logo

Crowdly

Browser

Add to Chrome

IS52054A: ALGORITHMS 2 (2024-25)

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 function

Assume 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? 

0%
0%
0%
0%
View this question

For this tree:

What of the following traversal functions visit the nodes in this order?

4, 18, 3, 30, 20, 22, 0

0%
0%
0%
0%
View this question

The following numbers are inserted in a BST: 8, 10, 5, 9

What is printed on screen after executing function K? 

   

function

 K(root) 

if

(root==NULL)

      return

else 

      K(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 function
0%
0%
0%
0%
0%
View this question

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 function

Assume 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? 

0%
0%
0%
0%
0%
View this question

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  

View this question
In a singly linked-list, the instruction:

 tmp=tmp->next
0%
0%
0%
0%
0%
View this question
If you implement a stack using a linked list, this pseudocode:

function g()

     if(top==NULL)

          top=top->next
0%
0%
0%
0%
0%
View this question
If you implement a queue using a linked list, this operation:

function h(x)

    newNode=new Node(x)

    tail->next=Newnode

    tail=newNode

is missing something. What is it?
0%
0%
0%
0%
0%
View this question
If you implement a queue using a linked list, what does the following pseudocode do?

if (front==NULL and tail==NULL)

     front=newNode

     tail=newNode
0%
0%
0%
0%
0%
View this question
If you implement a stack using a linked list, this pseudocode:

function g(x)

      newNode=new Node(x)

      top=newNode

      newNode->next=top
0%
0%
0%
0%
View this question

Want instant access to all verified answers on learn.gold.ac.uk?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome