Data Structure Questions and Answers-Binary Search Iterative

DOWNLOAD FREE PDF <<CLICK HERE>>

Data Structure Questions and Answers-Binary Search Iterative

Congratulations - you have completed Data Structure Questions and Answers-Binary Search Iterative.

You scored %%SCORE%% out of %%TOTAL%%.

Your performance has been rated as %%RATING%%


Your answers are highlighted below.
Question 1 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER]
What is the advantage of recursive approach than an iterative approach?
A
Consumes less memory
B
Less code and easy to implement
C
Consumes more memory
D
All of the mentioned
Question 1 Explanation: 
A recursive approach is easier to understand and contains fewer lines of code.

Question 2 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER]
Choose the appropriate code that does binary search using recursion.
A

public static int recursive(int arr[], int low, int high, int key) { 	int mid = low + (high - low)/2; 	if(arr[mid
B

public static int recursive(int arr[], int low, int high, int key) { 	int mid = low + (high + low)/2; 	if(arr[mid
public static int recursive(int arr[], int low, int high, int key) { 	int mid = low + (high - low)/2; 	if(arr[mid
Question 3 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER]
Given an input arr = {2, 5, 7, 99, 899}; key = 899; What is the level of recursion?
A
5
B
2
C
3
D
4
Question 3 Explanation: 
level 1: mid = 7

level 2: mid = 99

level 3: mid = 899(this is the key).

Question 4 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER]
Given an array arr = {45, 77, 89, 90, 94, 99, 100} and key = 99; what are the mid values(corresponding array elements) in the first and second levels of recursion?
A
90 and 99
B
90 and 94
C
89 and 99
D
89 and 94
Question 4 Explanation: 
Trace the input with the binary search recursive code.

Question 5 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER]
What is the worst case complexity of binary search using recursion?
A
O(nlogn)
B
O(logn)
C
O(n)
D
O(n2)
Question 5 Explanation: 
Using the divide and conquer master theorem.

Once you are finished, click the button below. Any items you have not completed will be marked incorrect. Get Results
There are 5 questions to complete.

DOWNLOAD FREE PDF <<CLICK HERE>>