Chapter 25: A binary search tree implementation

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

18. Given a binary search tree with n nodes and height h, what is the maximum number of comparisons that each operation requires for the method add? a. O(h) b. O(n) c. O(log h) d. O(1)

A

Every addition to a binary search tree adds a new a. leaf b. parent c. ancenstor d. root

A

Given a binary search tree with n nodes and height h, what is the maximum number of comparisons that each operation requires for the method getEntry? a. O(h) b. O(n) c. O(log h) d. O(1)

A

Given a binary search tree with n nodes and height h, what is the maximum number of comparisons that each operation requires for the method remove? a. O(h) b. O(n) c. O(log h) d. O(1)

A

If a node x is the inorder predecessor of node y then node x must appear in y's _____ subtree. a. left b. right c. middle d. all of the above

A

If a node x is the inorder successor of node y then node x must appear in y's _____ subtree. a. right b. left c. middle d. all of the above

A

In a binary search tree, the getInorderIterator inherited from the class BinaryTree sorts data a. in ascending order b. in descending order c. in striped order d. none of the above

A

In the interface SearchTreeInterface, the method getEntry returns an object in the tree that matches the given entry according to the entry's _____ method. a. compareTo b. equalTo c. equals d. same

A

In the interface SearchTreeInterface, what does the method add return if the object being added doesn't exist? a. null b. false c. 0 d. throws an exception

A

In the interface SearchTreeInterface, what does the method getEntry return if the object being sought doesn't exist? a. null b. false c. 0 d. throws an exception

A

In the interface SearchTreeInterface, what does the method remove return if the object being sought doesn't exist? a. null b. false c. 0 d. throws an exception

A

The data in a node's _____ subtree are less than the data in a node's _____ subtree. a. left, right b. right, left c. left, middle d. middle, right

A

The inorder predecessor of a node N is a. the largest entry in N's left subtree b. the largest entry in N's right subtree c. the smallest entry in N's left subtree d. the smallest entry in N's right subtree

A

The inorder successor of a node N is a. the smallest entry in N's right subtree b. the smallest entry in N's left subtree c. the largest entry in N's right subtree d. the largest entry in N's left subtree

A

The largest entry in a node N's left subtree is a. the subtree's rightmost node b. the subtree's leftmost node c. the left child of N d. the right child of N

A

The largest entry in a node N's right subtree is a. the subtree's rightmost node b. the subtree's leftmost node c. the left child of N d. the right child of N

A

The maximum possible height of a binary search tree with n nodes is a. n b. log n c. n2 d. n-2

A

The smallest entry in a node N's left subtree is a. the subtree's leftmost node b. the subtree's rightmost node c. the left child of N d. the right child of N

A

The smallest entry in a node N's right subtree is a. the subtree's leftmost node b. the subtree's rightmost node c. the left child of N d. the right child of N

A

What is the worst-case performance of the add method in a binary search tree with linked nodes? a. O(n) b. O(1) c. O(log n) d. O(n2)

A

What is the worst-case performance of the add method in a full binary search tree with linked nodes? a. O(log n) b. O(n) c. O(1) d. O(n2)

A

What is the worst-case performance of the getEntry method in a binary search tree with linked nodes? a. O(n) b. O(1) c. O(log n) d. O(n2)

A

What is the worst-case performance of the getEntry method in a full binary search tree with linked nodes? a. O(log n) b. O(n) c. O(1) d. O(n2)

A

What is the worst-case performance of the remove method in a binary search tree with linked nodes? a. O(n) b. O(1) c. O(log n) d. O(n2)

A

What is the worst-case performance of the remove method in a full binary search tree with linked nodes? a. O(log n) b. O(n) c. O(1) d. O(n2)

A

n the interface SearchTreeInterface, what does the method add return if the object being added already exists in the tree? a. the existing entry that matched the parameter b. true c. 1 d. throws an exception

A

When adding an entry to a binary search tree, when does the search ends? a. when the item is found b. at a leaf if the entry is not already in the tree c. both a & b d. none of the above

C

T/F: Binary search trees are not an efficient choice for searching if the data tends to remain stable.

F

T/F: Every addition to a binary search tree adds a new root.

F

T/F: For best performance, when you add entries to a binary search tree, you should add them in sorted order.

F

T/F: Searching a binary search tree is like performing a binary search of an array.

T

T/F: The shape of a binary search tree affects the efficiency of the simple recursive search algorithm.

T

T/F: When adding an entry to a binary search tree, the search ends at a leaf if the entry is not already in the tree.

T

T/F: You can create different binary search trees from the same data.

T

T/F: You can implement the ADT dictionary using a binary search tree.

T


Ensembles d'études connexes

Lesson 8: Listing Agreements: Pop Quiz

View Set

Air Methods Part 135 Study Guide

View Set

Reasoning in Algebra and Geometry

View Set

Oracle Study Guide Sections 1-10

View Set

Lewis Chapter 37 Vascular Disorders

View Set