



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Exam; Professor: Padua-Perez; Class: OBJECT-ORIENTED PROG II; Subject: Computer Science; University: University of Maryland; Term: Summer I 2008;
Typology: Exams
1 / 7
This page cannot be seen from the preview
Don't miss anything!




First Name (PRINT): ___________________________________________________
Last Name (PRINT): ___________________________________________________
University ID: _________________________________________________________
I pledge on my honor that I have not given or received any unauthorized assistance on this examination.
_Your signature: ______________________________________________________________
Instructions
This exam is a closed-book and closed-notes exam. Total point value is 100 points, 50 minutes exam. Please use a pencil to complete the exam. PUNT RULE: For any question, you may write PUNT, and you will get ¼ of the points for the question (rounded down). If you feel totally lost on a question, you are encouraged to punt rather than write down an incorrect answer in hopes of getting some partial credit. WRITE NEATLY. If we cannot understand your answer, we will not grade it (i.e., 0 credit).
Grader Use Only
#1 Software Engineering ( 30 )
#2 OO Design (UML) (20)
#3 GUI/Inner Classes (12)
#4 Heaps ( 14 )
#5 Binary Trees ( 24 )
Total (100)
Answer: Any four of: Problem Specification, Program Design, Algorithms and Data Structures, Coding and Debugging, Testing and Verification, Documentation and Support, Maintenance
Answer: Testing where we are allowed to examine the code.
Answer: Testing where we are not allowed to examine the code. Tests behavior in response to inputs.
Answer: Testing to see if some functionality has been lost.
package innerClass;
class Tetris { public void playGame() { System.out.println("Playing Tetris"); } }
public class Driver { public static void main(String[] args) { Tetris megaTetris = /* COMPLETE THIS ASSIGNMENT */ } }
Answer:
Tetris megaTetris = new Tetris() { public void playGame() { System. out .println("Playing MegaTetris"); } };
Use the following heap to answer the questions that follow.
Answer: 7 10 8 13 20
7
10
13 20
8
Answer:
Answer:
a. F Every heap is a binary search tree. b. F A post-order traversal of a heap will list its values in increasing order. c. T The heap will always be a balanced-tree (elements can be inserted in any order) d. T The time required to find the maximum element is O(1). e. T A sorted array represents a heap. f. T Priority queues can be implemented using heaps.
8
10
13
20
3
10
13 20
7
8
Answer:
public void removeLeaves() { if (root == null) return; else if (root.left == null && root.right == null) root = null; else { removeLeavesAux(root.left, root); removeLeavesAux(root.right, root); } }
private void removeLeavesAux(Node rootAux, Node parent) { if (rootAux.left == null && rootAux.right == null) if (rootAux == parent.left) parent.left = null; else parent.right = null; else if (rootAux.left == null && rootAux.right != null) removeLeavesAux(rootAux.right, rootAux); else if (rootAux.left != null && rootAux.right == null) removeLeavesAux(rootAux.left, rootAux); else { removeLeavesAux(rootAux.left, rootAux); removeLeavesAux(rootAux.right, rootAux); } }