0% found this document useful (0 votes)
12 views

data structure63637

The document contains a series of multiple-choice questions related to data structures and algorithms, covering topics such as expression conversion, traversal methods, sorting algorithms, and tree properties. Each question presents four answer options, requiring knowledge of computer science concepts. The questions test understanding of theoretical and practical aspects of data structures like stacks, queues, and graphs.

Uploaded by

cirab29938
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

data structure63637

The document contains a series of multiple-choice questions related to data structures and algorithms, covering topics such as expression conversion, traversal methods, sorting algorithms, and tree properties. Each question presents four answer options, requiring knowledge of computer science concepts. The questions test understanding of theoretical and practical aspects of data structures like stacks, queues, and graphs.

Uploaded by

cirab29938
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

1. Convert the following infix expression into its equivalent postfix expression.

(A
+ B ⋀D)/(E – F)+G
a) (A B D ⋀ + E F – /G +) b) (A B D +⋀ E F – / G +) c) (A B D ⋀ + E F/- G +) d)
(A B D E F + ⋀ /G+)

2. The result of preorder traversal is same as:


a) Depth-first order b) Breadth-first search c) Topological order d) Linear order

3. Queues serve a major role in ______________ .


a) Simulation of recursion b) Simulation of arbitrary linked list c) Simulation of
limited resource allocation d) Simulation of heap sort

4. In the worst case, the number of comparisons needed to search a singly linked
list of length n for a given element is?
a) log 2n b) n⁄2 c) log 2n – 1 d) n

5. If several elements are competing for the same bucket in the hash table, what is
it called?
a) Diffusion b) Replication c) Collision d) Duplication

6 .What is the number of edges present in a complete graph having n vertices?


a) (n*(n+1))/2 b) (n*(n-1))/2 c) n d) Information given is insufficient

7. Which of the following is not an in-place sorting algorithm?


a) Selection sort b) Heap sort c) Quick sort d) Merge sort

8. The time complexity of heap sort in worst case is:


a) O(logn) b) O(n) c) O(nlogn) d) O(n2)

9. Suppose we are sorting an array of eight integers using quicksort, and we have
just finished the first partitioning with the array looking like this:
2 5 1 7 9 12 11 10 Which statement is correct?
a) The pivot could be either the 7 or the 9. b) The pivot could be the 7, but it is not
the 9 c) The pivot is not the 7, but it could be the 9 d) Neither the 7 nor the 9 is the
pivot
10. Consider a situation where swap operation is very costly. Which of the
following sorting algorithms should be preferred so that the number of swap
operations are minimized in general?
a) Heap Sort b) Selection Sort c) Insertion Sort d) Merge Sort

11. The Inorder and Preorder traversal of a binary tree is d b e a f c g and a b d e c f


g respectively. Which among the following is the correct Post Order Traversal
Sequence for this tree?
a) d e b f g c a b) e d b g f c a c) e d b f g c a d) d e f g b c a

12. Which of the following is not the application of stack?


a) A parenthesis balancing program b) Tracking of local variables at run time
c) Compiler Syntax Analyzer d) Data Transfer between two asynchronous
processes

13. In the worst case, the number of comparisons needed to search a singly linked
list of length n for a given element is?
a) log 2 n b) n⁄2 c) log 2 n – 1 d) n

14. To implement a stack using queue (with only enqueue and dequeue operations),
how many queues will you need?
a)​ 1 b) 2 c) 3 d) 4

15. The optimal data structure used to solve Tower of Hanoi is _________
a) Tree b) Heap c) Priority queue d) Stack
16. Assume that the operators +, -, X are left associative and ^ is right associative.
The order of precedence (from highest to lowest) is ^, X, +, -. The postfix
expression for the infix expression a + b X c – d ^ e ^ f is?
a) abc X+ def ^^ – b) abc X+ de^f^ – c) ab+c Xd – e ^f^ d) ) -+aXbc^ ^def

17. The time complexity of heap sort in worst case is


a) O(logn) b) O(n) c) O(nlogn) d) O(n2)
18. Suppose we are sorting an array of eight integers using heapsort, and we have
just finished some heapify (either maxheapify or minheapify) operations. The array
now looks like this: 16 14 15 10 12 27 28 How many heapify operations have been
performed on root of heap?
a)​ 1 b) 2 c) 3 or 4 d) 5 or 6

19. What is the number of edges present in a complete graph having n vertices?
a) (n*(n+1))/2 b) (n*(n-1))/2 c) n d) Information given is insufficient

20. If several elements are competing for the same bucket in the hash table, what is
it called?
a) Diffusion b) Replication c) Collision d) Duplication

21. The worst case complexity of quick sort is ..............


a) O(n) b) O (log c) O(n 2 d) O(n log n)

22. What is the output of following function for start pointing to first node of
following linked
list? 1 -->2 -->3 -->4 -->5 -->6
void fun(struct node* start)
{
if(start == NULL)
return;
printf("%d ", start -->
if(start -->next != NULL )
fun(start -->next -->next);
printf("%d ", start -->data);
}
a) 1 4 6 6 4 1 b) 1 3 5 1 3 5 c) 1 2 3 5 d) 1 3 5 5 3 1

23. The prefix form of A- B/ (C * D ^E) is?


a) -/*^ACBDE b) -ABCD*^ DE c) -A/B*C^ DE d) -A/BC*^ DE
24. Suppose we are sorting an array of eight integers using quicksort, and we have
just finished the first partitioning with the array looking like this: 2 5 1 7 9 12 11
10 Which statement is correct?
a) The pivot could be either the 7 or the 9. b) The pivot could be the 7, but it is not
the 9 c) The pivot is not the 7, but it could be the 9 d) Neither the 7 nor the 9 is the
pivot.

25. In a complete k ary tree, every internal node has exactly k children or no child.
The number of leaves in such a tree with n internal nodes is:
a) nk b) (n -1) k+ 1 c) n( k- 1) + 1 d) n(k -1)

26. If a node in a Binary search tree has two children, then its inorder predecessor
has .........
a) No child b) No left child c) No right child d) Two children

27. Using Bubble sort, the number of interchanges required to sort 5, 1, 6, 2 and 4
in ascending order is...........
a) 7 b) 5 c) 8 d) 6

28. Which one of the following is a sequence container?


a) stack b) dequeue c) queue d) set
29. Minimum number of queues needed to implement the priority queue is ...........
a) 1 b) 2 c) 3 d) 4

30. The data structure used in the breadth first search algorithm is ...........
a) queue b) stack c) heap d) hash table

You might also like