Vidyalelo
Data Structure · all questions

Heaps
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

166

Questions

5/9

Page

Pick an option on a question to see the right answer and solution.

The relationship of skew heaps to leftist heaps is analogous to that of?

Select an option to see the answer and solution.

Given the pseudo code, state whether the function for merging of two heap is correct or not?
mergeTree(p,q)
if p.root.value <= q.root.value
return p.addTree(q)
else
return q.addTree(p)

Select an option to see the answer and solution.

What is the run time efficiency of an insertion algorithm?

Select an option to see the answer and solution.

In a leftist heap, all the operations should be performed on?

Select an option to see the answer and solution.

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)

Select an option to see the answer and solution.

Should leaves in ternary heap be distributed from left to right.

Select an option to see the answer and solution.

If we implement heap as min-heap, deleting root node (value 1)from the heap. What would be the value of root node after second iteration if leaf node (value 100) is chosen to replace the root at start.
Heaps mcq question image

Select an option to see the answer and solution.

Heap exhibits the property of a binary tree?

Select an option to see the answer and solution.

Pointer manipulation is generally more time-consuming than multiplication and division.

Select an option to see the answer and solution.

Which one of the following array elements represents a binary min heap?

Select an option to see the answer and solution.

Time taken in decreasing the node value in a binomial heap is

Select an option to see the answer and solution.

Out of the following given options, which is the fastest algorithm?

Select an option to see the answer and solution.

In a max-heap, element with the greatest key is always in the which node?

Select an option to see the answer and solution.

What does this pseudo_code return?
int myfun(heap_arr[])
{
	int mini=INF;
	for(int i=0;i<tot_node;i++)
	mini=min(mini,heap_arr)
	return mini;
}

Select an option to see the answer and solution.

For construction of a binary heap with 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. }

Select an option to see the answer and solution.

Descending priority queue can be implemented using . . . . . . . .

Select an option to see the answer and solution.

How many nodes does a leftist tree with r nodes must have?

Select an option to see the answer and solution.

What is wrong with the following code of insertion in fibonacci heap.
Choose the correct option
FIB-INSERT(H, x)
degree[x]= 0
p[x]=  NIL
child[x] =NIL
left[x] =x
right[x] =x
mark[x] =FALSE
concatenate the root list containing x with root list H 
if min[H] = NIL or key[x] > key[min[H]]
then min[H]= x
n[H]= n[H] + 1

Select an option to see the answer and solution.

What is the complexity of given function of insertion.
insert(int n)
{
	if(buffer_size()< maxi_biffer_size())
	buffer_aar[ind]==n;
	else
	move_to_heap(buffer,buffer+maxi_buffer_size())
}

Select an option to see the answer and solution.

In skew heaps, certain constraints are to be met in order to perform swapping.

Select an option to see the answer and solution.