1. Define a linked list.
List out various types of
linked list and also present their Key Differences:
representations.?
Stack
2. Define a Stack and show its representations? Stack
Using
3. How does a stack implemented using a linked list Feature Using
Linked
Array
differ from a stack implemented using array? List
4. Define a binary tree and write its properties? Dynamic
Fixed size
size
5. Define Searching. Which technique of an Size (predefine
(grows as
element in an array would you prefer to use and d)
needed)
in which situation? Contiguous Non-
Memory
6. Define the Graph and write the adjacency block (may contiguou
Allocatio
cause s memory
matrix? n
wastage) (flexible)
7. Define the AVL Tree and write its properties? Push Done at New node
Operatio the end of is added
Solution :- n the array at the top
Remove
Pop Remove
1. Linked List: A linked list is a linear data structure from the
Operatio from the
end of the
where elements (nodes) are stored in memory n top node
array
with each node pointing to the next. Types Only
include: occurs if
Singly Linked List: Each node points to the next Occurs the
Overflow when the system
node.
array is full runs out
Doubly Linked List: Each node points to both the of
next and the previous node. memory
Circular Linked List: The last node points back to
the first node.
Representation:
struct Node { 4. Binary Tree: A binary tree is a hierarchical data
structure where each node has at most two
int data;
children (left and right). Properties include:
struct Node* next; Each node has a maximum of two children.
}; Binary trees can be classified as full, complete, or
2. Stack: A stack is a linear data structure that balanced.
follows the LIFO (Last In, First Out) principle. 5. Searching: Searching refers to finding an
Operations include push, pop, and peek. element in a data structure. In arrays, Linear
Search is useful for unsorted data, and Binary
Search is preferred for sorted data due to its
Representation: O(log n) efficiency.
6. Graph: A graph is a collection of nodes
struct Stack { (vertices) connected by edges. An adjacency
int data[MAX]; // Array to store stack elements matrix represents a graph with a 2D array, where
int top; the element at row i and column j represents an
}; edge between vertices i and j.
Adjacency Matrix:
int adjMatrix[V][V];
3. Stack with Linked List vs. Array:
7. AVL Tree: An AVL tree is a self-balancing
binary search tree. Its properties:
Linked List: Dynamic size, no memory wastage. The balance factor (difference between heights of
left and right subtrees) of each node must be -1,
Array: Fixed size, limited memory, and resizing 0, or 1.
is costly. Rotations (left or right) are used to maintain
balance.
8. Queue: A queue is a linear data structure that
follows the FIFO (First In, First Out) principle.
Elements are added at the rear and removed
from the front.
Queue Operations:
Enqueue: Add element to the rear.
Dequeue: Remove element from the front.
Peek: View front element.
isEmpty: Check if the queue is empty.
isFull: Check if the queue is full (for fixed-size
queues).
Queue Representation:
Using Array:
struct Queue {
int arr[MAX];
int front, rear;
};
Using Linked List:
struct Node {
int data;
struct Node* next;
};
struct Queue {
struct Node *front, *rear;
};
Differences:
Array-based Queue: Fixed size, faster access.
Linked List-based Queue: Dynamic size, more
memory usage due to pointers.