Data_Structures_QA
Data_Structures_QA
Unit 1
Q: Define Data Structure
A: A data structure is a specialized format for organizing, processing, and storing data efficiently to perform operations
like insertion, deletion, and traversal.
Q: Define Abstract Data Type (ADT)
A: An ADT is a logical description of a data type and its operations, independent of implementation. Example: List,
Stack, Queue.
Q: Define Time complexity and Space complexity
A: Time Complexity: The amount of time an algorithm takes based on input size.
Space Complexity: The amount of memory an algorithm uses based on input size.
Q: Differentiate Linear Search and Binary Search
A: Linear Search: Checks each element sequentially. No need for sorting. Time: O(n).
Binary Search: Requires sorted data. Uses divide-and-conquer. Time: O(log n).
Q: Best, Average, and Worst case of Binary Search
A: Best: O(1)
Average: O(log n)
Worst: O(log n)
Q: Use of Pivot in Quick Sort
A: The pivot divides the array into subarrays to recursively sort them.
Q: Worst and Best Case of Quick Sort
A: Best: O(n log n)
Worst: O(n^2)
Q: Algorithm technique used in Merge Sort
A: Divide and Conquer
Unit 2
Q: Define Linked List
A: A linear data structure where each node contains data and a pointer to the next node.
Q: Differentiate Arrays and Linked Lists
A: Arrays: Fixed size, random access.
Linked Lists: Dynamic size, sequential access.
Q: Application of Linked Lists
A: Used in dynamic memory allocation, implementing stacks/queues, and graphs.
Q: Inserting in a Single Linked List
A: Update links to insert at beginning, middle, or end.
Q: Double Linked List vs Circular Linked List
A: Doubly Linked: Two pointers (next, prev).
Circular Linked: Last node links to the first.
Q: Operations on Linked List
A: Insertion, Deletion, Traversal, Searching.
Q: Time Complexity of Insertion/Deletion in Single Linked List
A: O(1) at head, O(n) at tail/position.
Q: Time Complexity of Search in Doubly Linked List
A: O(n)
Unit 3
Q: Applications of Queue
Data Structures - Unit Wise Q&A
A: CPU scheduling, Printer management, BFS traversal.
Q: Types of Queues
A: Simple, Circular, Priority, Deque.
Q: Queue & Disadvantages of Linear Queue
A: Linear Queue uses FIFO but wastes space as front moves forward.
Q: Define Stack & Operations
A: Stack is LIFO. Operations: Push, Pop, Peek, isEmpty.
Q: Applications of Stack
A: Expression evaluation, Undo operations, Function call stack.
Q: Define Reverse Polish Notation (Postfix)
A: Notation where operator follows operands. Example: AB+.
Q: Queue in BFS Traversal
A: Queue stores current level nodes in BFS for FIFO processing.
Unit 4
Q: Binary Tree & Its Types
A: Binary tree: max two children per node. Types: Full, Complete, BST.
Q: LR and RL Rotation in AVL Tree
A: LR: Left-Right Rotation. RL: Right-Left Rotation.
Q: Binary Tree vs Binary Search Tree
A: Binary Tree: No order. BST: Left < Root < Right.
Q: Define Deque & Operations
A: Deque allows insert/delete at both ends. Operations: insertFront, insertRear, deleteFront, deleteRear.
Q: Height, Depth, Level of Binary Tree
A: Height: Max path to leaf. Depth: Path from root. Level: Depth+1.
Q: AVL Tree Balance Factor
A: Balance Factor = height(left) - height(right). Balanced if -1, 0, 1.
Q: Drawbacks of Binary Search Tree
A: Can become unbalanced and degrade to O(n).
Q: Spanning Trees in Complete Graph K3
A: 3 spanning trees.
Q: Maximum nodes in binary tree of height h
A: 2^(h+1) - 1
Unit 5
Q: Regular Graph
A: Each vertex has the same number of edges.
Q: Spanning Tree & Minimum Spanning Tree
A: Spanning Tree: Connects all nodes with no cycles. MST: Minimal total weight.
Q: Adjacency Matrix Representation
A: 2D matrix indicating presence and weights of edges.
Q: Weighted Graph & Directed Graph
A: Weighted: Edges have weights. Directed: Edges have direction.
Q: Shortest Path & Techniques
A: Shortest distance between nodes. Techniques: Dijkstra, Bellman-Ford, Floyd-Warshall.
Q: Graph Traversal Techniques
A: DFS and BFS.
Data Structures - Unit Wise Q&A
Q: Applications of Graphs
A: Networking, Navigation, Social networks.
Q: Operations on Graphs
A: Add/Delete vertex/edge, Traverse, Search.
Q: Define Hash Function
A: Maps data to fixed-size values (hash codes).
Q: Collision Resolution Techniques
A: Chaining, Linear probing, Quadratic probing, Double hashing.
Q: Applications of Hash Tables
A: Databases, Caching, Symbol tables.
Q: Why Quadratic Probing May Fail
A: May not find vacant cells due to clustering if table size isn't prime.