Quiz-1

Question 1

Time: 00:00:00
For the construction of a binary heap with the property that parent node has value less than child node.In reference to that which line is incorrect. Line indexed from 1.

```1. add(int k)
2. {
3. heap_size++;
4. int i = heap_size - 1;
5. harr[i] = k;
6. while (i != 0 && harr[parent(i)] < harr[i])
7. {
8. swap(&harr[i], &harr[parent(i)]);
9. i = parent(i);
10. }
11. }```

Line -3

Line -3

Line – 5

Line – 5

Line – 6

Line – 6

Line -7

Line -7

Once you attempt the question then PrepInsta explanation will be displayed.

Start

Question 2

Time: 00:00:00
Given an array of element 5,7,9,1,3,10,8,4. Tick all the correct sequences of elements after inserting all the elements in a min-heap.

1,3,4,5,7,8,9,10

1,3,4,5,7,8,9,10

1,4,3,8,9,5,7,10

1,4,3,8,9,5,7,10

1,3,4,5,8,7,9,10

1,3,4,5,8,7,9,10

None of these

None of these

Once you attempt the question then PrepInsta explanation will be displayed.

Start

Question 3

Time: 00:00:00
Given the code, choose the correct option that is consistent with the code. (Here A is the heap)

```build(A,i)
left-> 2*i
right->2*i +1
temp- > i
if(left<= heap_length[A] ans A[left] >A[temp])
temp -> left
if (right = heap_length[A] and A[right] > A[temp])
temp->right
if temp!= i
swap(A[i],A[temp])
build(A,temp)```

It is the build function of the max heap.

It is the build function of the max heap.

It is the build function of min heap.

It is the build function of min heap.

It is general build function of any heap.

It is general build function of any heap.

None of the mentioned

None of the mentioned

Once you attempt the question then PrepInsta explanation will be displayed.

Start

Question 4

Time: 00:00:00

dynamic size

dynamic size

ease of insertion/deletion

ease of insertion/deletion

ease in randomly accessing a node

ease in randomly accessing a node

both dynamic size and ease of insertion/deletion

both dynamic size and ease of insertion/deletion

Once you attempt the question then PrepInsta explanation will be displayed.

Start

Question 5

Time: 00:00:00
What is the code below trying to print?

```void print(tree *root,tree *node)
{
if(root ==null) return 0
if(root-->left==node || root-->right==node || print(root->left,node)||printf(root->right,node)
{
print(root->data)
}
}```

just printing all nodes

just printing all nodes

not a valid logic to do any task

not a valid logic to do any task

printing ancestors of a node passed as the argument

printing ancestors of a node passed as the argument

printing nodes from the leaf node to a node passed as the argument

printing nodes from the leaf node to a node passed as the argument

Once you attempt the question then PrepInsta explanation will be displayed.

Start

Question 6

Time: 00:00:00
The following lines talk about deleting a node in a binary tree.(the tree property must not be violated after deletion)
i) from root search for the node to be deleted
ii)
iii) delete the node at
what must be statement ii) and fill up statement iii)

i)-find random node, replace with the node to be deleted. iii)- delete the node

i)-find random node, replace with the node to be deleted. iii)- delete the node

ii)-find node to be deleted. iii)- delete the node at the found location

ii)-find node to be deleted. iii)- delete the node at the found location

ii)-find deepest node, replace with the node to be deleted. iii)- delete a node

ii)-find deepest node, replace with the node to be deleted. iii)- delete a node

ii)-find deepest node, replace with the node to be deleted. iii)- the deepest node

ii)-find deepest node, replace with the node to be deleted. iii)- the deepest node

Once you attempt the question then PrepInsta explanation will be displayed.

Start

Question 7

Time: 00:00:00
Level order traversal of a tree is formed with the help of

depth-first search

depth-first search

dijkstra’s algorithm

dijkstra’s algorithm

prims algorithm

prims algorithm

Once you attempt the question then PrepInsta explanation will be displayed.

Start

Question 8

Time: 00:00:00
Consider the following pseudocode of insertion in XOR list and write the approximate code snippet of it. What will be the code for English statement

```void xor-linked-list insert(struct node **head_ref, int value)
{
node *new_node  = new (struct node);
new_node->value = value;
{
printf("invalid");
}
else
{
let b,c,d are nodes and a is to be inserted at beginning,
a address field must contain NULL xor b and b
address filed must be a xor c.
}
}```

```node* next = XOR ((*head_ref)->npx,  NULL);

```node* next = XOR ((*head_ref)->npx,  NULL);

```node* next = XOR ((*head_ref)->npx,  NULL);

```node* next = XOR ((*head_ref)->npx,  NULL);

```node* next = XOR ((*head_ref)->npx,  NULL);

```node* next = XOR ((*head_ref)->npx,  NULL);

```node* next = XOR ((*head_ref),  NULL);

```node* next = XOR ((*head_ref),  NULL);

Once you attempt the question then PrepInsta explanation will be displayed.

Start

Question 9

Time: 00:00:00
Given 10,8,6,7,9
swap the above numbers such that finally you got 6,7,8,9,10
so now reverse 10
9,7,6,8,10
now reverse 9
8,6,7,9,10
7,6,8,9,10
6,7,8,9,10
at this point 6 is ahead so no more reversing can be done so stop.
To implement above algorithm which data structure is better and why ?

linked list. because we can swap elements easily

linked list. because we can swap elements easily

arrays. because we can swap elements easily

arrays. because we can swap elements easily

xor linked list. because there is no overhead of pointers and so memory is saved

xor linked list. because there is no overhead of pointers and so memory is saved

doubly linked list. because you can traverse back and forth

doubly linked list. because you can traverse back and forth

Once you attempt the question then PrepInsta explanation will be displayed.

Start

Question 10

Time: 00:00:00
What does first and last nodes of a xor linked lists contain ? (let address of first and last be A and B)

NULL xor A and B xor NULL

NULL xor A and B xor NULL

NULL and NULL

NULL and NULL

A and B

A and B

NULL xor A and B

NULL xor A and B

Once you attempt the question then PrepInsta explanation will be displayed.

Start

["0","40","60","80","100"]
["Need more practice! \r\n","Keep trying! \r\n","Not bad! \r\n","Good work! \r\n","Perfect! \r\n"]

Buy Capgemini Pseudo Code Paid Materials

Join Capgemini Online Classes

Personalized Analytics only Availble for Logged in users

Analytics below shows your performance in various Mocks on PrepInsta

Your average Analytics for this Quiz

Rank

-

Percentile

0%

Get over 200+ Courses under One Subscription

Don’t settle Learn from the Best with PrepInsta Prime Subscription

Learn from Top 1%

One Subscription, For Everything

The new cool way of learning and upskilling -

Limitless Learning

One Subscription access everything

Job Assurance