Dynamic Storage Management & Data Structures: Q5. Solve Any TWO of The Following Questions (2x6 12)
Dynamic Storage Management & Data Structures: Q5. Solve Any TWO of The Following Questions (2x6 12)
a) Stack Operations
Given an initial stack: A, D, E, F, G (Top), and N = 6 (max size), the operations are performed as
follows:
struct Node {
int data;
};
struct Queue {
};
temp->data = value;
temp->next = NULL;
if (q->rear == NULL) {
return;
q->rear->next = temp;
q->rear = temp;
1. Push(10)
2. Push(5)
3. Push(6)
6. Push(8)
Final Result: 5
Characteristics:
1. Correctness
2. Efficiency
3. Finiteness
4. Definiteness
5. Generality
Analysis:
Binary Tree:
/\
B C
/\
D F
Storage:
- One-Dimensional Array: A, B, C, D, F
- Linked List: Each node has data, left child, right child pointers.
Queue is an ADT because it defines enqueue(), dequeue() operations without specifying storage
d) Graph Terminology
4. Cycle: A closed path where first and last vertex are same.