DSA Practice Questions
1. Longest Substring Without Repeating Characters (LeetCode)
2. 3Sum (LeetCode)
3. Add Two Numbers (LeetCode)
4. Merge Intervals (LeetCode)
5. Find the Duplicate Number (LeetCode)
6. Rotate Image (LeetCode)
7. Next Greater Element (LeetCode)
8. Longest Palindromic Substring (LeetCode)
9. Kth Largest Element in an Array (LeetCode)
10. Spirally Traversing a Matrix (GeeksforGeeks)
11. **Best Time to Buy and Sell Stock**
- **Platform**: LeetCode
- **Problem**: [Best Time to Buy and Sell Stock](https://leetcode.com/problems/best-time-tobuy-and-sell-stock/)
- **Topic**: Arrays, Greedy
12. **Find Peak Element**
- **Platform**: LeetCode
- **Problem**: [Find Peak Element](https://leetcode.com/problems/find-peak-element/)
- **Topic**: Arrays, Binary Search
13. **Intersection of Two Arrays**
- **Platform**: LeetCode
- **Problem**: [Intersection of Two Arrays](https://leetcode.com/problems/intersection-of-twoarrays/)
- **Topic**: Arrays, Hashing
14. **Remove Duplicates from Sorted Array**
- **Platform**: LeetCode
- **Problem**: [Remove Duplicates from Sorted Array](https://leetcode.com/problems/removeduplicates-from-sorted-array/)
- **Topic**: Arrays, Two Pointers
15. **Check if a String is Palindrome**
- **Platform**: GeeksforGeeks
- **Problem**: [Check if a string is palindrome](https://www.geeksforgeeks.org/c-program-checkgiven-string-palindrome/)
- **Topic**: Strings
16. **Climbing Stairs**
- **Platform**: LeetCode
- **Problem**: [Climbing Stairs](https://leetcode.com/problems/climbing-stairs/)
- **Topic**: Dynamic Programming
17. **Remove Nth Node From End of List**
- **Platform**: LeetCode
- **Problem**: [Remove Nth Node From End of List](https://leetcode.com/problems/remove-nthnode-from-end-of-list/)
- **Topic**: Linked List, Two Pointers
18. **Merge Two Sorted Linked Lists**
- **Platform**: LeetCode
- **Problem**: [Merge Two Sorted Lists](https://leetcode.com/problems/merge-two-sortedlists/)
- **Topic**: Linked List
19. **Single Number**
- **Platform**: LeetCode
- **Problem**: [Single Number](https://leetcode.com/problems/single-number/)
- **Topic**: Arrays, Bit Manipulation
20. **Power of Two**
- **Platform**: LeetCode
- **Problem**: [Power of Two](https://leetcode.com/problems/power-of-two/)
- **Topic**: Mathematics, Bit Manipulation
These additional questions will give you a broader range of topics to practice and strengthen your
understanding of basic DSA concepts.
PRACTICE SET # 1
Linked List
done
Scenario: Implement a simple phone book using a linked list.
Task: Create functions to add a new contact, delete a contact
by name, search for a contact by name, and display all
contacts in the phone book.
Double Linked List
Scenario: Manage a playlist of songs using a doubly linked
list.
Task: Create functions to add a song to the beginning, end,
and a specific position in the playlist. Also, create functions to
delete a song by name, move to the next song, and move to
the previous song in the playlist.
Circular Linked List
Scenario: Implement a circular queue for a ticketing system
at an amusement park using a circular linked list.
Task: Create functions to add a customer to the queue,
remove a customer from the queue, and display the current
queue. Ensure the last customer points back to the first to
form a circular structure.
Stack
done
Scenario: Implement an undo feature for a text editor using a
stack.
Task: Create functions to push a new action onto the stack,
pop the last action (undo), and display the current stack of
actions. Each action could be represented as a string (e.g.,
"Typed 'Hello'", "Deleted 'World'").
PRACTICE SET # 2
TO COVER TOPICS:
1. Queue
Prompt: Implement a Ticketing System for a Movie Theater
Scenario: done
You are tasked with implementing a ticketing system for a movie
theater using a queue. The system should handle the following
operations:
1. Issue a Ticket: Customers join the queue to buy a ticket.
2. Serve a Customer: The customer at the front of the queue buys
a ticket and leaves the queue.
3. Display the Queue: Display the list of customers currently in
the queue.
PRACTICE # 3
1. DEQueue
2. Queue using LL
3. Trees
### 1. DEQueue (Double-Ended Queue) –1 hour
**Project Idea: Music Playlist Manager**
done
- **Description:** Create a program that manages a music playlist using a DEQueue. Users should be
able to add songs to the front or back of the playlist, remove songs from either end, and view the
current playlist.
- **Features:**
- Add a song to the beginning or end of the playlist.
- Remove a song from the beginning or end.
- Display the current playlist.
- Search for a song in the playlist.
### 2. Queue using Linked List –1 hour
**Project Idea: Customer Support Ticket System**
done
- **Description:** Develop a customer support ticket system where tickets are processed in the
order they are received (FIFO - First In, First Out). Use a linked list to implement the queue.
- **Features:**
- Add a new support ticket with customer details and issue description.
- Process and remove the oldest ticket from the queue.
- View the current queue of tickets.
- Search for a specific ticket based on customer
details.
PRACTICE # 4
### Unified Tree Operations Program done
**Project Idea: Unified Tree Operations Program**
**Description:** Create a program that allows users to build and
interact with either a Binary Search Tree (BST) or an AVL Tree. The
program should support insertion, searching, traversal, and basic
height calculation, with AVL-specific rotations for balancing.
**Features:**
1. **Choose Tree Type:**
- Allow the user to select whether they want to work with a BST or
an AVL Tree.
2. **Insert Elements:**
- Insert elements into the chosen tree.
- For AVL Tree, automatically balance the tree after each insertion
and display rotations.
3. **Search Elements:**
- Allow users to input a value to search for in the tree.
- Indicate whether the value is found and display the path taken
during the search.
4. **Tree Traversals:**
- Perform and display in-order, pre-order, and post-order traversals
of the tree.
5. **Find Minimum and Maximum:**
- Find and display the minimum and maximum values in the tree.
6. **Calculate Height:**
- Calculate and display the height of the tree.
**Sample Interface:**
```plaintext
Welcome to the Unified Tree Operations Program!
Please choose the type of tree:
1. Binary Search Tree (BST)
2. AVL Tree
Enter your choice: [1/2]
--- For BST ---
1. Insert an element
2. Search for an element
3. Perform tree traversal
4. Find minimum value
5. Find maximum value
6. Calculate tree height
7. Exit
--- For AVL Tree --1. Insert an element (with automatic balancing)
2. Search for an element
3. Perform tree traversal
4. Find minimum value
5. Find maximum value
6. Calculate tree height
7. Exit
Enter your choice: [1-7]
--- After each action, display results and return to the main menu --```
### Steps to Implement:
1. **Tree Node Class:**
- Define a class for tree nodes with attributes for value, left child,
right child, and height (for AVL).
2. **BST and AVL Tree Classes:**
- Implement separate classes for BST and AVL trees with methods
for insertion, search, traversals, finding min/max, and height
calculation.
- For AVL, include methods for rotations (left, right, left-right, rightleft) and balancing.
3. **Main Program:**
- Create a menu-driven interface that allows users to choose the
tree type and perform operations based on their choice.
- Use a loop to keep the program running until the user chooses to
exit.
This program will give you a comprehensive understanding of both
BST and AVL tree operations in one cohesive project.
Practice#5
Scenario: partially done
Create a maze-solving algorithm that finds a path from the start cell to the end cell using BFS
(Breadth-First Search) and DFS (Depth-First Search). Compare the paths found by both
methods.
Requirements:
1. Maze Representation: A 2D grid where 0 is a passable cell and 1 is a blocked cell.
2. BFS Solver: Implement BFS to find the shortest path from the start cell to the end
cell.
3. DFS Solver: Implement DFS to find any path from the start cell to the end cell.
4. Path Comparison: Compare the paths in terms of length and the number of explored
cells.
5. Visualization: Display the maze and the paths found by BFS and DFS.