

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Spring 2009 Voicu Popescu Assignment 3 Due Friday February 6th, 11:59PM Running Time Analysis and Stacks
Of course once you get n=4 case to work you should devise additional cases with different n values to ensure your program truly works. b. Question 2: Name your program file as โstack.cppโ. โstack.cppโ should implement the operations explained in โstack.hโ. A sample test file โstackTest.cppโ is also provided. Examine and run that program to see what is expected. You can play with that file and add more test as you like. You will not turnin that file. Question 2 part b: Name your program file as โparenthetic.cppโ. โparenthetic.cppโ should read the input strings from file โparentheticโinputโ. The input file has one string per line. The strings are read from the file. The
standard output not to a file). (You do not have to evaluate the expressions) c. Questions 1 and 2: Turn in a PDF document named as โa3.pdfโ with your answers to the questions. Read General turnin instructions parts E, F and G very carefully, on the website. d. Question 3 (Extra): Name your program file as โhanoi.cppโ. โhanoi.cppโ should solve Towers of Hanoi puzzle for n = 5 using your stack class. You need to solve the puzzle in the minimum number of moves. You are supposed to move all the disks from peg a to peg c. Your program should print out the elements in the three stacks from bottom to top at the beginning and after each move to the standard output. Assume that you have the elements 5,4,3,2,1 at peg a from bottom to top at the beginning. The format for output is given as files for n= (โhanoi2โoutputโ) and n=3 (โhanoi3โoutputโ). You can run your program with n=3, direct the output to a temporary file and diff your output with the given โhanoi3โoutputโ file. Assuming that your executable is called โhanoi" which solves n=3: ./hanoi > myhanoi3โoutput diff myhanoi3โoutput hanoi3โoutput Then, make your program solve n=5, and check your output for correctness by yourself. e. Your codes MUST compile on lore.cs.purdue.edu for it to be graded. f. All of your documents (permutation.cpp, stack.cpp, parenthetic.cpp, a3.pdf, hanoi.cpp (OPTIONAL)) MUST be in the directory A3. In the directory above A3, run the command on lore.cs.purdue.edu