Mukund DS Short Answers
Mukund DS Short Answers
A node is a basic unit of a data structure like a linked list. It typically contains two parts:
A linked list is a linear data structure where each node is linked to the next one using pointers. Unlike arrays,
linked lists don't store elements in contiguous memory. They are dynamic, meaning they can grow/shrink
during runtime.
A singly linked list is a type of linked list where each node points to the next node only.
Structure:
struct Node {
int data;
};
Operations:
A stack is a linear data structure that follows LIFO (Last In, First Out).
Operations:
Array implementation:
stack[++top] = val;
void pop() {
top--;
A hash table is a data structure that stores key-value pairs using a hash function to compute an index into an
array.
Advantages:
A queue is a linear data structure that follows FIFO (First In, First Out).
Operations:
Array implementation:
queue[++rear] = val;
void dequeue() {
front++;
A doubly linked list allows traversal in both directions. Each node has:
- Data
Structure:
struct Node {
int data;
struct Node* prev;
};
Operations:
- Insert at front/back/middle
A hash function converts keys into array indices. A good hash function:
- Minimizes collisions
Common types:
- Multiplication method
- Folding method
- Undo/Redo operations
Operations in hashing:
- Insert(key)
- Search(key)
- Delete(key)
Applications:
- Database indexing
- Data
- Left child
- Right child
BST Node in C:
struct Node {
int data;
Operations:
- Insert
- Search
- Delete
- In-order/Pre-order/Post-order traversal