data structures and algorithms interview questions
Data Structure Data Structure Questions gate practice set

Top 100 Data Structures and Algorithms Interview Questions [ 2021]

Data Structures and Algorithms Interview Questions

Data Structure is an important subject for GATE(CS) and UGC NET Exam. Top 100 Data structures and algorithms interview questions are also asked in Technical Interview of most of the software companies. In this post we are going to tell you about some ds algo interview questions and sorting algorithm interview questions are also discussed here in this post.

We have divided all these top 100 data structures and algorithms interview questions in three sections. Students looking for job in software companies are kindly requested to read this post completely and ask your query in comment section.

Short Type Data Structure Interview Questions

Short type data structures and algorithms interview questions are mostly asked in technical interview. 

Q1. Define Data Structures? What are different types of Data Structures?

Q2. Explain Dynamic memory allocation. Write a structure in c to create a node in linked list.

Q3. What is Recursion? Write a program to calculate factorial of a number.

Q4. Define algorithm? What are its characteristics?

Q5. What do you mean by sparse matrix? How we represent a sparse matrix in memory?

Q6. List Various linear and non linear data structures.

Q7. Describe Asymptotic Notations and their use.

Q8.Write overflow condition for a circular queue.

Q9. State the formula for calculating location of an element of 2-D Array.

Q10. State the merits and demerits of static and dynamic memory allocation techniques?

Q11.What do you mean by tail Recursion? Explain.

Q12. What is the difference between complete binary tree and almost complete binary tree?

Q13. Write the basic concept of KRUSKAL’s Algorithm.

Q14. Differentiate between linear search and binary search with example.

Q15. Define Recursion with example.

Q16. Discuss the concept of “Successor” and “Predecessor” in binary search tree.

Q17. Convert the following arithmetic infix expression into its equivalent postfix expression.                              A-B/C+D*E+F

Q18. Write the short note on circular linked list.

Q19. Calculate total number of moves for tower of Hanoi for n=10 disks.

Q20. Explain 2-tree with example.

Q21. Explain DFS or BFS with example, adjancy list execution.

Q22. Write programs for implementing stacks and queues.

data structures and algorithms interview questions

Application Based DS Interview Questions

In the first section of this post we have discussed some short types data structures and algorithms interview questions, generally asked in technical interview or in viva voce. In this section we are going to discuss some application based ds interview questions.

Q1.A 2-D array defined as A[4….7, -1….3] requires 2 bytes of storage for each element. calculate the address of element at Location A[6,2]. If the array is stored –

(a) In row major order.

(b) In-coloumn major order.

Given the base address is 100.

Q2. Explain Dynamic memory allocation. Write a structure in C to create a node in linked list.

Q3.What is sparse matrix? Give some examples that how we represent it in memory?

Q4.What is recursion? WAP to calculate factorial of a number.

Q5.What are Collection Frameworks ?

Q6.Define algorithm. What do you mean by analysis of algorithm?

Q7.Differentiate static memory allocation with dynamic memory. allocation. Write a structure in c to create a node in linked list.

Q8.Convert the given infix expression into equivalent postfix form using STACK.

                                In-fix : A+(B*C-(D/E^F)*G)*H

Q10.Define the term data structure. List various types of data structure.

Q11.What do you mean by time – space trade off? What are different asymptotic notations?

Q12.Write a c program to delete an element from STACK (array implementation )

Q13.Discuss the requirements of various types of data structures?

Q14.Discuss Tail Recursion with suitable example.

Q15.Why AVL Tree is required? Explain balancing factor?

Q16. How complete binary tree is different from strict binary tree.

Q17. Insert the following members in an empty BST

40, 25,      70,      22,      35,      60,      80,      90,      10,       30

Draw the BST T and delete node 40.

Q18.What are the applications of Stack and Queue?

Q19.What is circular queue? How it is different from ordinary queue.

Q20.Create an AVL Search tree from the given set of values:-

                           H, I, J, B, A, E, C, F, D

Q21.Write short notes on:-

(a) Threaded Binary Tree

(b) Double Ended Queue.

(c) Height Balanced Tree

(d) Priority Queue.

Q22. A binary tree T has 9 nodes. The inorder and preorder traversals yield the following sequence of nodes:-

Inorder : E         A         C         K         F          H         D         B         G

Preorder: F          A         E         K         C         D         H         G         B

Draw the tree with illustration of algorithm.

Q23. Write Huffman Algorithm. Construct an extended binary tree using Huffman Algorithm.  Construct an extended binary tree using Huffman algorithm with given data:-

Symbols: A         E         I          O         U

Frequency: 19        11         9          7          7

Q24. What is tower of Hanoi problem? Solve tower of Hanoi problem when the disks are three.

Q25.Translate the infix string to reverse polish notation using stack.

Q26.Write a function in C which searches string X for the first occurrence of string Y. If Y does not appear in X, then function returns zero, otherwise function returns starting position in X of the first occurrence of Y.

Q27.Write an algorithm to convert infix expression into a postfix expression. Illustrate the same with the given infix expression.

                                            ((a+b)/d-((e-f)+g))

Q28.How a polynomial equation can be represented through a linked list. Explain the function to add two polynomials using linked list.

Q29.Construct a binary tree from given traversals.

Q30.Define Spanning tree. Write the PRIM’s Algorithm and find the minimum cost spanning tree for the following graph.

Q31.Write an algorithm to insert and delete a node from doubly linked list.

Q32.Implement typical stack operations when stacks are represented using single linked list.

Q34.State the Towers of Hanoi problem. Write a recursive algorithm for solving this problem there are three disks, also show the state space tree.

35.Show that the maximum number of nodes in a binary tree of height ‘h’ is

                                                (2h+1-1).

(ii) How an extended binary tree is constructed using Huffman’s algorithm? Construct a tree with codes for the following data frequency.

(35)         Data (36)         A (37)         B (38)         C (39)         D (40)        E
(41)          Frequency (42)        24 (43)         12 (44)        10 (45)         8 (46)        8

Q36. What do you mean by height balanced search tree? Construct an AVL search tree from following keys.

                       8, 6, 4, 7, 10, 9, 11, 3, 5, 2, 12

Q36.State single source shortest path problem. Write and explain Dijikstra’s algorithm on the following graph with source ‘a’.

Q37.Write short notes on the following:

        Depth First search

       Floyd-warshall algorithm

strongly connected component

List and Matrix Representation of graph

Q38.What do you mean by sorting? Sort the following elements using quick sort.

               52, 38, 81, 22, 48, 13, 69, 93, 14, 45, 58, 79, 72

Q39.Write short notes on:

B-Trees

Hash function and collision resolution techniques

Garbage collection

Q40.If the in-order traversal of a Binary tree B, I, D, A, C, Q ,E, H, F and its post-order traversal is I, D, B, Q, C, H, F, E, A. Determine the Binary tree.

Q41.Define spanning tree. Also construct minimum spanning tree using prim’s Algorithm for the given graph.

Q42.Write programs for implementing stacks and queues as array.

Q43.What do you understand by time space trade off? Explain best, worst and average case analysis in this respect with an example.

Q44.Illustrate the quick sort algorithm on list 9, 20, 12, 21, 3, 5, 1, 22, 19, 7.

Q45.What are the various asymptotic notations? Explain Big Oh notation.

Q46.Discuss the different cases of rotations in A.V.L. trees.

Q47.Construct a B-Tree of order 3 using following 10, 20, 30, 40, 50, 60, 70, 80, 90.

Q48.Explain Dijkstra’s Algorithm and illustrate it on a suitable graph.

Q49.Show that maximum number of nodes in a binary tree of height h is 2h+1-1

Q50.Draw a Binary tree with five nodes and three leaf.

Q51.Discuss about Kruskal’s Algorithm with examples.

Q52.What is threaded Binary tree? Explain the advantages of using a threaded binary tree

Q53.States the Merit and Demerit of static and dynamic memory Allocation technique.

Note – To understand the concepts of array read this tutorial. Concepts of Array 

DS Algo Interview Questions

In previous sections we have discussed ds interview questions and data structure interview questions. In this section we will discuss ds algo interview questions which are generally asked in technical interview. Various data structures and algorithms interview questions 2021 are discussed here in this post.

These ds algo interview questions and data structures and algorithms interview questions are also important for GATE exam.

Q1. Illustrate the quick sort Algorithm an list 9, 20, 12, 21, 3, 5, 1, 22, 19, 7.

Q2. Use prim’s Algorithm to determine the minimum spanning tree of the graph given below:

Q3. Explain Dijkstra’s Algorithm and illustrate it on a suitable graph.

    • Show that the maximum number of nodes in a Binary Tree of height h is 2h+1-1.
    • Draw a Binary Tree with five nodes and three leaf

Q4.Write an Algorithm to convert a valid Arithmetic infix expression into its equivalent postfix expressions. Trace your Algorithm for   A-B/C+D*E+F

Q5. Write Huffman Algorithm. Construct an extended binary tree using Huffman Algorithm.  Construct an extended binary tree using Huffman algorithm with given data:-

    1. Symbols: A         E         I          O         U
    2. Frequency: 19        11         9          7          7

Q6.State single source shortest path problem. Write and explain Dijikstra’s algorithm on the following graph with source ‘a’.

Data Structure Program Based Questions

In previous two sections we have discussed data structures and algorithms interview questions. Data structure program based questions are discussed here in this section.

Q1. Write a program to delete duplicate elements from an array of 20 integers.

Q2. Write a program, which deletes all the blank spaces except a single space between two words.

Q3. Write a c program to add a node in end of a single linked list

Q4. Write programs for implementing stacks and queues.

Q5. Write a program which deletes all blank spaces except a single space between two words. Show using Dry run.

Q6. Write a c program to add a node in end of a single Linked List.

Q7. Write a program to delete duplicate elements from an array of 10 integers.

Q8.Consider an array int arr [4] [5] declared in a ‘c’ program. If base address is 1020, find the address of element arr [3] [4] with raw major and column major representation of array.

Q9. Write a C program to show the operation on the Stack using array.

Q10. Write a program in C which reverses the order of elements in a given string and check whether the string is palindrome or not.

Q11. Write a c program to multiply two integer numbers using recursion.

Q12. Write a short note on the Garbage Collection and Compaction.

Important Note –  To know the answer of Theory Questions students are advised to study these Data Structure Notes for GATE Exam

Conclusion and Summary

Data Structure is an important subject to be asked in technical interview. I hope data structures and algorithms interview questions discussed here in this post will be beneficial for you.

Your feedback is precious to us. Please give your feedback or leave a comment to improve the quality of our tutorials and provide tutorials as per your expectation.

If you find this page helpful, then please Like and Share the post on Facebook, Twitter, LinkedIn through their icons as given below.

Do not stop learning and practice.

Leave a Reply

Your email address will not be published. Required fields are marked *