In this article, we are going to see about the top most important questions and answers about the Data Structures and algorithms. so if you are preparing for the competitive exams, or for coding interviews for big companies like Google, Microsoft, Amazon, etc then you must prepare for the Data structures and algorithms questions. so here we are including some basic to advanced questions related to DSA so you can prepare for this topic.

#### Consider the following tree

If the post order traversal gives ab-cd*+ then the label of the nodes 1,2,3,... will be
1. +,-,*,a,b,c,d
2. a,-,b,+,*,d
3. a,b,c,d,d,-,*,+
4. -,a,b,+,*,c,d

#### Consider the following tree

If this tree is used for sorting, then a new number 8 should be placed as the
1. the left child of the node labeled 30
2. right child of the node labeled 5
3. right child of the node labeled 30
4. the left child of the node labeled 10
Answer - (4) the left child of the node labeled 10

#### The initial configuration of a queue is a,b,c,d,('a' is in the front end). To get the configuration d,c,b, a, one needs a minimum of

1. 2 deletions and 3 additions
2. 3 deletions and 2 additions
3. 3 deletions and 3 additions
4. 3 deletions and 4 additions

#### The order of a B-tree is defined as the

1. Minimum no. of keys in a non-root node
2. Maximum no. of keys in a non-root node
3. (n + 1) / 2
4. Maximum no. of pointers in any node
Answer - (4) Maximum no. of pointers in any node

#### If the sequence of operations - push(1), push(2), pop, push(1), push(20), pop, pop, pop, push(2), pop, are performad 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
Answer - (1) 2, 2, 1, 1, 2

#### The depth of a complete binary tree with 'n' nodes is (log is to the base two)

1. log(n + 1) - 1
2. log(n)
3. log(n - 1) + 1
4. log(n) + 1
Answer - (1) log(n + 1) - 1

#### Preorder is same as

1. depth-first order
3. topological order
4. linear order

#### Which of the following traversal techniques lists the nodes of a binary search tree in ascending order?

1. Post-order
2. In-order
3. Pre-order
4. None of the above

1. 3
2. 4
3. 5
4. 6

1. A1
2. A2
3. A4
4. A3

1. 12
2. 13
3. 5
4. 15

#### Sorting is useful for

1. report generation
2. minimizing the storage needs and responding to queries easily
3. making searching easier and more efficient
4. all of the above
Answer - (4) all of the above

#### The order of an algorithm that finds whether a given Boolean function of 'n' variables, produces a 1 is

1. constant
2. linear
3. logarithmic
4. exponential

In evaluating the arithmetic expression 2 * 3 - (4 + 5), using stacks to evaluate its equivalent postfix form, which of the following stack configuration is not possible?

#### The way a card game player arranges his cards as he picks them up one by one is an example of

1. bubble sort
2. selection sort
3. insertion sort
4. merge sort

#### You want to check whether a given set of items is sorted. Which of the following sorting methods will be the most efficient if it is already in sorted order?

1. Bubble sort
2. Selection sort
3. Insertion sort
4. Merge sort

#### Which of the following sorting methods will be the best if a number of swappings is done, is the only measure of efficiency?

1. bubble sort
2. selection sort
3. insertion sort
4. Quicksort

#### You are asked to sort 15 randomly generated numbers. You should prefer

1. bubble sort
2. selection sort
3. insertion sort
4. Quicksort

#### As part of maintenance work, you are entrusted with the work of rearranging the library books on a shelf in proper order, at the end of each day. The ideal choice will be

1. bubble sort
2. selection sort
3. insertion sort
4. heap sort