VIEWS: 3,441 PAGES: 6 CATEGORY: Other POSTED ON: 11/4/2009
CET 230 Applied Data Structures Fall 2001 MidTerm Exam 2 Name: 1. (10 points)Consider the usual algorithm to convert a fully parenthesized infix expression to a postfix expression. Suppose that you have read 10 input characters during a conversion and that the stack now contains these symbols: | | | + | | ( | bottom |___*___| Now, suppose that you read and process the 11th symbol of the input. Draw the stack for the case where the 11th symbol is: A. A number: B. A left parenthesis: C. A right parenthesis: D. A minus sign: E. A division sign but change the algorithm to the general case (not fully parenthesized): 2. (4 points) Entries in a stack are "ordered". What is the meaning of this statement? A. There is a first entry, a second entry, and so on. B. A collection of Stacks can be sorted. C. Stack entries may be compared with the compareTo method. D. The entries must be stored in a linked list. Page 1/6 CET 230 Applied Data Structures Fall 2001 MidTerm Exam 2 Name: 3. (4 points) Which of the following stack operations could result in stack underflow? A peek B. pop C. push D. Two or more of the above answers. 4. (4 points)Suppose we have an array implementation of the stack class, with twelve items in the stack stored at data[0] through data[11]. The CAPACITY is 42. Where does the push method place the new entry in the array? A. data[0] B. data[1] C. data[11] D. data[12] 5. (4 points) What is the postfix expression for the following infix: (a + b*(c - a) - d) A. d b c a - * a + - B. a b c a d - - * + C. a b c a - * + d - D. None of the above. 6. In the array version of the Stack class, which operations require linear time for (4 points) their worst-case behavior? A. is_empty B. peek C. pop D. push when the stack is below capacity E. None of these operations require linear time. 7. (4 points) What is the value of the postfix expression 6 3 2 4 - + * A. Something between -15 and -100 B. Something between -5 and -15 C. Something between 5 and -5 D. Something between 5 and 15 E. Something between 15 and 100 Page 2/6 CET 230 Applied Data Structures Fall 2001 MidTerm Exam 2 Name: 8. (4 points) One difference between a queue and a stack is: A. Queues require linked lists, but stacks do not. B. Stacks require linked lists, but queues do not. C Queues use two ends of the structure; stacks use only one. D. Stacks use two ends of the structure, queues use only one. 9. (4 points) Which of the following best describes the operation of the Queue class? A. First in first out. B. Last in first out. C. First in last out. D. Highest priority out first.. 10. In the circular array version of the Queue class, which operations require (4 points) constant time for their worst-case behavior? A. getFront B. insert when the capacity has not yet been reached C. isEmpty D. All of these operations require constant time. 11. (4 points)When doing an insert on a Queue class object which implementation may result in a linear time operation for their worst case behavior? A. Linked list implementation with head and tail references B. Linked list implementation with head, only, reference C. Partially filled array implementation with head and tail references when the CAPACITY has not been reached D. None of the above will require linear time in the worst case. 12. A queue has been implemented with a linked list, keeping track of a front node (4 points) and rear node with two reference variables. Which of these reference variables will change during an insertion into an EMPTY queue? A. Neither changes B. Only front changes. C. Only rear changes. D. Both change. Page 3/6 CET 230 Applied Data Structures Fall 2001 MidTerm Exam 2 Name: 13. (4 points) What is the importance of the stopping case in recursive methods? 14. In a real computer, what will happen if you make a recursive call without (4 points) making the problem smaller? A. The program keeps running until you press Ctrl-C. B. The results are non-deterministic. C. The run-time stack eventually overflows, halting the program. D. Any of the above may occur. 15. (4 points) Consider this method declaration: void zaboomafoo(int i) { if (i > 0) { zaboomafoo (i / 2); zaboomafoo (i / 2); } System.out.print("*"); } How many asterisks are printed by the method call zaboomafoo(5)? A. 3 B. 7 C. 11 D. 15 E. Some other number. 16. (4 points) What technique is often used to prove the correctness of a recursive method? A. Linear Regression. B. Probability Population. C. Mathematical Induction. D. Incremental Simulation. Page 4/6 CET 230 Applied Data Structures Fall 2001 MidTerm Exam 2 Name: Here is a small binary tree of integers that is needed for the next seven questions. 14 / \ 2 19 / \ / \ 1 5 15 30 \ / \ 12 22 40 17. (4 points) The left-most node of the right node of the root node of the tree has value. A. 1 B. 12 C. 15 D. 40 E. None of the above. 18. (2 points) The node with the value 12 is an ancestor of the node with the value 2. True False 19. (2 points) The node with the value 40 is a descendant of the node with the value 15. True False 20. (2 points)The tree is a complete tree. True False 21. (2 points) The tree is a full tree. True False 22. (2 points)The tree is arranged in manner that is useful as a binary search tree as required for class programming project 4. True False 23. (4 points) What is the depth of the tree?. A. 2 B. 3 C. 4 D. 5 Page 5/6 CET 230 Applied Data Structures Fall 2001 MidTerm Exam 2 Name: 24. (4 points) Given a binary tree with 18 nodes, what is the minimum possible depth of the tree? A. 1 B. 2 C. 3 D. 4 E. 5 25. For the following tree, what is the order of nodes visited using an in-order (4 points) traversal? 14 / \ 2 11 / \ / \ 1 3 10 30 / / 7 40 A. 1 2 3 7 10 11 14 30 40 B. 1 2 3 14 7 10 11 40 30 C. 1 3 2 7 10 40 30 11 14 D. 14 2 1 3 11 10 7 30 40 26. Using the binary search tree below, if we remove the root and replace it with (4 points) something from the left sub-tree, what will be the value of the new root? 14 / \ 2 22 / \ / \ 1 5 20 30 / / / 4 17 40 A. 1 B. 2 C. 4 D. 5 Page 6/6