β
10 JavaScript Project Ideas for Practice π‘π»
Building projects is the best way to solidify JavaScript skills. These 10 ideas start simple and build up, covering DOM manipulation, APIs, events, and more. Each includes key features to implementβgrab a code editor and start coding!
1οΈβ£ To-Do List App
β Add, delete, and mark tasks as complete with checkboxes.
β Use localStorage to persist data across browser sessions.
β Bonus: Add categories or due dates for organization.
2οΈβ£ Weather App
β Fetch real-time weather data using the OpenWeatherMap API (free key needed).
β Display temperature, humidity, city search, and weather icons.
β Bonus: Show forecasts for the next few days.
3οΈβ£ Quiz App
β Create multiple-choice questions from a JavaScript array or JSON.
β Track score, add a timer, and include a restart button.
β Bonus: Randomize questions and save high scores.
4οΈβ£ Calculator
β Implement basic operations: addition, subtraction, multiplication, division.
β Handle edge cases like division by zero or invalid input.
β Bonus: Add advanced functions like square root or memory.
5οΈβ£ Image Slider
β Build a carousel with next/prev buttons and auto-slide functionality.
β Include dot indicators for navigation and optional fade transitions.
β Bonus: Make it responsive for mobile swipe gestures.
6οΈβ£ Form Validator
β Validate fields like email, password strength, and required inputs in real-time.
β Display dynamic error/success messages with CSS classes.
β Bonus: Submit valid forms to a mock API or email service.
7οΈβ£ Typing Speed Test
β Display a paragraph or sentence for users to type.
β Calculate words per minute (WPM), accuracy, and error count.
β Bonus: Add multiple test lengths and a leaderboard.
8οΈβ£ Random Quote Generator
β Pull quotes from an array or API like Quotable.io.
β Refresh with a button and add share options (copy to clipboard or tweet).
β Bonus: Animate the quote reveal with CSS transitions.
9οΈβ£ Expense Tracker
β Log income/expenses with categories and amounts; calculate running balance.
β Visualize data using Chart.js for pie/bar charts.
β Bonus: Filter by date range and export to CSV.
π Rock Paper Scissors Game
β Let users choose rock, paper, or scissors against computer (random AI).
β Keep a score counter and add a restart option after rounds.
β Bonus: Include animations for choices and win/lose effects.
π‘ Bonus: Push your projects to GitHub for version control, then deploy for free with GitHub Pages or Netlify. These build portfolio-worthy skillsβstart with vanilla JS before adding frameworks like React.
π¬ Tap β€οΈ for more! π
Building projects is the best way to solidify JavaScript skills. These 10 ideas start simple and build up, covering DOM manipulation, APIs, events, and more. Each includes key features to implementβgrab a code editor and start coding!
1οΈβ£ To-Do List App
β Add, delete, and mark tasks as complete with checkboxes.
β Use localStorage to persist data across browser sessions.
β Bonus: Add categories or due dates for organization.
2οΈβ£ Weather App
β Fetch real-time weather data using the OpenWeatherMap API (free key needed).
β Display temperature, humidity, city search, and weather icons.
β Bonus: Show forecasts for the next few days.
3οΈβ£ Quiz App
β Create multiple-choice questions from a JavaScript array or JSON.
β Track score, add a timer, and include a restart button.
β Bonus: Randomize questions and save high scores.
4οΈβ£ Calculator
β Implement basic operations: addition, subtraction, multiplication, division.
β Handle edge cases like division by zero or invalid input.
β Bonus: Add advanced functions like square root or memory.
5οΈβ£ Image Slider
β Build a carousel with next/prev buttons and auto-slide functionality.
β Include dot indicators for navigation and optional fade transitions.
β Bonus: Make it responsive for mobile swipe gestures.
6οΈβ£ Form Validator
β Validate fields like email, password strength, and required inputs in real-time.
β Display dynamic error/success messages with CSS classes.
β Bonus: Submit valid forms to a mock API or email service.
7οΈβ£ Typing Speed Test
β Display a paragraph or sentence for users to type.
β Calculate words per minute (WPM), accuracy, and error count.
β Bonus: Add multiple test lengths and a leaderboard.
8οΈβ£ Random Quote Generator
β Pull quotes from an array or API like Quotable.io.
β Refresh with a button and add share options (copy to clipboard or tweet).
β Bonus: Animate the quote reveal with CSS transitions.
9οΈβ£ Expense Tracker
β Log income/expenses with categories and amounts; calculate running balance.
β Visualize data using Chart.js for pie/bar charts.
β Bonus: Filter by date range and export to CSV.
π Rock Paper Scissors Game
β Let users choose rock, paper, or scissors against computer (random AI).
β Keep a score counter and add a restart option after rounds.
β Bonus: Include animations for choices and win/lose effects.
π‘ Bonus: Push your projects to GitHub for version control, then deploy for free with GitHub Pages or Netlify. These build portfolio-worthy skillsβstart with vanilla JS before adding frameworks like React.
π¬ Tap β€οΈ for more! π
β€14
β
Top 6 Tips to Pick the Right Tech Career in 2025 ππ»
1οΈβ£ Start with Self-Discovery
β Do you enjoy building things? Try Web or App Dev ποΈ
β Love solving puzzles? Explore Data Science or Cybersecurity π§©π
β Like visuals? Go for UI/UX or Design Tools π¨
2οΈβ£ Explore Before You Commit
β Try short tutorials on YouTube or free courses πΊ
β Spend 1 hour exploring a new tool or language weekly β±οΈ
3οΈβ£ Look at Salary + Demand
β Research in-demand roles on LinkedIn & Glassdoor πΌ
β Focus on skills like Python, SQL, AI, Cloud, DevOps βοΈπ
4οΈβ£ Follow a Real Career Path
β Donβt just learn random things π€
β Example: HTML β CSS β JS β React β Full-Stack πΊοΈ
5οΈβ£ Build, Donβt Just Watch
β Make mini projects (to-do app, blog, scraper, etc.) π οΈ
β Share on GitHub or LinkedIn π
6οΈβ£ Stay Consistent
β 30 mins a day beats 5 hours once a week κΎΈμ€ν
β Track your learning and celebrate progress π
π‘ You donβt need to learn everything β just the right thing at the right time.
π¬ Tap β€οΈ for more!
1οΈβ£ Start with Self-Discovery
β Do you enjoy building things? Try Web or App Dev ποΈ
β Love solving puzzles? Explore Data Science or Cybersecurity π§©π
β Like visuals? Go for UI/UX or Design Tools π¨
2οΈβ£ Explore Before You Commit
β Try short tutorials on YouTube or free courses πΊ
β Spend 1 hour exploring a new tool or language weekly β±οΈ
3οΈβ£ Look at Salary + Demand
β Research in-demand roles on LinkedIn & Glassdoor πΌ
β Focus on skills like Python, SQL, AI, Cloud, DevOps βοΈπ
4οΈβ£ Follow a Real Career Path
β Donβt just learn random things π€
β Example: HTML β CSS β JS β React β Full-Stack πΊοΈ
5οΈβ£ Build, Donβt Just Watch
β Make mini projects (to-do app, blog, scraper, etc.) π οΈ
β Share on GitHub or LinkedIn π
6οΈβ£ Stay Consistent
β 30 mins a day beats 5 hours once a week κΎΈμ€ν
β Track your learning and celebrate progress π
π‘ You donβt need to learn everything β just the right thing at the right time.
π¬ Tap β€οΈ for more!
β€13
β
Top 50 DSA (Data Structures & Algorithms) Interview Questions πβοΈ
1. What is a Data Structure?
2. What are the different types of data structures?
3. What is the difference between Array and Linked List?
4. How does a Stack work?
5. What is a Queue? Difference between Queue and Deque?
6. What is a Priority Queue?
7. What is a Hash Table and how does it work?
8. What is the difference between HashMap and HashSet?
9. What are Trees? Explain Binary Tree.
10. What is a Binary Search Tree (BST)?
11. What is the difference between BFS and DFS?
12. What is a Heap?
13. What is a Trie?
14. What is a Graph?
15. Difference between Directed and Undirected Graph?
16. What is the time complexity of common operations in arrays and linked lists?
17. What is recursion?
18. What are base case and recursive case?
19. What is dynamic programming?
20. Difference between Memoization and Tabulation?
21. What is the Sliding Window technique?
22. Explain Two-Pointer technique.
23. What is the Binary Search algorithm?
24. What is the Merge Sort algorithm?
25. What is the Quick Sort algorithm?
26. Difference between Merge Sort and Quick Sort?
27. What is Insertion Sort and how does it work?
28. What is Selection Sort?
29. What is Bubble Sort and its drawbacks?
30. What is the time and space complexity of sorting algorithms?
31. What is Backtracking?
32. Explain the N-Queens Problem.
33. What is the Kadane's Algorithm?
34. What is Floydβs Cycle Detection Algorithm?
35. What is the Union-Find (Disjoint Set) algorithm?
36. What are topological sorting and its uses?
37. What is Dijkstra's Algorithm?
38. What is Bellman-Ford Algorithm?
39. What is Kruskalβs Algorithm?
40. What is Primβs Algorithm?
41. What is Longest Common Subsequence (LCS)?
42. What is Longest Increasing Subsequence (LIS)?
43. What is a Palindrome Substring problem?
44. What is the difference between greedy and dynamic programming?
45. What is Big-O notation?
46. What is the difference between time and space complexity?
47. How to find the time complexity of a recursive function?
48. What are amortized time complexities?
49. What is tail recursion?
50. How do you approach solving a coding problem in interviews?
π¬ Tap β€οΈ for the detailed answers!
1. What is a Data Structure?
2. What are the different types of data structures?
3. What is the difference between Array and Linked List?
4. How does a Stack work?
5. What is a Queue? Difference between Queue and Deque?
6. What is a Priority Queue?
7. What is a Hash Table and how does it work?
8. What is the difference between HashMap and HashSet?
9. What are Trees? Explain Binary Tree.
10. What is a Binary Search Tree (BST)?
11. What is the difference between BFS and DFS?
12. What is a Heap?
13. What is a Trie?
14. What is a Graph?
15. Difference between Directed and Undirected Graph?
16. What is the time complexity of common operations in arrays and linked lists?
17. What is recursion?
18. What are base case and recursive case?
19. What is dynamic programming?
20. Difference between Memoization and Tabulation?
21. What is the Sliding Window technique?
22. Explain Two-Pointer technique.
23. What is the Binary Search algorithm?
24. What is the Merge Sort algorithm?
25. What is the Quick Sort algorithm?
26. Difference between Merge Sort and Quick Sort?
27. What is Insertion Sort and how does it work?
28. What is Selection Sort?
29. What is Bubble Sort and its drawbacks?
30. What is the time and space complexity of sorting algorithms?
31. What is Backtracking?
32. Explain the N-Queens Problem.
33. What is the Kadane's Algorithm?
34. What is Floydβs Cycle Detection Algorithm?
35. What is the Union-Find (Disjoint Set) algorithm?
36. What are topological sorting and its uses?
37. What is Dijkstra's Algorithm?
38. What is Bellman-Ford Algorithm?
39. What is Kruskalβs Algorithm?
40. What is Primβs Algorithm?
41. What is Longest Common Subsequence (LCS)?
42. What is Longest Increasing Subsequence (LIS)?
43. What is a Palindrome Substring problem?
44. What is the difference between greedy and dynamic programming?
45. What is Big-O notation?
46. What is the difference between time and space complexity?
47. How to find the time complexity of a recursive function?
48. What are amortized time complexities?
49. What is tail recursion?
50. How do you approach solving a coding problem in interviews?
π¬ Tap β€οΈ for the detailed answers!
β€32
β
Top DSA Interview Questions with Answers: Part-1 π§
1. What is a Data Structure?
A data structure is a way to organize, store, and manage data efficiently so it can be accessed and modified easily. Examples: Arrays, Linked Lists, Stacks, Queues, Trees, Graphs.
2. What are the different types of data structures?
β’ Linear: Arrays, Linked Lists, Stacks, Queues
β’ Non-linear: Trees, Graphs
β’ Hash-based: Hash Tables, Hash Maps
β’ Dynamic: Heaps, Tries, Disjoint Sets
3. What is the difference between Array and Linked List?
β’ Array: Fixed size, index-based access (O(1)), insertion/deletion is expensive
β’ Linked List: Dynamic size, sequential access (O(n)), efficient insertion/deletion at any position
4. How does a Stack work?
A Stack follows LIFO (Last In, First Out) principle.
β’ Operations: push() to add, pop() to remove, peek() to view top
β’ Used in: undo mechanisms, recursion, parsing
5. What is a Queue? Difference between Queue and Deque?
A Queue follows FIFO (First In, First Out).
β’ Deque (Double-Ended Queue): Allows insertion/removal from both ends.
β’ Used in scheduling, caching, BFS traversal.
6. What is a Priority Queue?
A type of queue where each element has a priority.
β’ Higher priority elements are dequeued before lower ones.
β’ Implemented using heaps.
7. What is a Hash Table and how does it work?
A structure that maps keys to values using a hash function.
β’ Allows O(1) average-case lookup, insert, delete.
β’ Handles collisions using chaining or open addressing.
8. What is the difference between HashMap and HashSet?
β’ HashMap: Stores key-value pairs
β’ HashSet: Stores only unique keys (no values)
Both use hash tables internally.
9. What are Trees? Explain Binary Tree.
A tree is a non-linear structure with nodes connected hierarchically.
β’ Binary Tree: Each node has at most 2 children (left, right).
Used in hierarchical data, parsers, expression trees.
10. What is a Binary Search Tree (BST)?
A special binary tree where:
β’ Left child < Node < Right child
β’ Enables fast lookup, insert, and delete in O(log n) (average case).
Maintains sorted structure.
Double Tap β₯οΈ For Part-2
1. What is a Data Structure?
A data structure is a way to organize, store, and manage data efficiently so it can be accessed and modified easily. Examples: Arrays, Linked Lists, Stacks, Queues, Trees, Graphs.
2. What are the different types of data structures?
β’ Linear: Arrays, Linked Lists, Stacks, Queues
β’ Non-linear: Trees, Graphs
β’ Hash-based: Hash Tables, Hash Maps
β’ Dynamic: Heaps, Tries, Disjoint Sets
3. What is the difference between Array and Linked List?
β’ Array: Fixed size, index-based access (O(1)), insertion/deletion is expensive
β’ Linked List: Dynamic size, sequential access (O(n)), efficient insertion/deletion at any position
4. How does a Stack work?
A Stack follows LIFO (Last In, First Out) principle.
β’ Operations: push() to add, pop() to remove, peek() to view top
β’ Used in: undo mechanisms, recursion, parsing
5. What is a Queue? Difference between Queue and Deque?
A Queue follows FIFO (First In, First Out).
β’ Deque (Double-Ended Queue): Allows insertion/removal from both ends.
β’ Used in scheduling, caching, BFS traversal.
6. What is a Priority Queue?
A type of queue where each element has a priority.
β’ Higher priority elements are dequeued before lower ones.
β’ Implemented using heaps.
7. What is a Hash Table and how does it work?
A structure that maps keys to values using a hash function.
β’ Allows O(1) average-case lookup, insert, delete.
β’ Handles collisions using chaining or open addressing.
8. What is the difference between HashMap and HashSet?
β’ HashMap: Stores key-value pairs
β’ HashSet: Stores only unique keys (no values)
Both use hash tables internally.
9. What are Trees? Explain Binary Tree.
A tree is a non-linear structure with nodes connected hierarchically.
β’ Binary Tree: Each node has at most 2 children (left, right).
Used in hierarchical data, parsers, expression trees.
10. What is a Binary Search Tree (BST)?
A special binary tree where:
β’ Left child < Node < Right child
β’ Enables fast lookup, insert, and delete in O(log n) (average case).
Maintains sorted structure.
Double Tap β₯οΈ For Part-2
β€20
β
Top DSA Interview Questions with Answers: Part-2 π§
11. What is the difference between BFS and DFS?
- BFS (Breadth-First Search): Explores neighbors first (level by level). Uses a queue. β‘οΈ
- DFS (Depth-First Search): Explores depth (child nodes) first. Uses a stack or recursion. β¬οΈ
Used in graph/tree traversals, pathfinding, cycle detection. π³π
12. What is a Heap?
A binary tree with heap properties:
- Max-Heap: Parent β₯ children πΌ
- Min-Heap: Parent β€ children π½
Used in priority queues, heap sort, scheduling algorithms. β°
13. What is a Trie?
A tree-like data structure used to store strings. π²
Each node represents a character.
Used in: autocomplete, spell-checkers, prefix search. π‘
14. What is a Graph?
A graph is a collection of nodes (vertices) and edges. π
- Can be directed/undirected, weighted/unweighted.
Used in: networks, maps, recommendation systems. πΊοΈ
15. Difference between Directed and Undirected Graph?
- Directed: Edges have direction (A β B β B β A) β‘οΈ
- Undirected: Edges are bidirectional (A β B) βοΈ
Used differently based on relationships (e.g., social networks vs. web links).
16. What is the time complexity of common operations in arrays and linked lists?
- Array: π’
- Access: O(1)
- Insert/Delete: O(n)
- Linked List: π
- Access: O(n)
- Insert/Delete: O(1) at head
17. What is recursion?
When a function calls itself to solve a smaller subproblem. π
Requires a base case to stop infinite calls.
Used in: tree traversals, backtracking, divide & conquer. π³π§©
18. What are base case and recursive case?
- Base Case: Condition that ends recursion π
- Recursive Case: Part where the function calls itself β‘οΈ
Example:
19. What is dynamic programming?
An optimization technique that solves problems by breaking them into overlapping subproblems and storing their results (memoization). πΎ
Used in: Fibonacci, knapsack, LCS. π
20. Difference between Memoization and Tabulation?
- Memoization (Top-down): Uses recursion + caching π§
- Tabulation (Bottom-up): Uses iteration + table π
Both store solutions to avoid redundant calculations.
π¬ Double Tap β₯οΈ For Part-3
11. What is the difference between BFS and DFS?
- BFS (Breadth-First Search): Explores neighbors first (level by level). Uses a queue. β‘οΈ
- DFS (Depth-First Search): Explores depth (child nodes) first. Uses a stack or recursion. β¬οΈ
Used in graph/tree traversals, pathfinding, cycle detection. π³π
12. What is a Heap?
A binary tree with heap properties:
- Max-Heap: Parent β₯ children πΌ
- Min-Heap: Parent β€ children π½
Used in priority queues, heap sort, scheduling algorithms. β°
13. What is a Trie?
A tree-like data structure used to store strings. π²
Each node represents a character.
Used in: autocomplete, spell-checkers, prefix search. π‘
14. What is a Graph?
A graph is a collection of nodes (vertices) and edges. π
- Can be directed/undirected, weighted/unweighted.
Used in: networks, maps, recommendation systems. πΊοΈ
15. Difference between Directed and Undirected Graph?
- Directed: Edges have direction (A β B β B β A) β‘οΈ
- Undirected: Edges are bidirectional (A β B) βοΈ
Used differently based on relationships (e.g., social networks vs. web links).
16. What is the time complexity of common operations in arrays and linked lists?
- Array: π’
- Access: O(1)
- Insert/Delete: O(n)
- Linked List: π
- Access: O(n)
- Insert/Delete: O(1) at head
17. What is recursion?
When a function calls itself to solve a smaller subproblem. π
Requires a base case to stop infinite calls.
Used in: tree traversals, backtracking, divide & conquer. π³π§©
18. What are base case and recursive case?
- Base Case: Condition that ends recursion π
- Recursive Case: Part where the function calls itself β‘οΈ
Example:
def fact(n):
if n == 0: return 1 # base case
return n * fact(n-1) # recursive case
19. What is dynamic programming?
An optimization technique that solves problems by breaking them into overlapping subproblems and storing their results (memoization). πΎ
Used in: Fibonacci, knapsack, LCS. π
20. Difference between Memoization and Tabulation?
- Memoization (Top-down): Uses recursion + caching π§
- Tabulation (Bottom-up): Uses iteration + table π
Both store solutions to avoid redundant calculations.
π¬ Double Tap β₯οΈ For Part-3
β€7π1
β
15-Day Winter Training by GeeksforGeeks βοΈπ»
π― Build 1 Industry-Level Project
π IBM Certification Included
π¨βπ« Mentor-Led Classroom Learning
π Offline in: Noida | Bengaluru | Hyderabad | Pune | Kolkata
π§³ Perfect for Minor/Major Projects Portfolio
π§ MERN Stack:
https://gfgcdn.com/tu/WC6/
π Data Science:
https://gfgcdn.com/tu/WC7/
π₯ What Youβll Build:
β’ MERN: Full LMS with auth, roles, payments, AWS deploy
β’ Data Science: End-to-end GenAI apps (chatbots, RAG, recsys)
π’ Limited Seats β Register Now!
π― Build 1 Industry-Level Project
π IBM Certification Included
π¨βπ« Mentor-Led Classroom Learning
π Offline in: Noida | Bengaluru | Hyderabad | Pune | Kolkata
π§³ Perfect for Minor/Major Projects Portfolio
π§ MERN Stack:
https://gfgcdn.com/tu/WC6/
π Data Science:
https://gfgcdn.com/tu/WC7/
π₯ What Youβll Build:
β’ MERN: Full LMS with auth, roles, payments, AWS deploy
β’ Data Science: End-to-end GenAI apps (chatbots, RAG, recsys)
π’ Limited Seats β Register Now!
β€8π1
β
Top DSA Interview Questions with Answers: Part-3 π§
21. What is the Sliding Window technique?
Itβs an optimization method used to reduce time complexity in problems involving arrays or strings. You create a "window" over a subset of data and slide it as needed, updating results on the go.
Example use case: Find the maximum sum of any k consecutive elements in an array.
22. Explain the Two-Pointer technique.
This involves using two indices (pointers) to traverse a data structure, usually from opposite ends or the same direction. It's helpful for searching pairs or reversing sequences efficiently.
Common problems: Two-sum, palindrome check, sorted array partitioning.
23. What is the Binary Search algorithm?
Itβs an efficient algorithm to find an element in a sorted array by repeatedly dividing the search range in half.
Time Complexity: O(log n)
Key idea: Compare the target with the middle element and eliminate half the array each step.
24. What is the Merge Sort algorithm?
A divide-and-conquer sorting algorithm that splits the array into halves, sorts them recursively, and then merges them.
Time Complexity: O(n log n)
Stable? Yes
Extra space? Yes, due to merging.
25. What is the Quick Sort algorithm?
It chooses a pivot, partitions the array so elements < pivot are left, and > pivot are right, then recursively sorts both sides.
Time Complexity: Avg β O(n log n), Worst β O(nΒ²)
Fast in practice, but not stable.
26. Difference between Merge Sort and Quick Sort
β’ Merge Sort is stable, consistent in performance (O(n log n)), but uses extra space.
β’ Quick Sort is faster in practice and works in-place, but may degrade to O(nΒ²) if pivot is poorly chosen.
27. What is Insertion Sort and how does it work?
It builds the sorted list one item at a time by comparing and inserting items into their correct position.
Time Complexity: O(nΒ²)
Best Case (nearly sorted): O(n)
Stable? Yes
Space: O(1)
28. What is Selection Sort?
It finds the smallest element from the unsorted part and swaps it with the beginning.
Time Complexity: O(nΒ²)
Space: O(1)
Stable? No
Rarely used due to inefficiency.
29. What is Bubble Sort and its drawbacks?
It repeatedly compares and swaps adjacent elements if out of order.
Time Complexity: O(nΒ²)
Space: O(1)
Drawback: Extremely slow for large data. Educational, not practical.
30. What is the time and space complexity of common sorting algorithms?
β’ Bubble Sort β Time: O(nΒ²), Space: O(1), Stable: Yes
β’ Selection Sort β Time: O(nΒ²), Space: O(1), Stable: No
β’ Insertion Sort β Time: O(nΒ²), Space: O(1), Stable: Yes
β’ Merge Sort β Time: O(n log n), Space: O(n), Stable: Yes
β’ Quick Sort β Avg Time: O(n log n), Worst: O(nΒ²), Space: O(log n), Stable: No
Double Tap β₯οΈ For Part-4
21. What is the Sliding Window technique?
Itβs an optimization method used to reduce time complexity in problems involving arrays or strings. You create a "window" over a subset of data and slide it as needed, updating results on the go.
Example use case: Find the maximum sum of any k consecutive elements in an array.
22. Explain the Two-Pointer technique.
This involves using two indices (pointers) to traverse a data structure, usually from opposite ends or the same direction. It's helpful for searching pairs or reversing sequences efficiently.
Common problems: Two-sum, palindrome check, sorted array partitioning.
23. What is the Binary Search algorithm?
Itβs an efficient algorithm to find an element in a sorted array by repeatedly dividing the search range in half.
Time Complexity: O(log n)
Key idea: Compare the target with the middle element and eliminate half the array each step.
24. What is the Merge Sort algorithm?
A divide-and-conquer sorting algorithm that splits the array into halves, sorts them recursively, and then merges them.
Time Complexity: O(n log n)
Stable? Yes
Extra space? Yes, due to merging.
25. What is the Quick Sort algorithm?
It chooses a pivot, partitions the array so elements < pivot are left, and > pivot are right, then recursively sorts both sides.
Time Complexity: Avg β O(n log n), Worst β O(nΒ²)
Fast in practice, but not stable.
26. Difference between Merge Sort and Quick Sort
β’ Merge Sort is stable, consistent in performance (O(n log n)), but uses extra space.
β’ Quick Sort is faster in practice and works in-place, but may degrade to O(nΒ²) if pivot is poorly chosen.
27. What is Insertion Sort and how does it work?
It builds the sorted list one item at a time by comparing and inserting items into their correct position.
Time Complexity: O(nΒ²)
Best Case (nearly sorted): O(n)
Stable? Yes
Space: O(1)
28. What is Selection Sort?
It finds the smallest element from the unsorted part and swaps it with the beginning.
Time Complexity: O(nΒ²)
Space: O(1)
Stable? No
Rarely used due to inefficiency.
29. What is Bubble Sort and its drawbacks?
It repeatedly compares and swaps adjacent elements if out of order.
Time Complexity: O(nΒ²)
Space: O(1)
Drawback: Extremely slow for large data. Educational, not practical.
30. What is the time and space complexity of common sorting algorithms?
β’ Bubble Sort β Time: O(nΒ²), Space: O(1), Stable: Yes
β’ Selection Sort β Time: O(nΒ²), Space: O(1), Stable: No
β’ Insertion Sort β Time: O(nΒ²), Space: O(1), Stable: Yes
β’ Merge Sort β Time: O(n log n), Space: O(n), Stable: Yes
β’ Quick Sort β Avg Time: O(n log n), Worst: O(nΒ²), Space: O(log n), Stable: No
Double Tap β₯οΈ For Part-4
β€13