DSA- Advanced Quiz

Q1.A stack is a linear data structure in which data is stored and retrieved in a :

(A).Last out first in
(B).Last in first out
(C).First in first out
(D).Last out lost in

Q2.Which of the following creates a worst-case scenario for linear search?

(A).The element to be searched is at the first position
(B).The element to be searched is at the middle position in the list
(C).The element to be searched is either at the last position in the list or not in the list
(D).The element to be searched is at the second position in the list

Q3.If the Binary search algorithm determines that the search argument is in the lower half of the array, which of the following statements will set the appropriate variable to the appropriate value.

(A).start sub = middle sub-1
(B).start sub = middle sub+1
(C).stop sub= middle sub-1
(D).Stop sub = middle sub+1

Q4.Operation can be perform on data structure

(A).insertion
(B).updation
(C).deletion
(D).All of the above

Q5.Which of the following is not a non-linear data structure ?

(A).trees
(B).graphs
(C).stack
(D).None of these

2 Likes

ques1 ans- b-last in first out
ques2 ans-c-The element to be searched is either at the last position in the list or not in the list
ques3 ans-b-start sub = middle sub+1
ques4-ans-d-all of the above
ques5-ans-c-stack

4 Likes

Correct Answers

ques1 ans- b-last in first out
ques2 ans-c-The element to be searched is either at the last position in the list or not in the list
ques3 ans-c-stop sub = middle sub-1
ques4-ans-d-all of the above
ques5-ans-c-stack

2 Likes

Answer #3 will be: start sub = middle sub+1.
Explanation: In a binary search algorithm, if the search argument is in the lower half of the array, we need to update the start sub variable to middle sub+1.
This is because the search argument cannot be in the lower half of the array, so we can eliminate it from our search. By updating the start sub variable to middle sub+1, we narrow down our search to the upper half of the array.