Basics of Data-WPS Office
Basics of Data-WPS Office
5. **Common operations:**
1. **What is a stack?**
3. **Implementation:**
4. **Applications:**
1. **What is a queue?**
2. **Queue operations:**
3. **Types:**
4. **Applications:**
2. **Types:**
## Module V: Tree
1. **What is a tree?**
3. **Traversals:**
1. **Stack applications:**
3. **Tree applications:**
The images you've provided already contain detailed answers to all the viva questions about data
structures. Here's a summary of the solution approach:
1. **For definition questions:** Provide concise textbook definitions (as shown in the images)
2. **For comparison questions:** Highlight key differences (e.g., stack vs queue: LIFO vs FIFO)
3. **For implementation questions:** Describe the approach (e.g., array with top pointer for stack)
4. **For application questions:** Give practical examples (e.g., stack for undo operations)
5. **For operation questions:** List steps clearly (e.g., how to insert in BST: compare and recurse)
The answers in your images are comprehensive and suitable for viva preparation. Focus on
understanding these concepts rather than just memorizing them, as viva exams often involve follow-up
questions based on your initial answers.
Here are detailed solutions to the data structure viva questions from your uploaded images, organized
by module:
---
- *Solution:* A data structure is a specialized format for organizing, storing, and manipulating data to
enable efficient access and modification (e.g., arrays, linked lists).
- *Solution:* ADT defines a logical model for data and operations (e.g., `Stack` with `push/pop`)
without specifying implementation details.
- *Solution:*
- *Solution:*
---
1. **Stack operations**
- *Solution:*
3. **Stack overflow/underflow**
- *Solution:*
4. **Postfix evaluation**
- *Solution:*
```python
stack = []
if token.isdigit(): stack.append(int(token))
else:
b, a = stack.pop(), stack.pop()
```
---
1. **Queue operations**
- *Solution:*
2. **Circular queue**
- *Solution:* Reuses empty spaces by wrapping around (avoids wasted space in linear queues).
3. **Priority Queue**
---
- *Solution:*
- *Solution:*
```python
while current:
next_node = current.next
current.next = prev
head = prev
```
---
1. **BST Insertion**
- *Solution:*
```python
return root
```
2. **Tree Traversals**
- *Solution:*
---
- *Solution:*
2. **Huffman Coding**
- *Solution:* Tree built from character frequencies; frequent chars get shorter codes.
- *Solution:*
---
4. **Comparisons:** Highlight trade-offs (e.g., "Arrays allow random access; linked lists allow dynamic
resizing").
The answers in your images are already comprehensive—practice explaining them concisely!