(A) Strings
(B) Lists
(C) Stacks
(D) None of the above
Ans:-D
Explanation:- In Linear type data can be traversed sequentially. For example, arrays, linked list. In non linear type data is traversed in a non-sequential,hierarchal manner. Example are trees, Binary search trees etc. So option D will be the correct answer.
2. The total number of comparisons in a bubble sort is
(A) 0(log n)
(B) 0(n log n)
(C) 0(n)
(D) None of the above
Ans:-D
Explanation:-
The total number of comparisons in a bubble sort is
=(N-1)+(N-2)+…+2+1
=(N-1)*N/2=O(N2)
Since this value is not available in the list of options,we go with D.
3. Which of the following is a bad example of recursion ?
(A) Factorial
(B) Fibonacci numbers
(C) Tower of Hanai
(D) Tree traversal
Ans:-B
Why is Fibonacci a bad example? Because it stores a lot of intermediate results?
ReplyDelete