Looking for IS52054A: ALGORITHMS 2 (2024-25) test answers and solutions? Browse our comprehensive collection of verified answers for IS52054A: ALGORITHMS 2 (2024-25) at learn.gold.ac.uk.
Get instant access to accurate answers and detailed explanations for your course questions. Our community-driven platform helps students succeed!
For this pseudocode:
function Z(root,x) if (root==NULL) Node newNode= new Node(x) root=newNode else if(x %2==0) Z(root->left,x) else Z(root->right,x) end functionAssume that the tree starts empty. After executing the function Z with the following numbers: 8, 9, 6, 3, 4. What is the leftmost leaf in the tree?For this tree:
What of the following traversal functions visit the nodes in this order?
4, 18, 3, 30, 20, 22, 0
functionK(root)
if(root==NULL)
return
elseK(root->left)
k(root->right)
if (root->left!= NULL and root->right!=NULL)
print("C3:", root->data)
else if
(root->left== NULL and root->right==NULL)
print("C1:", root->data)
else
if
(root->left== NULL)
tmp=root->data
root->data=root->right->data
root->right->data=tmp
else
tmp=root->data
root->data=root->left->data
root->left->data=tmp
end functionFor this pseudocode:
function Z(root,x) if (root==NULL) Node newNode= new Node(x) root=newNode else if(x %2==0) Z(root->left,x) else Z(root->right,x) end functionAssume that the tree starts empty. After executing the function Z with the following numbers: 8, 9, 6, 3, 4. What is the right child of 6?The following numbers are inserted in a BST: 25, 17, 32, 35, 28. What number is stored in the right child of root after executing Z with input arguments: the root of the BST and number 32?function Z(root, x) if (root==NULL) return NULL else if(x < root->data) root->left=Z(root->left,x) else if (x > root->data) root->right=Z(root->right,x) else if (root->left!= NULL and root->right!=NULL) Node tmp=getRMin(root->right) root->data=tmp->data root->right=Z(root->right, root->data) else if (root->left== NULL and root->right==NULL) root=NULL return root end function