🏗️ Basic Data Structures¶
Beyond simple variables and arrays, data structures help organize information for efficient access and modification.
1. Stack Implementation (Array)¶
Rating: Beginner | Difficulty: Medium
Implement a Stack (LIFO) using an array with push and pop operations. 💡
Hint
Use a top variable to keep track of the current index.
2. Queue Implementation (Array)¶
Rating: Beginner | Difficulty: Medium
Implement a Queue (FIFO) using an array with enqueue and dequeue operations.
Use front and rear variables.
3. Check for Balanced Parentheses¶
Rating: Intermediate | Difficulty: Medium
Use a Stack to check if an expression like (( )) is balanced. 💡 Hint
Push ( to the stack. Pop when you see ). Stack should be empty at the end.
4. Reverse a String using Stack¶
Rating: Beginner | Difficulty: Easy Push every character of a string into a stack, then pop them all out to get the reversed string.
💡 Hint
Last In, First Out!5. Linked List Node Creation¶
Rating: Beginner | Difficulty: Medium
Create a simple structure/class for a Node in a singly linked list. 💡
Hint
A Node contains data and a pointer/reference to the next node.
6. Linked List - Insert at Beginning¶
Rating: Intermediate | Difficulty: Medium
Write a function to insert a new node at the start of a singly linked list. 💡
Hint
newNode.next = head; head = newNode;
7. Linked List - Traversal¶
Rating: Beginner | Difficulty: Easy
Print all elements of a singly linked list. 💡 Hint
Use a temp pointer
and loop while (temp != null).
8. Stack using Linked List¶
Rating: Advanced | Difficulty: Medium
Implement a Stack where each element is a node in a linked list. 💡 Hint
Pushing is inserting at the head; popping is deleting the head.
9. Queue using Linked List¶
Rating: Advanced | Difficulty: Medium
Implement a Queue using a linked list. 💡 Hint
Maintain both front and
rear pointers for efficient operations.
10. Circular Queue¶
Rating: Advanced | Difficulty: Hard
Implement a Circular Queue to reuse empty spaces in an array. 💡 Hint
Use the modulus operator: rear = (rear + 1) % size.
11. Reverse a Linked List¶
Rating: Pro | Difficulty: Hard
Reverse the links in a singly linked list so the tail becomes the head. 💡
Hint
Use three pointers: prev, current, and next.
12. Find the Middle of a Linked List¶
Rating: Advanced | Difficulty: Medium
Find the middle node of a linked list in a single pass. 💡 Hint
Use two
pointers: "Slow" (moves 1 step) and "Fast" (moves 2 steps).
13. Search in a Linked List¶
Rating: Beginner | Difficulty: Easy
Check if a specific value exists in a linked list. 💡 Hint
Traverse and
compare.
14. Delete a Node (Linked List)¶
Rating: Intermediate | Difficulty: Medium
Delete a node with a specific value from a linked list. 💡 Hint
Link the
previous node directly to the next node of the target.
15. Decimal to Binary using Stack¶
Rating: Intermediate | Difficulty: Medium
Convert a decimal number to binary by pushing remainders onto a stack. 💡
Hint
Divide by 2, push remainder, repeat. Pop everything at the end.
← Previous: File Handling | Next Section: Mastering Logic (Coming Soon)