Python Programming (2180711) MCQs

MCQs of Simple Algorithms and Data structures

Showing 1 to 10 out of 29 Questions
1.
The Average case occurs in the linear search algorithm ……….
(a) when the item is somewhere in the middle of the array
(b) when the item is not the array at all
(c) when the item is the last element in the array
(d) Item is the last element in the array or item is not there at all
Answer:

Option (a)

2.
Where is linear searching used?
(a) When the list has only a few elements
(b) When performing a single search in an unordered list
(c) Used all the time
(d) When the list has only a few elements and When performing a single search in an unordered list
Answer:

Option (d)

3.
What is the best case for linear search?
(a) O(nlogn)
(b) O(logn)
(c) O(n)
(d) O(1)
Answer:

Option (d)

4.
What is the worst case for linear search?
(a) O(nlogn)
(b) O(logn)
(c) O(n)
(d) O(1)
Answer:

Option (c)

5.
Which of the following is a disadvantage of linear search?
(a) Requires more space
(b) Greater time complexities compared to other searching algorithms
(c) Not easy to understand
(d) Not easy to implement
Answer:

Option (b)

6.
Which of the following is not a limitation of binary search algorithm?
(a) must use a sorted array
(b) requirement of sorted array is expensive when a lot of insertion and deletions are needed
(c) there must be a mechanism to access middle element directly
(d) binary search algorithm is not efficient when the data elements more than 1500.
Answer:

Option (d)

7.
Binary search algorithm cannot be applied to …
(a) sorted linked list
(b) sorted binary trees
(c) sorted linear array
(d) pointer array
Answer:

Option (d)

8.
For a binary search algorithm to work, it is necessary that the array (list) must be
(a) sorted
(b) unsorted
(c) in a heap
(d) popped out of stack
Answer:

Option (a)

9.
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
Answer:

Option (a)

10.
Which of the following is not an application of binary search?
(a) To find the lower/upper bound in an ordered sequence
(b) Union of intervals
(c) Debugging
(d) To search in unordered list
Answer:

Option (d)

Showing 1 to 10 out of 29 Questions