Comp 285 Test 3

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

TrieSearch(root, "RAIN") visits ___ node(s) when searching the trie below. (Assume that to "visit" a node means accessing the node's children in TrieSearch.)

1

What is the height of a BST built by inserting nodes in the order in the order 20, 10, 30

1

In the following 2-3-4 tree, a right rotation on the root's left child moves key ___ into the root and 12 into the root's middle1 child

10

If search key =60, identify the sequence of nodes that are visited and the outcome.

100 -> 70 -> 60

What is the minimum possible height of an AVL tree with the following nodes in order? 320, 470, 500, 540, 700, 650, 870

2

What is the number of children that a leaf node 2-3-4 B-tee must have

2

Identify the outcome of the following function calls. BSTGetHeight(node X) BSTGetHeight(node C), BSTGetHeight(node Q) BSTGetHeight(nodeA)

2, 0 ,1,3

Which tree is formed after splitting both full nodes

2-3-4 tree

Calling TrieRemove(root, "PEACH") on the trie below removes___ nodes from the trie

3

What is the depth of the "Practical.jpg" Node?

3

What is the height of the BST built by inserting nodes in the order 12, 24, 23,48,47?

3

When using the fucntion BTreeRemovekey(node,keyindex) to remove a key from a 2-3-4 tree node, which is not a valid value for key index?

3

Identify the order of the nodes that would be printed during a BST inorder traversal

3,4,5,6,7,8,9

if a node with key 50 is inserted into the following BST, What sequence of nodes is visited and where is the new node inserted?

40-> 80 -> 70 -> 60, as 60's left child

What statement is true about the insertion of new node in an AVL Tree?

AVLTreeInsert updates heights on all ancestors after inserting the node

Which XXX will complete the following partial algorithm for the right rotation of an AVL Tree. AVLSTreeRotateRight(tree,node){ leftRightChild= node->left ->right if(node->parent!=null) AVLTreeReplaceChild(node->parent,node,node->left) else{ tree->root = node->left tree->root->parent = null } XXX }

AVLTreeSetChild(node->left,"right", node) AVLTreeSetChild(node,"left",leftRightChild).

Where will a new node with key 5 be inserted into the following BST?

As 4's right child

What function is first called for removing a node from an AVL Tree?

BSTSearch

Which XXX completes the BST in order traversal algorithm? BSTPrintInOrder(node){ if(node is null) return XXX print node BSTPrintInorder(node->right) }

BSTPrintInorder(node ->left)

Identify which nodes are printed first and last

F and D

Identify the following type of the following binary tree.

Full, not complete, not perfect

Which is the worst-case height of AVL?

Less than or equal to 1.5 times compared to the minimum binary tree height

Is this an AVL tree? Justify your answer.

No, as the tree is not a binary search tree(BST)

The space complexity of a BST insertion algorithm is

O(1)

Identify the ancestor(s) of node P

X,A

What are the parent of the "Theory.doc" node?

Science

Identify the error in the red-black tree

The path from the root to a null leaf node does not have the same number of black nodes

Which XXX would replace the missing statement in the following algorithm for updating the height of an AVL tree? AVLTreeUpdateHeight(node){ leftHeight=-1 if(node->left!=null){ leftHeight=node->left->height } rightHeight=-1 if(node->right!=null){ rightHeight=node->right->height } XXX }

node->height=max(leftHeight,rightHeight)+1

Which XXX should replace the missing statement in the following BSTGetHeight algorithm? BSTGetHeight(node){ if(node is null) return -1 leftHeight = BSTGetHeight(node->left) rightHeight= BSTGetHeight(node->right) XXX }

return 1+ max(leftHeight, rightHeight)

A BTree merge operates on a node with 1 key and increases the node's keys to 2 or 3 using either a(n)

rotation or fusion

Which XXX would replace the missing statement in the given RBTreeReplaceChild utility function? RBTreeReplaceChild(parent, currentChild, newChild){ If (parent -> left == currentChild) Return RBTreeSetChild(parent, "left", newChild) XXX Return RBTreeSetChild(parent, "right", newChild) Return false

else if(parent ->right == currentchild)

Which XXX would replace the missing statement in given algorithm for rebalancing an AVL tree a node is removed? AVLTreeRebalance(tree, node){ AVLTreeUpdateHeight(node) XXX{ if(AVLTreeGetBalance(node->right) ==1) AVLTreeRotateRight(tree, node->right)

if(AVLTreeGetBalance(node)== -2)

Which XXX would replace the missing statement in the given algorithm for finding the uncle of a node in an RBT? RBTreeGetUncle(node){ grandparent= null if(node -> parent != null) grandparent= node->parent-> parent if(grandparent==null) Return null XXX Return grandparent ->right Else Return grandparent ->left

if(grandparent->left ==node ->parent)

Which XXX completes the BST search algorithm? BSTSearch(tree,key){ cur= tree->root while(cur is not null) if(key == cur ->key) return cur else XXX cur = cur ->left else cur = cur ->right return null }

if(key<cur->key)

Which XXX would replace the missing statement in the algorithm for inserting a new node in an empty AVL tree? AVLTreeInsert(tree, node){ XXX{ tree->root = node node->parent = null Return } ... }

if(tree->root ==null)

What type of node is "English"?

leaf

When calling the recursive BTSRemoveNode function to remove node 8, a recursive call is made to remove ___

node 9


Conjuntos de estudio relacionados

Physics - Module 9: Conservation of Energy

View Set

Fahmy 3030 ===> 12/2 Russiab English sentences 1

View Set