Quiz 7 - Trees (Data Structures)

¡Supera tus tareas y exámenes ahora con Quizwiz!

Which of the following is a preorder traversal of the tree? 7 / \ 5 8 / \ \ 2 6 12 \ / 4 10 / 8

7, 5, 2, 4, 6, 8, 12, 10, 8

If we remove the minimum from this binary heap, the graph will no longer be a tree. Which node is then removed and its value is put into the root node (but eventually, its value will percolate down)? 1 / \ 3 6 / \ / 5 9 8

8

What is the value of the root node? 8 / \ 5 4 / \ \ 9 7 11 / \ / 1 12 3 / 2

8

If a new value is inserted into this binary heap, where would the new node be created? 1 / \ 3 6 / \ / 5 9 8

As a right child of the node with value 6

In a binary search tree, to remove a node, let's call it, currentNode, that has two children, the algorithm the book gives does what?

It finds the minimum node of the right subtree of currentNode. It replaces currentNode's key and payload with that minimum node's key and payload. That minimum node is then taken out of the tree.

In the worst case, what is the big-O of inserting, finding, or deleting a node in a binary search tree?

O(n)

Whenever a new value (which is not already in the tree) is inserted into a BINARY SEARCH TREE, the new tree node created will be a leaf node.

True

When 7 is inserted, this tree is no longer balanced. Notice that the height on the left side of the root is 3 while the height of the right side of the root is 1. To fix this, using the AVL algorithm ... 20 / \ 10 40 / \ 5 15 \ 7

We can use a single right rotation.

Which of the following is the correct list of lists representations of this tree? A / \ B C / / D E

['A', ['B', ['D', [], []], []], ['C', ['E', [], []], []]]

What is the big-O of a binary search tree that has been balanced using the AVL algorithm?

log(n)

What is the value of the sibling of the node with value 1? 8 / \ 5 4 / \ \ 9 7 11 / \ / 1 12 3 / 2

12

Which of the following is a inorder traversal of the tree? 7 / \ 5 8 / \ \ 2 6 12 \ / 4 10 / 8

2, 4, 5, 6, 7, 8, 8, 10, 12

How many leaves does this tree have? 8 / \ 5 4 / \ \ 9 7 11 / \ / 1 12 3 / 2

4

What is the height of this tree? 8 / \ 5 4 / \ \ 9 7 11 / \ / 1 12 3 / 2

4

Which of the following is a postorder traversal of the tree? 7 / \ 5 8 / \ \ 2 6 12 \ / 4 10 / 8

4, 2, 6, 5,8, 10, 12, 8, 7


Conjuntos de estudio relacionados

Old Testament Survey II Quizlet (2/2)

View Set

Mrs. Davis - English Final Study guide- The Glass Castle

View Set

Unit 10.2. Popular culture. Speakout Upper-Intermediate.

View Set

*Chapter 17: Standard scores and normal distributions( FINAL) sd and mean

View Set

BIOL 3500: Recombinant DNA Technology

View Set

Fundamentals of Economics Quiz (v)

View Set

MAA136 Computer Applications: Word

View Set

Chapter 10: Capital Budgeting Cash Flows

View Set

Assignment: Quiz: CompTIA Network+ N10-008 Post-Assessment Quiz

View Set