dsa_study_guide
dsa_study_guide
1. Stacks
Concepts:
- Definition: A linear data structure where operations follow the LIFO (Last-In, First-Out) principle.
- Operations:
- Push: Add an element to the top of the stack. Time Complexity: O(1)
- Pop: Remove the top element from the stack. Time Complexity: O(1)
- Top/Peek: View the top element without removing it. Time Complexity: O(1)
Types of Implementations:
- Array-Based Stack:
- Simple and efficient but has a fixed size, which may lead to overflow.
- Dynamic size with no overflow (unless memory is exhausted). Nodes have data and pointers.
Complex Points:
- Overflow and Underflow: Overflow occurs when pushing to a full array-based stack; underflow occurs when
- Recursion Support: Stacks manage return addresses and local variables, essential for recursion.
- Memory Efficiency: Linked list stacks use extra memory for pointers.
Applications:
- Expression Evaluation (Postfix): Operands are pushed onto the stack; operators apply to the top elements.
- Function Call Management: Helps manage function calls and returns, especially for recursion.
2. Queues
Detailed Overview of Stacks, Queues, and Linked Lists
Concepts:
- Operations:
- isFull: Check if the queue is full (relevant for fixed-size arrays). Time Complexity: O(1)
Types of Implementations:
- Array-Based Queue: Efficient but space can be wasted when front and back reach the end of the array.
Complex Points:
- Circular Array Management: Handling pointers as they wrap around the array.
- Full vs. Empty State: Avoiding ambiguity when front equals back.
Applications:
3. Linked Lists
Concepts:
- Definition: A collection of nodes, each with data and a pointer to the next node.
- Operations:
Types:
- Singly Linked List: Nodes point to the next, with the last pointing to NULL.
- Doubly Linked List: Nodes have pointers to both next and previous, allowing bidirectional traversal
- Circular Linked List: Last node points to the first, forming a loop.
- Circular Doubly Linked List: Combines circular and doubly linked properties.
Complex Points:
- Pointer Manipulation: Ensuring correct updates during insertion/deletion to avoid breaking the list.
Applications: