Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem #2 (All Kinds of Sorting) Sort a single column array and/or sort a 2 dimensional array of characters given any column. Here is what

Problem #2 (All Kinds of Sorting)

Sort a single column array and/or sort a 2 dimensional array

of characters given any column. Here is what I used as my

template specification.

//This class sorts arrays either ascending or descending

template

class Prb2Srt

{

private:

int *index; //Index that is utilized in the sort

public:

Prb2Srt(){index=NULL;}; //Constructor

~Prb2Srt(){delete []index;}; //Destructor

T *srtArry(const T*,int,bool); //Sorts a single column array

T *srtArry(const T*,int,int,int,bool); //Sorts a 2 dimensional array represented as a 1 dim array

};

Driver program for the above class. Create your own file to read.

cout<<"The start of Problem 2, the sorting problem"<

Prb2Srt rc;

bool ascending=true;

ifstream infile;

infile.open("Problem2.txt",ios::in);

char *ch2=new char[10*16];

char *ch2p=ch2;

while(infile.get(*ch2)){cout<<*ch2;ch2++;}

infile.close();

cout<

cout<<"Sorting on which column"<

int column;

cin>>column;

char *zc=rc.srtArry(ch2p,10,16,column,ascending);

for(int i=0;i<10;i++)

{

for(int j=0;j<16;j++)

{

cout<

}

}

delete []zc;

cout<

The output from this problem.

The start of Problem 2, the sorting problem

Lbekoeddhoffbmi

Lkcmggjcdhhglif

Cgldjhcekjigcdd

Cgldjhcekjigcdm

Bffmdbkcenlafjk

Fggdijijegfblln

Jjlncnimjldfedj

Amliglfohajcdmn

Balgfcaelhfkgeb

Kmlhmhcddfoeilc

Sorting on column 15

Cgldjhcekjigcdm

Fggdijijegfblln

Amliglfohajcdmn

Bffmdbkcenlafjk

Jjlncnimjldfedj

Lbekoeddhoffbmi

Lkcmggjcdhhglif

Cgldjhcekjigcdd

Kmlhmhcddfoeilc

Balgfcaelhfkgeb

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions

Question

1.The difference between climate and weather?

Answered: 1 week ago

Question

1. What is Fog ?

Answered: 1 week ago

Question

How water vapour forms ?

Answered: 1 week ago

Question

What is Entrepreneur?

Answered: 1 week ago

Question

Which period is known as the chalolithic age ?

Answered: 1 week ago

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago