Data Structure Questions and Answers-Binary Heap

 

 Buy/Download all MCQ Ebook   >>>Click Here<<<

Data Structure Questions and Answers-Binary Heap

Click on any option to know the CORRECT ANSWERS

Question 1
What is the space complexity of searching in a heap?
A
O(logn)
B
O(n)
C
O(1)
D
O(nlogn)
Data interpretation (DI) Questions answers

Question 1 Explanation: 
None.

Question 2
What is the best case complexity in builading a heap?
A
O(nlogn)
B
O(n2)
C
O(n*longn *logn)
D
O(n)
Reading comprehension Questions answers

Question 2 Explanation: 
The best case compexity occur in botton-up construction when we have a sortes array given.

Question 3
Given the code, choose the correct option that is consistent with the code

	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)

Here A is the heap

A
It is the build function of max heap
B
It is the build function of min heap
C
It is general build function of any heap
D
None of the mentioned
Education Questions answers

Question 3 Explanation: 
Since in every condition we are comparing the current value is less than the parent of that node.So this is build function of Max heap.

Question 4
What is the location of parent node for any arbitary node i?
A
(i/2) position
B
(i+1)/ position
C
floor(i/2) position
D
ceil(i/2) position
Home science Questions answers

Question 4 Explanation: 
For any node child nodes are located at either 2*i, 2*i +1 So the parent node could be found by taking the floor of the half of child node.

Question 5
State the complexity of algorithm gien below

	int function(vector<int> arr) 	int len=arr.length(); 	if(len==0) 	return; 	temp=arr[len-1]; 	arr.pop....back(); 	return temp;
A
o(n)
B
O(logn)
C
O(1)
D
O(n logn)
Arab culture Questions answers

Question 5 Explanation: 
Deletion in a min-heap is in O(1) time.

There are 5 questions to complete.

 

 Buy/Download all MCQ Ebook >>>CLICK HERE<<<