AKTU Data Structures BCS 301 Fixed
AKTU Data Structures BCS 301 Fixed
- **Efficiency**: Measured by the time complexity (execution time) and space complexity (memory usage) of an
algorithm.
- Data can be organized linearly (arrays, linked lists) or non-linearly (trees, graphs).
**Example Question:** Define and explain time and space complexity with examples.
**Answer:** Time complexity measures the time an algorithm takes as a function of input size. Space complexity
measures the memory usage. For instance, binary search is O(log n) in time and O(1) in space.
**1. Stacks**
- **Definition**: A linear data structure following LIFO (Last In, First Out).
- **Operations**:
**Answer:**
```c
stack[++(*top)] = value;
return stack[(*top)--];
AKTU Data Structures (BCS 301) - Comprehensive Guide
```
**2. Queues**
- **Definition**: Linear data structure following FIFO (First In, First Out).
- **Types**:
- Circular Queue.
- Priority Queue.
**Example Question:** Write algorithms for enqueue and dequeue operations in a queue.
**Answer:**
1. Choose a pivot.
- Definitions:
- **Binary Tree**: A tree where each node has at most two children.
**Answer:**
```c
if (root) {
inorderTraversal(root->left);
inorderTraversal(root->right);
}
AKTU Data Structures (BCS 301) - Comprehensive Guide
```
**1. Representations**
**Answer:**
---