Data Structure Multiple Choice Questions And Answers - Set 2

Data Structure Multiple choice and objective type questions.

1) If the sequence of operations - push(1), push(2), pop, push(1), push(2), pop, pop, pop, push(2), pop are performed on a stack, the sequence of popped out values are ?
  1. 2, 2, 1, 1, 2
  2. 2, 2, 1, 2, 2
  3. 2, 1, 2, 2, 1
  4. 2, 1, 2, 2, 2
Show/Hide Answer
Answer = A
Explanation:
The elements are popped from the top of the stack.
2) Queue can be used to implement ?
  1. radix sort
  2. quick sort
  3. recursion
  4. depth first search
Show/Hide Answer
Answer = A 
Explanation:
A simple version of an LSD radix sort can be achieved using queues as buckets.
3) A machine took 200 sec to sort 200 names, using bubble sort. In 800 sec, it can approximately sort ?
  1. 400 names
  2. 800 names
  3. 750 names
  4. 800 names
Show/Hide Answer
Answer = A
Explanation:
For sorting 200 names bubble sort makes 200 x 199/2 = 19900 comparisons. The time needed for 1 comparison is 200 sec. In 800 sec it can make 80,000 comparisons. We have to fine n, such that n(n - 1)/2 = 80,000. From this n is approximately 400.
4) A machine needs a minimum of 100 sec to sort 1000 names by quick sort.The minimum time needed to sort 100 names will be approximately ?
  1. 50.2 sec
  2. 6.7 sec
  3. 72.7 sec
  4. 11.2 sec
Show/Hide Answer
Answer = B 
Explanation:
In the best case quick sort algorithm makes n log(n) comparisons. so 1000 x log (1000) = 9000 comparisons, which takes 100 sec. To sort 100 names a minimum of 100 log(100) = 600 comparisons are needed. This takes 100 x 600/9000 = 6.7 sec.
5) The number of binary trees with 3 nodes which when traversed in post order gives the sequence A,B,C is ?
  1. 3
  2. 9
  3. 7
  4. 5
Show/Hide Answer
Answer =  D
Explanation: Five trees are
6) The average search time of hashing with linear probing will be less if the load factor ?
  1. is far less than one
  2. equals one
  3. is far greater than one
  4. none of above
Show/Hide Answer
Answer = A
Explanation:
Load factor is the ratio number of records that are currently present and the total number of records that can be present. If the load factor is less, free space will be more. This means probability of collision is less. So the search time will be less.
7)  A binary tree that has n leaf nodes. The number of nodes of degree 2 in this tree is ?
  1. log2n
  2. n - 1
  3. n
  4. 2n
Show/Hide Answer
Answer = B
Explanation:
It can be proved by induction that a binary tree with n leaf nodes will have total of 2n - 1 nodes. So number of non-leaf nodes is (2n - 1)-n=n-1
8) The principal of locality justifies the use of ?
  1. Interrupts
  2. DMA
  3. Polling
  4. Cache memory
Show/Hide Answer
Answer = D
Explanation:
In principal of phenomenon the same value or same memory location is being used frequently.
9) Sparse matrices have ?
  1. many zero entries
  2. many non- zero entries
  3. higher dimension
  4. none of above
Show/Hide Answer
Answer = A Explanation: A sparse matrix is a matrix populated primarily with zeros
10) The postfix expression for * + a b - c d is?
  1. ab + cd - *
  2. ab cd + - *
  3. ab + cd * -
  4. ab + - cd *
Show/Hide Answer
Answer = A
Explanation:
No Explanation

Do You Like This? Please take 5 seconds to share with your firends.

0 comments:

Post a Comment