Register for our webinar

How to Nail your next Technical Interview

1 hour
Loading...
1
Enter details
2
Select webinar slot
*Invalid Name
*Invalid Name
By sharing your contact details, you agree to our privacy policy.
Step 1
Step 2
Congratulations!
You have registered for our webinar
check-mark
Oops! Something went wrong while submitting the form.
1
Enter details
2
Select webinar slot
*All webinar slots are in the Asia/Kolkata timezone
Step 1
Step 2
check-mark
Confirmed
You are scheduled with Interview Kickstart.
Redirecting...
Oops! Something went wrong while submitting the form.
close-icon
Iks white logo

You may be missing out on a 66.5% salary hike*

Nick Camilleri

Head of Career Skills Development & Coaching
*Based on past data of successful IK students
Iks white logo
Help us know you better!

How many years of coding experience do you have?

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Iks white logo

FREE course on 'Sorting Algorithms' by Omkar Deshpande (Stanford PhD, Head of Curriculum, IK)

Thank you! Please check your inbox for the course details.
Oops! Something went wrong while submitting the form.

Help us with your details

Oops! Something went wrong while submitting the form.
close-icon
Our June 2021 cohorts are filling up quickly. Join our free webinar to Uplevel your career
close
blog-hero-image

55+ Data Structure Interview Questions

by Interview Kickstart Team in Interview Questions
May 30, 2024

55+ Data Structure Interview Questions

Last updated by Abhinav Rawat on May 30, 2024 at 05:46 PM | Reading time: 10 minutes

You can download a PDF version of  
Data Structure Interview Questions
Download PDF

Data Structures are an important topic to prepare for interviews at FAANG and other Tier-1 tech companies. Interviewers check your problem-solving skills in various data structures like arrays, trees, graphs, etc.

In this article, we look at some interview questions in data structures.

To help with your interview prep, check out our technical interview checklist, interview questions page, and salary negotiation e-book to get interview-ready! Also, read the Best Way to Learn Data Structures and Algorithms to understand how to prepare for data-structure-related questions.

Having trained over 6,000 software engineers, we know what it takes to crack the toughest tech interviews. Since 2014, Interview Kickstart alums have been landing lucrative offers from FAANG and Tier-1 tech companies, with an average salary hike of 49%. The highest ever offer received by an IK alum is a whopping $933,000!

At IK, you get the unique opportunity to learn from expert instructors who are hiring managers and tech leads at Google, Facebook, Apple, and other top Silicon Valley tech companies.

Want to nail your next tech interview? Sign up for our FREE Webinar.

Here’s what we’ll cover in this article:

  • Types of Data Structures
  • Array Interview Questions
  • Linked Lists Interview Questions
  • Stacks Interview Questions
  • Queues Interview Questions
  • Hash Tables Interview Questions
  • Trees Interview Questions
  • Heaps Interview Questions
  • Graphs Interview Questions
  • Data Structures Interview Questions FAQs
  • How to Nail Your Next Data Structures Interview

Types of Data Structures

There are 8 commonly-used data structures that every programmer must know:

  1. Arrays
  2. Linked Lists
  3. Stacks
  4. Queues
  5. Hash Tables
  6. Trees
  7. Heaps
  8. Graphs

Array Interview Questions

What is an Array?

An array is a fixed-size structure that can hold items of the same data type. An array can be:

  1. An array of integers
  2. An array of strings
  3. An array of arrays

Arrays are indexed, and random access is possible.

Interview Questions on Arrays

  1. Find common elements in three-sorted arrays.
  2. Find whether a given array contains a subarray with sum equal to zero.
  3. Find the number of ways you can make change for n cents for a given value ‘n’ if we have an infinite supply of each of S = {s1, s2, … sm} valued coins.
  4. Find the majority element in a given array of ‘n’ elements. A majority element in an array of size ‘n’ is an element that appears more than n/2 times in the array.
  5. Given two arrays ‘a1[]’ and ‘a2[]’, find if a2[] is a subset of Trees[].
  6. Given the daily cost of a stock in an array ‘a[]’ of size ‘n,’ find the days on which you should buy and sell the stock such that your profit is maximized between these days.
  7. Given an array of size ‘n,’ find the smallest positive integer that cannot be represented as a sum of some elements from the array.
  8. In a sorted array ‘a[]’ of size ‘n’ and number ‘x,’ find a pair whose sum is closest to x.
  9. In an unsorted array ‘a’ of size ‘n’ of positive integers, one number a1 from set {1, 2, ...n} is missing, and one number a2 occurs twice in the array. Find these two numbers.
  10. Write a program to cyclically rotate an array by one.

Linked Lists Interview Questions

What is a Linked List?

A linked list is a sequential data structure made up of elements linked to each other in linear order. Here, you get sequential access to data. Random access is not possible.

Interview Questions on Linked Lists

  1. How are linked lists more efficient than arrays?
  2. What is a Doubly Linked List (DLL)? What are its applications?
  3. Write a program to check if a singly linked list is a palindrome.
  4. How do you find the middle element of a singly linked list in one pass?
  5. Write a function to delete a linked list.
  6. Write a program to delete the middle element of a linked list.
  7. Write a function to remove the duplicate elements from a sorted linked list.
  8. Write a function to reverse the nodes of a linked list.
  9. Write a program to find the ‘nth’ node from the end of a linked list.
  10. Write a program to check if a given linked list contains a cycle. If so, find the starting node of the cycle.

Stacks Interview Questions

What is a Stack?

A stack is a Last In First Out (LIFO) data structure, in which the last element is accessed first.

Interview Questions on Stacks

  1. Compare array-based implementation and linked list stack implementation.
  2. How would you efficiently implement ‘k’ stacks in a single array?
  3. How would you implement a stack using priority queue or heap?
  4. Write a program to convert a queue to a stack.
  5. Write a program to reverse a string using stack.
  6. Write a program to sort a stack using recursion.
  7. Write a program to sort a stack using another stack.
  8. Write a program to check if an array is stack sortable.
  9. Write a program to delete the middle element of a stack.
  10. Write a program to reverse a stack without using recursion and extra space.

Queues Interview Questions

What is a Queue?

A queue is a First In First Out (FIFO) data structure in which the first element is accessed first.

Interview Questions on Queues

  1. What are the benefits of circular queues?
  2. What is complexity analysis of queue operations?
  3. Write a program to convert a queue to a stack.
  4. Write a program to implement a priority queue.
  5. Write a program to sort a queue without extra space.
  6. Write a program to implement a queue using only one stack.
  7. Write a program to implement deque using doubly-linked lists.
  8. Write a program to reverse only the first ‘k’ elements of a queue.
  9. Write a program to efficiently implement ‘k’ queues in a single array.

Hash Tables Interview Questions

What is a Hash Table?

A hash table is a data structure that stores values that have keys associated with each of them.

Interview Questions on Hash Tables

  1. Differentiate between ‘hashing’ and ‘hash tables.’
  2. Explain how hash tables are implemented.
  3. What is the complexity of a hash table?
  4. Write a program to find if a list is cyclic using a hash table.

Trees Interview Questions

What is a Tree?

A tree is a structure in which data is linked and organized hierarchically. This differs from a linked list in which items are linked in a linear fashion.

Interview Questions on Trees

  1. Write a program to find if two binary trees are identical.
  2. Write a program to delete a node from a binary search tree.
  3. Write a program to convert a binary tree into a binary search tree.
  4. Write a program to find a lowest common ancestor (LCA) of a binary tree.
  5. Write a program to check if a given binary tree is a subtree of another binary tree.

Heaps Interview Questions

What is a Heap?

A heap is a type of binary tree in which the values of the parent nodes are compared to that of their children and are arranged accordingly.

Interview Questions on Heaps

  1. Explain a treap data structure.
  2. Write a program to check if a binary tree is a min-heap.
  3. Write a program for min heap and max heap implementation.
  4. Write a program to convert max heap to min heap in linear time.
  5. Given an array and a positive integer ‘k,’ find the ‘kth’ smallest element in the array.

Graphs Interview Questions

What is a Graph?

A graph is a data structure consisting of a finite set of vertices or nodes and a set of edges connecting these vertices.

Interview Questions on Graphs

  1. Given ‘A’ and ‘B,’ find all the stepping numbers in the range A to B. A number is called a stepping number if the adjacent digits have a difference of 1.
  2. Write a program to clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.
  3. You’re given a directed graph having ‘A’ nodes, a matrix ‘B’ of size ‘M * 2’, which represents the ‘M’ edges such that there is an edge directed from node B[i][0] to node B[i][1]. Find whether the graph contains a cycle or not. Return 1 if a cycle is present, else return 0.
  4. You’re given an undirected graph having ‘A’ nodes labeled from 1 to A, with ‘M’ edges given in the form of matric B of size M * 2, where (B[i][0], B[i][1]) represents two nodes connected by an edge. Find whether the graph contains a cycle or not. Return 1 if a cycle is present, else return 0.
  5. You’re given a graph of ‘A’ nodes, weighted edges in the form of array ‘B,’ starting point ‘C,’ a destination ‘D,’ and some extra edges in the form of vector ‘E.’ Find the length of the shortest path from C to D if you can use a maximum of one road from the given roads in E. All roads are one way, i.e., they go from B[i][0] to B[i][1].

Data Structures Interview Questions FAQs

  • Do all tech coding interviews feature data structure questions?
    No, it depends on the company and the role you’re being interviewed for.
  • How do you prepare for an interview on data structures?
    Practice is the key to cracking data structure interviews. The more you practice, the better you’ll get at solving unseen problems. For more practice problems with solutions, visit the Problems and Learn page.

How to Nail Data Structure Interview Questions

If you’re looking for guidance on how to prepare for a tech interview, join Interview Kickstart. Our Tech Interview Masterclass is the Best Data Structures and Algorithms Course to Crack FAANG Interviews, covering everything you need to learn to excel at your next tech interview.

As pioneers in the field of technical interview preparation, we have helped thousands of software engineers land their dream jobs at Google, Facebook, Apple, Netflix, Amazon, and more!

Sign up for our FREE webinar to learn more!


Author
Abhinav Rawat
Product Manager @ Interview Kickstart | Ex-upGrad | BITS Pilani. Working with hiring managers from top companies like Meta, Apple, Google, Amazon etc to build structured interview process BootCamps across domains
The fast well prepared banner

Data Structures are an important topic to prepare for interviews at FAANG and other Tier-1 tech companies. Interviewers check your problem-solving skills in various data structures like arrays, trees, graphs, etc.

In this article, we look at some interview questions in data structures.

To help with your interview prep, check out our technical interview checklist, interview questions page, and salary negotiation e-book to get interview-ready! Also, read the Best Way to Learn Data Structures and Algorithms to understand how to prepare for data-structure-related questions.

Having trained over 6,000 software engineers, we know what it takes to crack the toughest tech interviews. Since 2014, Interview Kickstart alums have been landing lucrative offers from FAANG and Tier-1 tech companies, with an average salary hike of 49%. The highest ever offer received by an IK alum is a whopping $933,000!

At IK, you get the unique opportunity to learn from expert instructors who are hiring managers and tech leads at Google, Facebook, Apple, and other top Silicon Valley tech companies.

Want to nail your next tech interview? Sign up for our FREE Webinar.

Here’s what we’ll cover in this article:

  • Types of Data Structures
  • Array Interview Questions
  • Linked Lists Interview Questions
  • Stacks Interview Questions
  • Queues Interview Questions
  • Hash Tables Interview Questions
  • Trees Interview Questions
  • Heaps Interview Questions
  • Graphs Interview Questions
  • Data Structures Interview Questions FAQs
  • How to Nail Your Next Data Structures Interview

Types of Data Structures

There are 8 commonly-used data structures that every programmer must know:

  1. Arrays
  2. Linked Lists
  3. Stacks
  4. Queues
  5. Hash Tables
  6. Trees
  7. Heaps
  8. Graphs

Array Interview Questions

What is an Array?

An array is a fixed-size structure that can hold items of the same data type. An array can be:

  1. An array of integers
  2. An array of strings
  3. An array of arrays

Arrays are indexed, and random access is possible.

Interview Questions on Arrays

  1. Find common elements in three-sorted arrays.
  2. Find whether a given array contains a subarray with sum equal to zero.
  3. Find the number of ways you can make change for n cents for a given value ‘n’ if we have an infinite supply of each of S = {s1, s2, … sm} valued coins.
  4. Find the majority element in a given array of ‘n’ elements. A majority element in an array of size ‘n’ is an element that appears more than n/2 times in the array.
  5. Given two arrays ‘a1[]’ and ‘a2[]’, find if a2[] is a subset of Trees[].
  6. Given the daily cost of a stock in an array ‘a[]’ of size ‘n,’ find the days on which you should buy and sell the stock such that your profit is maximized between these days.
  7. Given an array of size ‘n,’ find the smallest positive integer that cannot be represented as a sum of some elements from the array.
  8. In a sorted array ‘a[]’ of size ‘n’ and number ‘x,’ find a pair whose sum is closest to x.
  9. In an unsorted array ‘a’ of size ‘n’ of positive integers, one number a1 from set {1, 2, ...n} is missing, and one number a2 occurs twice in the array. Find these two numbers.
  10. Write a program to cyclically rotate an array by one.

Linked Lists Interview Questions

What is a Linked List?

A linked list is a sequential data structure made up of elements linked to each other in linear order. Here, you get sequential access to data. Random access is not possible.

Interview Questions on Linked Lists

  1. How are linked lists more efficient than arrays?
  2. What is a Doubly Linked List (DLL)? What are its applications?
  3. Write a program to check if a singly linked list is a palindrome.
  4. How do you find the middle element of a singly linked list in one pass?
  5. Write a function to delete a linked list.
  6. Write a program to delete the middle element of a linked list.
  7. Write a function to remove the duplicate elements from a sorted linked list.
  8. Write a function to reverse the nodes of a linked list.
  9. Write a program to find the ‘nth’ node from the end of a linked list.
  10. Write a program to check if a given linked list contains a cycle. If so, find the starting node of the cycle.

Stacks Interview Questions

What is a Stack?

A stack is a Last In First Out (LIFO) data structure, in which the last element is accessed first.

Interview Questions on Stacks

  1. Compare array-based implementation and linked list stack implementation.
  2. How would you efficiently implement ‘k’ stacks in a single array?
  3. How would you implement a stack using priority queue or heap?
  4. Write a program to convert a queue to a stack.
  5. Write a program to reverse a string using stack.
  6. Write a program to sort a stack using recursion.
  7. Write a program to sort a stack using another stack.
  8. Write a program to check if an array is stack sortable.
  9. Write a program to delete the middle element of a stack.
  10. Write a program to reverse a stack without using recursion and extra space.

Queues Interview Questions

What is a Queue?

A queue is a First In First Out (FIFO) data structure in which the first element is accessed first.

Interview Questions on Queues

  1. What are the benefits of circular queues?
  2. What is complexity analysis of queue operations?
  3. Write a program to convert a queue to a stack.
  4. Write a program to implement a priority queue.
  5. Write a program to sort a queue without extra space.
  6. Write a program to implement a queue using only one stack.
  7. Write a program to implement deque using doubly-linked lists.
  8. Write a program to reverse only the first ‘k’ elements of a queue.
  9. Write a program to efficiently implement ‘k’ queues in a single array.

Hash Tables Interview Questions

What is a Hash Table?

A hash table is a data structure that stores values that have keys associated with each of them.

Interview Questions on Hash Tables

  1. Differentiate between ‘hashing’ and ‘hash tables.’
  2. Explain how hash tables are implemented.
  3. What is the complexity of a hash table?
  4. Write a program to find if a list is cyclic using a hash table.

Trees Interview Questions

What is a Tree?

A tree is a structure in which data is linked and organized hierarchically. This differs from a linked list in which items are linked in a linear fashion.

Interview Questions on Trees

  1. Write a program to find if two binary trees are identical.
  2. Write a program to delete a node from a binary search tree.
  3. Write a program to convert a binary tree into a binary search tree.
  4. Write a program to find a lowest common ancestor (LCA) of a binary tree.
  5. Write a program to check if a given binary tree is a subtree of another binary tree.

Heaps Interview Questions

What is a Heap?

A heap is a type of binary tree in which the values of the parent nodes are compared to that of their children and are arranged accordingly.

Interview Questions on Heaps

  1. Explain a treap data structure.
  2. Write a program to check if a binary tree is a min-heap.
  3. Write a program for min heap and max heap implementation.
  4. Write a program to convert max heap to min heap in linear time.
  5. Given an array and a positive integer ‘k,’ find the ‘kth’ smallest element in the array.

Graphs Interview Questions

What is a Graph?

A graph is a data structure consisting of a finite set of vertices or nodes and a set of edges connecting these vertices.

Interview Questions on Graphs

  1. Given ‘A’ and ‘B,’ find all the stepping numbers in the range A to B. A number is called a stepping number if the adjacent digits have a difference of 1.
  2. Write a program to clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.
  3. You’re given a directed graph having ‘A’ nodes, a matrix ‘B’ of size ‘M * 2’, which represents the ‘M’ edges such that there is an edge directed from node B[i][0] to node B[i][1]. Find whether the graph contains a cycle or not. Return 1 if a cycle is present, else return 0.
  4. You’re given an undirected graph having ‘A’ nodes labeled from 1 to A, with ‘M’ edges given in the form of matric B of size M * 2, where (B[i][0], B[i][1]) represents two nodes connected by an edge. Find whether the graph contains a cycle or not. Return 1 if a cycle is present, else return 0.
  5. You’re given a graph of ‘A’ nodes, weighted edges in the form of array ‘B,’ starting point ‘C,’ a destination ‘D,’ and some extra edges in the form of vector ‘E.’ Find the length of the shortest path from C to D if you can use a maximum of one road from the given roads in E. All roads are one way, i.e., they go from B[i][0] to B[i][1].

Data Structures Interview Questions FAQs

  • Do all tech coding interviews feature data structure questions?
    No, it depends on the company and the role you’re being interviewed for.
  • How do you prepare for an interview on data structures?
    Practice is the key to cracking data structure interviews. The more you practice, the better you’ll get at solving unseen problems. For more practice problems with solutions, visit the Problems and Learn page.

How to Nail Data Structure Interview Questions

If you’re looking for guidance on how to prepare for a tech interview, join Interview Kickstart. Our Tech Interview Masterclass is the Best Data Structures and Algorithms Course to Crack FAANG Interviews, covering everything you need to learn to excel at your next tech interview.

As pioneers in the field of technical interview preparation, we have helped thousands of software engineers land their dream jobs at Google, Facebook, Apple, Netflix, Amazon, and more!

Sign up for our FREE webinar to learn more!


Recession-proof your Career

Recession-proof your Software Engineering Career

Attend our free webinar to amp up your career and get the salary you deserve.

Ryan-image
Hosted By
Ryan Valles
Founder, Interview Kickstart
blue tick
Accelerate your Interview prep with Tier-1 tech instructors
blue tick
360° courses that have helped 14,000+ tech professionals
blue tick
57% average salary hike received by alums in 2022
blue tick
100% money-back guarantee*
Register for Webinar

Recession-proof your Career

Recession-proof your Software Engineering Career

Attend our free webinar to amp up your career and get the salary you deserve.

Ryan-image
Hosted By
Ryan Valles
Founder, Interview Kickstart
blue tick
Accelerate your Interview prep with Tier-1 tech instructors
blue tick
360° courses that have helped 14,000+ tech professionals
blue tick
57% average salary hike received by alums in 2022
blue tick
100% money-back guarantee*
Register for Webinar

Attend our Free Webinar on How to Nail Your Next Technical Interview

Register for our webinar

How to Nail your next Technical Interview

1
Enter details
2
Select webinar slot
By sharing your contact details, you agree to our privacy policy.
Step 1
Step 2
Congratulations!
You have registered for our webinar
check-mark
Oops! Something went wrong while submitting the form.
1
Enter details
2
Select webinar slot
Step 1
Step 2
check-mark
Confirmed
You are scheduled with Interview Kickstart.
Redirecting...
Oops! Something went wrong while submitting the form.
All Blog Posts
entroll-image
closeAbout usWhy usInstructorsReviewsCostFAQContactBlogRegister for Webinar