
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
Information about quiz 3 for the cmsc 132 course, which covers binary search trees. The quiz will be a written, closed book, closed notes exam. Students are recommended to use pencil and eraser. The following exercises are provided to help students prepare for the quiz, but solutions will not be provided. Recursion and auxiliary methods are to be used in solving the problems. A java class definition for a binary search tree, and students are not allowed to add any variables to the class to answer the questions. The quiz questions include defining a constructor for an empty tree, implementing methods for adding a node, finding the number of non-leaf nodes, the height of the tree, and adding leaf nodes to an arraylist, as well as implementing a recursive method to check if a binary search tree is degenerate.
Typology: Quizzes
1 / 1
This page cannot be seen from the preview
Don't miss anything!

The third quiz for the course will be on Friday, July 18, during your lab session. The following list provides more information about the quiz:
The quiz will be a written quiz (no computer). Closed book, closed notes quiz. Answers must be neat and legible. We recommend that you use pencil and eraser.
The following exercises cover the material to be included in this quiz. Solutions to these exercises will not be provided, but you are welcome to discuss your solutions with the TA or instructor during office hours. We strongly recommend you do not use Eclipse to write the code associated with these exercises. Try to answer the exercises in a piece of paper and then use Eclipse to verify your solutions. This approach will better prepare you for the quiz.
Some recursion problems require an auxiliary method. For example, a recursive implementation for the tree size() method may use an auxiliary method that takes as parameter a reference to a Node. Keep this in mind when solving the problems below.
The following Java class definition for a binary search tree will be used to answer the questions that follow. Unlike project #3 the following tree is not polymorphic. Null is used to indicate an empty tree. For example, an empty BinarySearchTree has a null root, and a leaf node has null left and right fields. For this problem you may not add any variables (instance or static) to the class in order to answer the questions below.
public class BinarySearchTree <E extends Comparable