0% found this document useful (0 votes)
63 views3 pages

MCQ-01 Linear Search

The document consists of a series of questions and answers related to data structures and algorithms, covering topics such as linear search, binary search, graphs, trees, and sorting algorithms. It includes questions about time complexities, data structure properties, and specific algorithm implementations. The format is primarily multiple-choice, with correct answers provided for each question.

Uploaded by

JINESH VARIA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views3 pages

MCQ-01 Linear Search

The document consists of a series of questions and answers related to data structures and algorithms, covering topics such as linear search, binary search, graphs, trees, and sorting algorithms. It includes questions about time complexities, data structure properties, and specific algorithm implementations. The format is primarily multiple-choice, with correct answers provided for each question.

Uploaded by

JINESH VARIA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

1. 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.
2. What is the best case for linear search?
a) O(nlogn) b) O(logn) c) O(n) d) O(1)
3. What is the worst case for linear search?
a) O(nlogn) b) O(logn) c) O(n) d) O(1)
4. What is the best case and worst case complexity of ordered linear search?
a) O(nlogn), O(logn) b) O(logn), O(nlogn) c) O(n), O(1) d) O(1), O(n)
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
6. Is there any difference in the speed of execution between linear search(recursive) vs linear search(iterative)?
a) Both execute at same speed b) Linear search(recursive) is faster
c) Linear search(Iterative) is faster d) Can’t be said
7. Is the space consumed by the linear search(recursive) and linear search(iterative) same?
a) No, recursive algorithm consumes more space b) No, recursive algorithm consumes less space
c) Yes d) Nothing can be said
8. What is the worst case runtime of linear search(recursive) algorithm?
a) O(n) b) O(logn) c) O(n2) d) O(nx)
9. Linear search(recursive) algorithm used in _____________
a) When the size of the dataset is low b) When the size of the dataset is large
c) When the dataset is unordered d) Never used
10. Is there any difference in the speed of execution between linear search(recursive) vs linear search(iterative)?
a) Both execute at same speed b) Linear search(recursive) is faster
c) Linear search(Iterative) is faster d) Can’t be said
11. Is the space consumed by the linear search(recursive) and linear search(iterative) same?
a) No, recursive algorithm consumes more space b) No, recursive algorithm consumes less space
c) Yes d) Nothing can be said
12. What is the worst case runtime of linear search(recursive) algorithm?
a) O(n) b) O(logn) c) O(n2) d) O(nx)
13. Linear search(recursive) algorithm used in _____________
a) When the size of the dataset is low b) When the size of the dataset is large
c) When the dataset is unordered d) Never used
14. The array is as follows: 1,2,3,6,8,10. At what time the element 6 is found? (By using linear search(recursive) algorithm)
a) 4th call b) 3rd call c) 6th call d) 5th call
15. The array is as follows: 1,2,3,6,8,10. Given that the number 17 is to be searched. At which call it tells that there’s no
such
element? (By using linear search(recursive) algorithm)
a) 7th call b) 9th call c) 17th call
d) The function calls itself infinite number of times
16. What is the best case runtime of linear search(recursive) algorithm on an ordered set of elements?
a) O(1) b) O(n) c) O(logn) d) O(nx)
17. The array is as follows: 1,2,3,6,8,10. At what time the element 6 is found? (By using linear search(recursive) algorithm)
a) 4th call b) 3rd call c) 6th call d) 5th call
18. The array is as follows: 1,2,3,6,8,10. Given that the number 17 is to be searched. At which call it tells that there’s no
such element? (By using linear search(recursive) algorithm)
a) 7th call b) 9th call c) 17th call
d) The function calls itself infinite number of times
19. What is the best case runtime of linear search(recursive) algorithm on an ordered set of elements?
a) O(1) b) O(n) c) O(logn) d) O(nx)
20. Can linear search recursive algorithm and binary search recursive algorithm be performed on an unordered list?
a) Binary search can’t be used b) Linear search can’t be used
c) Both cannot be used d) Both can be used
21. What is the recurrence relation for the linear search recursive algorithm?
a) T(n-2)+c b) 2T(n-1)+c c) T(n-1)+c d) T(n+1)+c
22. 1. Binary Search can be categorized into which of the following?
a) Greedy algorithm Brute Force technique wrong Divide and conquer correct Dynamic programming
Explanation: Since 'mid' is calculated for every iteration or recursion, we are diving the array into half and then try to
solve
the problem.
23. Merge sort can be implemented using O(1) auxiliary space.
a) True b) False
24. What is the average case time complexity of standard merge sort?
a) O(n2 log n) b) O(n log n2) c) O(n2) d) O(n log n)

8. What does the following piece of code do?


for (int i = 0; i < arr.length-1; i++)
{
for (int j = i+1; j < arr.length; j++)
{
if( (arr[i].equals(arr[j])) && (i != j) )
{
System.out.println(arr[i]);
}
}
}
a) Print the duplicate elements in the array b) Print the element with maximum frequency
c) Print the unique elements in the array d) Prints the element with minimum frequency

1. Minimum number of fields in each node of a doubly linked list is ____ (A) 2 (B) 3 (C) 4 (D) None of the above Ans: B 3
2. A graph in which all vertices have equal degree is known as ____
(A) Complete graph (B) Regular graph (C) Multi graph (D) Simple graph Ans: A Complete graph
3. A vertex of in-degree zero in a directed graph is called a/an
(A) Root vertex (B) Isolated vertex (C) Sink (D) Articulation point Ans: C Sink
4. A graph is a tree if and only if graph is
(A) Directed graph (B) Contains no cycles (C) Planar (D) Completely connected Ans: B Contains no cycles
5. The elements of a linked list are stored (A) In a structure (B) In an array (C) Anywhere the computer has space for them
(D) In contiguous memory locations Ans: C Anywhere the computer has space for them
6. A parentheses checker program would be best implemented using
(A) List (B) Queue (C) Stack (D) Any of the above Ans: C Stack
7. To perform level-order traversal on a binary tree, which of the following data structure will be required? (A) Hash table
(B) Queue (C) Binary search tree (D) Stack Ans: B Queue
8. Which of the following data structure is required to convert arithmetic expression in infix to its equivalent postfix
notation? (A) Queue (B) Linked list (C) Binary search tree (D) None of above Ans: D None of above
9. A binary tree in which all its levels except the last, have maximum numbers of nodes, and all the nodes in the last level
have only one child it will be its left child. Name the tree.
(A) Threaded tree (B) Complete binary tree (C) M-way search tree (D) Full binary tree Ans: B Complete binary tree
10. Which of following data structure is more appropriate for implementing quick sort iteratively?
(A) Dequeue (B) Queue (C) Stack (D) Priority queue Ans: C Stack
11. The number of edges in a complete graph of n vertices is (A) n(n+1)/2 (B) n(n-1)/2 (C) n2 /2 (D) n Ans: B n(n-1)/2
12. If two trees have same structure and but different node content, then they are called ___ (A) Synonyms trees (B) Joint
trees (C) Equivalent trees (D) Similar trees Ans: D Similar trees
13. If two trees have same structure and node content, then they are called ____ (A) Synonyms trees (B) Joint trees (C)
Equivalent trees (D) Similar trees Ans: C Equivalent trees
14. Finding the location of a given item in a collection of items is called …… A. Discovering B. Finding C. Searching D. Mining
Ans. C searching
15. The time complexity of quicksort is …….. A. O(n) B. O(logn) C. O(n2) D. O(n logn) Ans. D O(n logn)
16. Quick sort is also known as …….. A. merge sort B. tree sort C. shell sort D. partition and exchange sort Ans. D partition
and exchange sort
17. ………. sorting is good to use when alphabetizing a large list of names. A. Merge B. Heap C. Radix D. Bubble Ans. C Radix
18. The total number of comparisons in a bubble sort is …. A. O(n logn) B. O(2n) C. O(n2) D. O(n) Ans. A O(n logn)
19. ……… form of access is used to add and remove nodes from a queue. A. LIFO, Last In First Out B. FIFO, First In First Out
C. Both a and b D. None of these Ans. B FIFO, First In First Out
20. New nodes are added to the ……… of the queue. A. Front B. Back C. Middle D. Both A and B Ans. B Back
21. The term push and pop is related to A. Array B. Lists C. Stacks D. Trees Ans. C Stacks
22. Which of the following is an application of stack?
A. finding factorial B. tower of Hanoi C. infix to postfix D. all of the above Ans. D all of the above
23. The operation of processing each element in the list is known as …… A. sorting B. Merging C. Inserting D. Traversal Ans.
D traversal
24. The situation when in a linked list START=NULL is …. A. Underflow B. Overflow C. Houseful D. Saturated Ans. A
Underflow
25. Which of the following are two-way lists? A. Grounded header list B. Circular header list C. Linked list with header and
trailer nodes D. List traversed in two directions Ans. D List traversed in two directions
26. Which is the pointer associated with the availability list? A. FIRST B. AVAIL C. TOP D. REAR Ans. B AVAIL
27. Which of the following data structure can’t store the non-homogeneous data elements? A) Arrays B) Records C)
Pointers D) Stacks Ans. A Arrays
28. Which of the following is non-liner data structure? A) Stacks B) List C) Strings D) Trees Ans. D Trees
29. To represent hierarchical relationship between elements, which data structure is suitable? A) Dequeue B) Priority C)
Tree D) Graph Ans. C Tree
30. Identify the data structure which allows deletions at both ends of the list but insertion at only one end. A) Input
restricted dequeue B) Output restricted queue C) Priority queues D) Stack Ans. A Input restricted dequeue.

You might also like