Data Structures
Viva/Short Questions
1. What is a Data structure?
Data Structure is a way of organizing and storing data for efficient access and modification.
2. What are the Types of data structures?
Primitive (int, float, char, double, etc.)
Non-Primitive (Arrays, Linked Lists, Stacks, Queues, Trees, Graphs)
3.What is mean by Array?
Collection of elements with similar elements is called as Array.
4.What is mean by Linked List?
Linked list is a linear data structure where elements are stored in nodes connected by pointers.
Types: 1. SLL 2. DLL 3. CLL
5. What is the difference between SLL, DLL, and CLL?
SLL → One pointer, forward direction only
DLL → Two pointers, forward & backward traversal
CLL → Tail points to head (circular), can be SLL or DLL
6. What is mean by Stack & its operations?
Stack is a linear data structure which follows LIFO (Last In First Out).
Operations: Push, Pop, Display
Top == -1 → Stack is Empty
Top == size - 1 → Stack is Full
7.What are the applications of Stack?
Expression Evaluation, Expression Conversion, Recursion,
Parentheses Matching, Backtracking Algorithms.
8. Define Queue.
Queue is a linear data structure which follows FIFO (First In First Out).
9.Queue operations?
enqueue(), dequeue(), front(), rear(), isEmpty(), isFull()
10. Define Circular Queue.
The last position is connected to the first position to form a circle and reuse space.
11. What are the Applications of Queue?
Scheduling, CPU task handling, Network buffering, Printer queue.
12.What are the Singly Linked List operations?
Insertion, Deletion, Searching, Traversal.
13. What is a Dictionary ADT?
Dictionary Stores data in key-value pairs with insert, delete and search.
14. Define Skip List.
A skip list is a data structure that allows for efficient search, insertion and deletion of elements in a sorted list.
15. Define Hashing.
Hashing is a technique used in data structures that efficiently stores and retrieves data in a way that allows for quick access.
16.What is a Hash Table?
Hash Table Stores keys in an array based on hash index.
17.What is Collision?
When two or more keys have the same hash value, a collision happens. To handle this collision, we use Collision Resolution Techniques.
18. What are Collision resolution techniques?
1. Separate Chaining (Open Hashing)
2. Open Addressing (Closed Hashing)
• Linear Probing
• Quadratic Probing
• Double Hashing
19. What is Separate Chaining?
Linked list is used at each index to store multiple keys.
20. What is Linear Probing?
When two values go to the same place in a hash table (collision happens),
linear probing will look at the next position in the table.
If that place is full → check the next one
→ then next → until we find an empty slot to store the value.
It moves in a straight line (one-by-one).
21.What is Quadratic Probing?
Quadratic probing is a collision handling method in hashing.
If the hash index is already full, instead of going one-by-one like linear probing,
it jumps using a square pattern.
formula : New Index=(h(key)+i2)mod table size
22. What is Double Hashing?
Uses a secondary hash function to find next index.
23. What is a Binary Search Tree (BST)?
Left Root Right
24. What are the Operations on BST?
Search, Insert, Delete, Traversal
25. Define AVL Tree.
Self-balancing BST where height difference (Balance Factor) is -1 to +1.
27.What are Rotations in AVL?
LL, RR, LR, RL rotations
28.Define B-Tree.
Balanced M-way search tree used in databases and disk storage.
29. Define B+ Tree.
All data stored in leaf nodes, linked sequentially for fast range queries.
30.Define Red-Black Tree.
Self-balancing BST with nodes coloured red or black.
1️⃣ Every node is either Red or Black.
2️⃣ Root is always Black.
3️⃣ Red nodes cannot have Red children.
→ No two Reds together in a row.
4️⃣ Every path from a node to leaf NULL must have the same number of Black nodes.
→ Equal Black count on all paths.
5️⃣ All NULL (leaf) nodes are Black.
31.Define Splay Tree.
Recently accessed node is brought to root → improves locality.
• Zig Rotation
• Zag Rotation
• Zig - Zig Rotation
• Zag - Zag Rotation
• Zig - Zag Rotation
• Zag - Zig Rotation
32. What is a Graph?
A set of vertices and edges connecting pairs of vertices.
33.Graph traversal techniques?
BFS → Queue
DFS → Stack / Recursion
Информация по комментариям в разработке