0% found this document useful (0 votes)
9 views3 pages

DSA1 Compact Questions Answers

The document provides an overview of key concepts in Data Structures and Algorithms, including comparisons between static and dynamic data structures, types of queues, and various sorting algorithms. It also covers essential operations for stacks, linked lists, and binary search trees, along with code snippets for implementation. Additionally, it highlights the importance of data structures in optimizing operations and data storage.

Uploaded by

sm9772206
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

DSA1 Compact Questions Answers

The document provides an overview of key concepts in Data Structures and Algorithms, including comparisons between static and dynamic data structures, types of queues, and various sorting algorithms. It also covers essential operations for stacks, linked lists, and binary search trees, along with code snippets for implementation. Additionally, it highlights the importance of data structures in optimizing operations and data storage.

Uploaded by

sm9772206
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

B.

Sc Computer Science - CS-231: Data Structures and Algorithms - I

Important Questions and Answers

1. Static vs Dynamic Data Structures:

| Static | Dynamic |

|--------|---------|

| Fixed size | Size varies |

| Example: Array | Example: Linked List |

2. Queue Types: Simple (FIFO), Circular, Priority, Deque.

3. Stack Program (Array):

```c

#define SIZE 5

int stack[SIZE], top = -1;

void push(int val) { ... }

void pop() { ... }

void display() { ... }

```

4. Infix, Prefix, Postfix:

Infix: A + B, Prefix: +AB, Postfix: AB+

5. Linked List vs Array:

| Array | Linked List |

|-------|-------------|

| Fixed size | Dynamic size |

| Random access | Sequential access |

| Costly insertion | Easy insertion |

6. BST: Left < Root, Right > Root, No duplicates.


7. Quick Sort: Divide-and-conquer, Pivot-based partitioning.

8. Insertion in Doubly Linked List:

1. Create newNode.

2. newNode.next = head, newNode.prev = NULL.

3. head = newNode.

9. Hashing: Data mapping, collision handling (Chaining, Open Addressing).

10. Linear Search: Sequential search, O(n) time.

11. Stack Examples: Undo feature, Plates, Browser history.

12. Circular Queue: Memory efficient, reuses space.

13. Recursive Fibonacci:

```c

int fibonacci(int n) { if(n==0) return 0; else if(n==1) return 1; return fibonacci(n-1)+fibonacci(n-2); }

```

14. BFS vs DFS: BFS (Level-wise), DFS (Depth-first), Queue vs Stack.

15. Bubble Sort: Adjacent swaps to sort array.

16. Data Structures Need: Optimize operations, data storage.

17. Types of Linked Lists: Singly, Doubly, Circular.

18. Overflow/Underflow: Overflow (insert in full), Underflow (delete from empty).

19. Tree Applications: Hierarchies, Databases, Compilers.

20. Recursion: Function calling itself.


21. Infix to Postfix: Stack-based, precedence rules.

22. Tree Traversals: Preorder (Root Left Right), Inorder (Left Root Right), Postorder (Left Right Root).

23. Binary Search: Efficient for sorted arrays, O(log n).

24. Sorting Algorithms: Bubble (O(n^2)), Quick (O(n log n)).

25. Linked List Apps: Music players, Browsers.

26. Hash Table with Chaining: Linked list at each index.

27. Queue using Linked List Code:

```c

struct Node { int data; struct Node *next; }

```

28. Memory Representation of Linked List: Data + Next pointer.

Fast Revision Table:

| Concept | Reminder |

|---------|----------|

| Stack | LIFO |

| Queue | FIFO |

| Tree | Hierarchy |

| Recursion | Self-Call |

| Hashing | Fast Access |

Good Luck!

Prepared by ChatGPT.

You might also like