Data Structure Questions and Answers-Binary Search Iterative

 

 Help authour, Buy PDF Ebook   >>>Click Here<<<

Data Structure Questions and Answers-Binary Search Iterative

Click on any option to know the CORRECT ANSWERS

Question 6
What is the average case time complexity of binary search using recursion?
A
O(nlogn)
B
O(logn)
C
O(n)
D
O(n2)
Management Questions answers

Question 6 Explanation: 
T(n) = T(n/2) + 1, Using the divide and conquer master theorem.

Question 7
What are the applications of binary search?
A
To find the lower/upper bound in an ordered sequence
B
Union of intervals
C
Debugging
D
All of the mentioned
Civics Test Questions answers

Question 7 Explanation: 
All of the mentioned can be realized by binary search.

Question 8
Choose among the following code for an iterative binary search.
A

public static int iterative(int arr[], int key) { 	int low = 0; 	int mid = 0; 	int high = arr.length-1; 	whil
B

public static int iterative(int arr[], int key) { 	int low = 0; 	int mid = 0; 	int high = arr.length-1; 	while
C

public static int iterative(int arr[], int key) { 	int low = 0; 	int mid = 0; 	int high = arr.length-HRM Questions answers 

Question 8 Explanation: 
Find the 'mid', check if it equals the key, if not, continue the iterations until low <= high.

Question 9
Binary Search can be categorized into which of the following?
A
Brute Force technique
B
Divide and conquer
C
Greedy algorithm
D
Dynamic programming
ICT Questions answers

Question 9 Explanation: 
Since 'mid' is calculated for every iteration or recursion, we are diving the array into half and then try to solve the problem.

Question 10
Given an array arr = {5, 6, 77, 88, 99} and key = 88; How many iterations are done until the element is found?
A
1
B
3
C
4
D
2
Reasoning Questions answers

Question 10 Explanation: 
Iteration1 : mid = 77; Iteration2 : mid = 88;

There are 10 questions to complete.

 

 Download all FREE PDF Ebook >>>CLICK HERE<<<