adplus-dvertising

Welcome to the Sorting and Searching MCQs Page

Dive deep into the fascinating world of Sorting and Searching with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Sorting and Searching, a crucial aspect of Data Structures and Algorithms. In this section, you will encounter a diverse range of MCQs that cover various aspects of Sorting and Searching, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within Data Structures and Algorithms.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Sorting and Searching. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of Data Structures and Algorithms.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Sorting and Searching. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Sorting and Searching MCQs | Page 16 of 24

Q151.
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

Discuss
Answer: (c).3
Q152.
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?
Discuss
Answer: (a).90 and 99
Q153.
What is the worst case complexity of binary search using recursion?
Discuss
Answer: (b).O(logn)
Q154.
What is the average case time complexity of binary search using recursion?
Discuss
Answer: (b).O(logn)
Discuss
Answer: (d).All of the mentioned
Q156.
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;
 while(low <= high)
 {
  mid = low + (high + low)/2;
  if(arr[mid] == key)
  {
   return mid;
  }
  else if(arr[mid] < key)
  {
   low = mid - 1;
  }
  else
  {
   high = mid + 1;
  }
 }
 return -1;
}

b)

public static int iterative(int arr[], int key)
{
 int low = 0;
 int mid = 0;
 int high = arr.length-1;
 while(low <= high)
 {
  mid = low + (high - low)/2;
  if(arr[mid] == key)
  {
   return mid;
  }
  else if(arr[mid] < key)
  {
   low = mid + 1;
  }
  else
  {
   high = mid - 1;
  }
 }
 return -1;
}

c)

public static int iterative(int arr[], int key)
{
 int low = 0;
 int mid = 0;
 int high = arr.length-1;
 while(low <= high)
 {
  mid = low + (high + low)/2;
  if(arr[mid] == key)
  {
   return mid;
  }
  else if(arr[mid] < key)
  {
   low = mid + 1;
  }
  else
  {
   high = mid - 1;
  }
 }
 return -1;
}

d) None of the mentioned

a.

a

b.

b

c.

c

d.

d

Discuss
Answer: (b).b
Q157.
Binary Search can be categorized into which of the following?
Discuss
Answer: (b).Divide and conquer
Q158.
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

Discuss
Answer: (d).2
Q159.
Given an array arr = {45,77,89,90,94,99,100} and key = 100; What are the mid values(corresponding array elements) generated in the first and second iterations?
Discuss
Answer: (a).90 and 99
Q160.
What is the time complexity of binary search with iteration?
Discuss
Answer: (b).O(logn)

Suggested Topics

Are you eager to expand your knowledge beyond Data Structures and Algorithms? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!