1. What is a Data Structure?
A Data Structure is a way to store and organize data so that it can be accessed and modified efficiently.

A focused DSA question bank for building strong fundamentals and preparing for technical interviews. Review concise answers, compare core concepts, and sharpen your problem-solving vocabulary.
50 essential questions covering data structures, algorithms, trees, graphs, searching, sorting, and hashing.
A Data Structure is a way to store and organize data so that it can be accessed and modified efficiently.
An Algorithm is a step-by-step procedure or formula for solving a problem.
A Stack is a linear data structure which follows LIFO (Last In First Out) principle.
A Queue is a linear data structure which follows FIFO (First In First Out) principle.
A Linked List is a linear data structure where elements are stored in nodes connected via pointers.
An Array is a collection of elements stored at contiguous memory locations.
A Binary Tree is a tree data structure in which each node has at most two children.
A BST is a binary tree where the left child contains values less than the parent node and the right child contains values greater than the parent node.
A Graph is a non-linear data structure consisting of nodes (vertices) connected by edges.
DFS is a graph traversal algorithm that explores as far as possible along each branch before backtracking.
BFS is a graph traversal algorithm that explores all neighbors of a node before moving to the next level.
A Heap is a special tree-based data structure that satisfies the heap property: max-heap or min-heap.
A Priority Queue is an abstract data type where each element has a priority and elements with higher priority are served first.
A Hash Table is a data structure that maps keys to values using a hash function for fast access.
A Circular Queue is a linear data structure in which the last position is connected back to the first position to make a circle.
Recursion is a technique where a function calls itself to solve smaller instances of a problem.
Linear data structures store elements sequentially (e.g., array, stack, queue). Non-linear structures do not follow a sequence (e.g., tree, graph).
A Doubly Linked List is a linked list where each node points to both its previous and next node.
A Singly Linked List is a linked list where each node points only to the next node.
A Dynamic Array is an array that can grow or shrink in size during program execution.
Stack Overflow occurs when there is no more space in the stack for new elements, often due to infinite recursion.
A Deque (Double Ended Queue) allows insertion and deletion at both ends.
Linear Search is a search algorithm that checks each element of a list sequentially until the desired element is found.
Binary Search is a search algorithm that works on sorted arrays by repeatedly dividing the search interval in half.
Merge Sort is a divide-and-conquer sorting algorithm that divides the array into halves, sorts them, and merges them back.
Quick Sort is a divide-and-conquer sorting algorithm that selects a pivot and partitions the array around the pivot.
Bubble Sort is a simple sorting algorithm that repeatedly swaps adjacent elements if they are in the wrong order.
Selection Sort repeatedly selects the minimum element from the unsorted part and moves it to the sorted part.
Insertion Sort builds the final sorted array one element at a time by inserting elements at the correct position.
Tree Traversal is the process of visiting all the nodes in a tree in a specific order (e.g., inorder, preorder, postorder).
Graph Traversal is visiting all nodes in a graph systematically using algorithms like BFS or DFS.
An Adjacency Matrix is a 2D array used to represent a graph where rows and columns represent nodes.
An Adjacency List represents a graph as an array of lists where each list contains neighbors of a node.
A Sparse Graph has relatively few edges compared to the maximum possible edges.
A Dense Graph has many edges, close to the maximum possible edges.
A Directed Graph has edges with direction, indicating the connection from one node to another.
An Undirected Graph has edges without direction, meaning connections are bidirectional.
A Cycle is a path in a graph that starts and ends at the same vertex.
A Connected Graph is a graph where there is a path between every pair of vertices.
A Disconnected Graph has at least two vertices that are not connected by a path.
A Weighted Graph is a graph where each edge has a numerical weight or cost.
An Unweighted Graph is a graph where all edges are considered equal (no weights).
An MST of a graph is a subset of edges that connects all vertices with minimum total edge weight.
Dijkstra’s Algorithm finds the shortest path from a source vertex to all other vertices in a weighted graph.
Bellman-Ford Algorithm finds the shortest paths from a single source vertex to all other vertices, even with negative weights.
Topological Sort is a linear ordering of vertices in a directed acyclic graph (DAG) such that for every edge u → v, u comes before v.
A Hash Function maps input data to a fixed-size value, often used in hash tables.
A Collision occurs when two different keys produce the same hash value.
Chaining is a technique to handle collisions by storing multiple elements in a linked list at the same hash index.
Open Addressing resolves collisions by finding another empty slot in the hash table using probing techniques.
30 interview questions with concise answers from the supplied DSA content.
Stack follows LIFO (Last In First Out) whereas Queue follows FIFO (First In First Out).
Arrays use contiguous memory and allow fast index access. Linked Lists use pointers, allow dynamic memory allocation, but slower access.
A BST is a binary tree where the left child is less than the parent and the right child is greater. It allows efficient searching, insertion, and deletion.
BFS explores neighbors level by level using a queue; DFS explores as deep as possible using a stack or recursion.
A Heap is a special tree-based structure that satisfies the heap property: max-heap (parent ≥ children) or min-heap (parent ≤ children).
A Hash Table maps keys to values using a hash function for fast insertion, deletion, and lookup.
Linear search checks elements sequentially (O(n)). Binary search works on sorted arrays, dividing the search space (O(log n)).
Recursion is a function calling itself to solve smaller instances of a problem. It is used in tree traversal, divide & conquer algorithms, and backtracking.
Singly Linked List nodes point only to the next node. Doubly Linked List nodes point to both previous and next nodes.
A Circular Queue connects the last element back to the first, allowing efficient use of memory for insertion and deletion.
A Graph is a collection of vertices connected by edges, which can be directed or undirected, weighted or unweighted.
A Tree is an acyclic connected graph with hierarchical structure. A Graph can have cycles and arbitrary connections.
Topological sorting is a linear ordering of vertices in a DAG such that for every directed edge u→v, u comes before v.
MST is a subset of edges in a weighted graph connecting all vertices with the minimum total weight.
Dijkstra’s algorithm finds the shortest path from a source vertex to all other vertices in a weighted graph with non-negative weights.
DFS is a traversal strategy. Backtracking uses DFS along with undoing choices to solve problems like puzzles, N-Queens, and combinatorial search.
A Priority Queue is a queue where elements with higher priority are dequeued before elements with lower priority.
Merge Sort divides and merges arrays, stable and O(n log n). Quick Sort uses a pivot to partition arrays, generally faster but unstable.
A Cycle is a path that starts and ends at the same vertex in a graph.
Sparse Graph has few edges relative to vertices; Dense Graph has edges close to the maximum possible.
An Adjacency Matrix is a 2D array representation of a graph, where cell (i,j) indicates the edge between vertices i and j.
An Adjacency List represents a graph as an array of lists, where each list contains neighbors of a vertex.
A Hash Collision occurs when two different keys hash to the same index in a hash table.
Chaining handles collisions by storing multiple elements at the same hash index using a linked list.
Open Addressing resolves collisions by finding the next available slot in the hash table using probing.
A Balanced Tree maintains minimal height to optimize search, insertion, and deletion operations.
BFS is a graph traversal algorithm. Level Order Traversal is BFS applied specifically to a tree structure.
Recursion internally uses a call stack to track function calls. Stack is an explicit data structure for LIFO operations.
DP is an optimization technique to solve problems by storing results of overlapping subproblems to avoid recomputation.
A Greedy Algorithm makes the locally optimal choice at each step, hoping to find the global optimum.