Download presentation
Presentation is loading. Please wait.
Published byDustin Oliver Modified over 9 years ago
1
Due: 2007/11/12
2
Problem 1 Rewrite function Push and Pop (Program 3.10 and 3.12) using an additional variable lastOp as discussed on Page 146. The queue should now be able to use all positions to hold up elements. The complexity of each of your functions should be O(1) (exclusive of the time taken to double queue capacity when needed).
3
Problem 2 1. Please implement the class Queue by using stacks. 2. Suppose that you start with an empty stack. After a sequence of n inqueues (insertion) and dequeues (deletion) operations, what is the average time complexity for each operation. please reason your answer.
4
Problem 3 Given the following maze: 1.Trace out the action of Program 3.16 on the maze and find a path through the maze 2.Rewrite Program 3.16 so that it can find out the shortcut. 123456789 1011110110 2100100001 3110100110 4111000110 5001001101 6110110111 7111100011 8111100100 entrance exit
5
Problem 4 1. Given an infix expression 6 / 2 * 3 + 4 * 5 Use tables like Section 3.6.3 and Figure 3.16 to describe how you convert it into postfix notation and how you evaluate its value. 2. Write an algorithm to convert an infix expression into prefix notation.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.