Data Structures Interview Questions

Data Structures Interview Questions: Data structures and algorithm questions are an important part of any programming job interview, be it a Java interview, C++ interview or any other programming language. Since data structures are core programming concept, it’s mandatory for all programmers, to know basic data structures like stack, linked list, queue, array, tree, and graph. Though tree and graph are on the tough side, I still see programmers get familiar will all these. Any list of programming job interview questions is incomplete without questions from data structures and algorithms. Similarly, while going on questions from data structure you may get some programming exercise as well e.g. swapping numbers without temp variable. The linked list and array are favorite topics in any data structure interview, questions like reversing linked list, traversing linked list or deleting nodes from linked list, which involves algorithm and data structures are quite common.

Similarly, finding duplicates in an array, finding missing numbers, sorting arrays are very popular. You can also expect data structures interview questions from the topics such as stack, queue, array, linked list, tree, graph and hash table etc.

Question-1. What is Data-Structure?

Answer- Data structure is a way of defining, storing & retriving of data in a structural & systemetic way. A data structure may contain different type of data items.

 

Question-2. What are various data-structures available?

Answer- Data structure availability may vary by programming languages. Commonly available data structures are list, arrays, stack, queues, graph, tree etc.

Question-3. What is an algorithm?

Answer- Algorithm is a step by step procedure, which defines a set of instructions to be executed in certain order to get the desired output.

Question-4. Why we need to do algorithm analysis?

Answer- A problem can be solved in more than one ways. So, many solution algorithms can be derived for a given problem. We analyze available algorithms to find and implement the best suitable algorithm.

Question-5. What are the criteria of algorithm analysis?

Answer- An algorithm are generally analyzed on two factors − time and space. That is, how much execution time and how much extra space required by the algorithm.

Question-6. is asymptotic analysis of an algorithm?

Answer- Asymptotic analysis of an algorithm, refers to defining the mathematical boundation/framing of its run-time performance. Using asymptotic analysis, we can very well conclude the best case, average case and worst case scenario of an algorithm.

Question-7. What are asymptotic notations?

Answer- Asymptotic analysis can provide three levels of mathematical binding of execution time of an algorithm −

                •	Best case is represented by Ω(n) notation.
                •	Worst case is represented by Ο(n) notation.
                •	Average case is represented by Θ(n) notation.

 

Question-8. What is linear data structure?

A linear data-structure has sequentially arranged data items. The next time can be located in the next memory address. It is stored and accessed in a sequential manner. Array and list are example of linear data structure.

Question-9. What are common operations that can be performed on a data-structure?

Answer- The following operations are commonly performed on any data-structure-

               •	Insertion − adding a data item
               •	Deletion − removing a data item
               •	Traversal − accessing and/or printing all data items
               •	Searching − finding a particular data item
               •	Sorting − arranging data items in a pre-defined sequence

 

Question-10. Briefly explain the approaches to develop algorithms.

Answer- There are three commonly used approaches to develop algorithms−

          •	Greedy Approach − finding solution by choosing next best option
          •	Divide and Conquer − dividing the problem to a minimum possible sub-problem and solving them independently
          •	Dynamic Programming − dividing the problem to a minimum possible sub-problem and solving them combined