Binary Search Trees Practice Quiz

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

If the following elements were added to a binary search tree starting from left to right, what will be the height of the tree? 78, 90, 13, 43, 4, 97, 82, 87, 103, 96

3

If the following elements were added from left to right into a Binary Search Tree, what would be the height? 90, 50, 123, 43, 32, 67, 111, 124, 70, 93, 91, 120

4

How does the following tree look like after removing the item "50" from it (according to the algorithm explained in the lectures)?

55 replaces 50

How does the following binary search tree look like after adding the item 85 to it? root is 50; left child is 20; right child 60; 60 has right child 80; 80 has right child 90;

90 gets a new left child of 85.

What does the following tree look like after adding the name "Ellie" to it?

Left of lance

Consider the following binary search tree. Based on the algorithms covered in the lectures, what is the resulting tree after removing item "40" ?

Match each operation to its running time (N is the number of nodes in the tree) Adding an item to a binary search tree (worst case scenario) O(N) adding an item to a binary search tree (average case scenario) O(log n) finding a specific item in a binary search tree (worst case scenario) O(N) removing an item from a binary search tree (worst case scenario) O(N) Removing an item from the binary search tree (average case scenario) O(log n) finding a specific item in a binary search tree (average case scenario) O(log n)

In the context of binary search trees, what is the worst case running time for the add operation?

O(N)

In the context of binary search trees, what is the worst case running time for the remove operation?

O(N)

In the context of binary search trees, what is the average case running time for the add operation?

O(log N)

In the context of binary search trees, what is the average case running time for the remove operation?

O(log N)

The data in a node's ____________ subtree are less than the data in a node's _____________ subtree.

left, right

In the algorithm for removing a node from a binary search tree, if the node being removed has two children, the algorithm:

sets the item of the node being removed to that of the least node in the right subtree of the node being removed, then sets the corresponding reference of that node's parent to null.

A tree that is unbalanced will have runtimes similar to a linked list.

True

The shape of a binary search tree affects the efficiency of the simple recursive search algorithm.

True


Set pelajaran terkait

Equity Markets and Stock Valuation - Chapter 7

View Set

Chapter 28: A Case of Depression

View Set