# Data Structures interview questions and answers

What are the different types of traversals?

The different types of traversing are

- Pre-order traversal
- In-order traversal
- Post-order traversal

How pre-order traversal works?

- Process the root node
- Process the left subtree
- Process the right subtree

How post-order traversal works?

- Process the left subtree
- Process the right subtree
- Process the root node

How in -order traversal works?

- Process the left subtree
- Process the root node
- Process the right subtree

How does a function call work?

- Arguments are passed
- local variables are allocated and initialized
- transferring control to the function body
- functions body statements are executed

What is precision?

Precision refers to the accuracy of the decimal portion of a value. Precision is the number of digits allowed after the decimal point.

What does mean by sorting?

Ordering the data in an increasing or decreasing fashion according to some relationship among the data item is called sorting.

What is the difference between storage structure and file structure?

The expression of a specific data structure inside the memory of a computer system is termed storage structure in contrast to a storage structure expression in auxiliary memory is normally known as a file structure.

What is a divide and conquer method?

The basic idea is to divide the problem into several subproblems beyond which cannot be further subdivided. Then solve the subproblems efficiently and join them together to get the solution for the main problem.

What is mean by d-queue?

De-queue stands for a double-ended queue. It is an abstract data structure that implements a queue for which elements can be added to front or rear and the elements can be removed from the rear or front. It is also called head-tail linked list

## Data Structures interview questions and answers for freshers

What is an AVL Tree?

AVL trees are height balancing binary search tree. AVL tree checks the height of left and right subtrees and assures that the difference is not more than 1 and this difference is called the Balance Factor.

What is a spanning Tree?

A spanning tree is a tree associated with a network. All the nodes of the graph appear on the tree once. A minimum spanning tree is a spanning tree organized so that the total edge weight between nodes is minimized.

Two linked lists L1 and L2 intersect at a particular node N1 and from there all other nodes till the end are common. The length of the lists is not the same. What are the possibilities to find N1?

The linear solution is possible. Have two pointers say P1 pointing to the first node of L1 and P2 to that of L2. Traverse through both the lists. If P1 reaches L1’s last node, point it to the first node of L2 and continue traversing. Do the same thing for P2 when it reaches L2’s last node. (By this process we are balancing the difference in the length between the linked lists. The shorter one will get over soon and by redirecting to longer list’s head, it will traverse the extra nodes also.) Finally, they will Meet at the Intersection node.

What is the difference between NULL and void?

NULL is actually a value, whereas void is a data type identifier. A NULL variable simply indicates an empty value, whereas void is used to identify pointers as having no initial size.

What does mean by recursive function?

A recursive function is one which calls itself, directly or calls a function that in turn calls it. Every recursive function follows the recursive properties – base criteria where functions stop calling itself and progressive approach where the functions try to meet the base criteria in each iteration.

What is the Fibonacci series?

Fibonacci Series generates subsequent number by adding two previous numbers. For example – 0 1 1 2 3 5 8 13.

What is the tower of Hanoi?

Tower of Hanoi, is a mathematical puzzle which consists of three towers (pegs) and more than one rings. All rings are of different size and stacked upon each other where the large disk is always below the small disk. The aim is to move the tower of the disk from one peg to another, without breaking its properties.