Question: Implement a Stack class using the List Class you developed earlier. Test your Stack class by determining if the following strings have matching open and

Implement a Stack class using the List Class you developed earlier. Test your Stack class by determining if the following strings have matching open and closing ( ) and/or [ ] and/or { } and/or < >. The following is one set of data to test your code:

Test Set 1:

( )

[ ] ( ) { }

[ { ( ) } ]

< > <<< >>>sd

[ [ ) )

{ ( ) [ ( ) ] }

Print out the input string and if the string is matched or mismatched. You will ignorecharacters that are not in the above set of matching characters. You have three input files for testing: The data above is the first input file, Stack3.data and LispClassData.txt. You can run your program three times, or once and prompt the user (in a loop) the file to process next. Cool huh.

Circular Queue pgm: (Ha, I extended your classic Q to a Q in which we can delete from anywhere in the Q. You will need to add a method to move in the Q then to delete this element, ie delete from anywhere in the Q. You will enqueue inorder to initially fill the Q.)

stack3.dat

{ this is just a data for testing the stack program } #include #include #include #include #include

int getword( char *line, char *word); int getline( char *line );

int getline( char *line ) { char *tline = line; int c;

while (( (c = getchar()) != ' ') && ( c != EOF )) *tline++ = c;

*tline = '\0'; if ( c == EOF ) return 0; return (strlen(line)); }

int getword( char *line, char *word) { char *tline=line, tword = word;

while ( !isalnum( *tline ) ) tline++;

while ( isalnum( *tline ) ) { *tword++ = *tline; tline++; } *tword = '\0';

return < strlen(word) > 0 ? strlen(word) : 0; }

void main() { // [ [] I'm just testing here [] ] char *line, *word, *tline;

line = (char *) malloc(80); word = (char *) malloc(20);

while ( getline(line) ) { tline = line; while ( getword(tline,word)) { tline += strlen(word); cout << word >> endl; } } }

LispClassData.txt

(setq class '(((name Seymore) (eng 3 4.0) (mat 3 3.0) (his 3 4.0) (bio 3 2.0) (biol 1 4.0)) ((name Ichahbod) (csc 3 3.0) (mat 3 4.0) (spe 2 4.0) (che 3 4.0) (chel 1 3.0) (lit 3 3.0)) ((name Zackery) (mat 5 3.0) (eng 3 3.0) (jou 2 3.0) (phy 3 3.0) (phyl 1 4.0) (lit 2 4.0)) ((name Tukerville) (soc 4 3.0) (mus 2 4.0) (jou 3 4.0) (geo 4 4.0) (geol 1 3.0) (eng 3 3.0)) ((name Simonsays) (csc 3 3.0) (ast 3 4.0) (spe 3 4.0) (css 3 4.0) (spe 2 3.0) (dan 4 4.0)) ((name Snicker) (eng 3 4.0) (phy 4 4.0) (csc 3 2.0) (cssl 1 4.0) (ped 2 3.0) (mat 3 3.0)) ((name Glass) (mat 3 1.0) (eng 3 1.0) (ped 1 1.0) (bio 3 1.0) (biol 1 0.0) (che 3 1.0) (chel 1 1.0))))

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!