Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Arrays/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ This directory contains Python implementations of common array-based algorithms

## Contents

- [Anagram Check (Sorted Solution)](Anagram_Check_Sorted_Sol.py): Checks if two strings are anagrams by comparing their sorted versions.
- [Anagram Check (Manual Solution)](Anagram_Check_manual_Sol.py): Checks if two strings are anagrams using a hash table (dictionary) to count character frequencies.
- [Array Find Missing Element (XOR Solution)](ArrayFindTheMissingElement_XOR_sol.py): Efficiently finds a missing element in a shuffled array using bitwise XOR.
- [Array Find Missing Element (Brute Force Solution)](ArrayFindTheMissingElement_brute_force_sol.py): Finds a missing element by sorting both arrays and comparing them.
- [Array Find Missing Element (Hash Table Solution)](ArrayFindTheMissingElement_hash_table_sol.py): Finds a missing element using a hash table (dictionary) to track element counts.
- [Array Find Missing Element (Sum/Subtract Solution)](ArrayFindTheMissingElement_takingSumandSubtract_sol.py): Finds a missing element by calculating the difference between the sums of the two arrays.
- [Anagram Check (Sorted Solution)](Anagram_Check_Sorted_Sol.py): Checks if two strings are anagrams by comparing their sorted versions in $O(n \log n)$ time.
- [Anagram Check (Manual Solution)](Anagram_Check_manual_Sol.py): Checks if two strings are anagrams using a hash table (dictionary) to count character frequencies in $O(n)$ time.
- [Array Find Missing Element (XOR Solution)](ArrayFindTheMissingElement_XOR_sol.py): Efficiently finds a missing element in a shuffled array using bitwise XOR in $O(n)$ time and $O(1)$ space.
- [Array Find Missing Element (Brute Force Solution)](ArrayFindTheMissingElement_brute_force_sol.py): Finds a missing element by sorting both arrays and comparing them in $O(n \log n)$ time.
- [Array Find Missing Element (Hash Table Solution)](ArrayFindTheMissingElement_hash_table_sol.py): Finds a missing element using a hash table (dictionary) to track element counts in $O(n)$ time and space.
- [Array Find Missing Element (Sum/Subtract Solution)](ArrayFindTheMissingElement_takingSumandSubtract_sol.py): Finds a missing element by calculating the difference between the sums of the two arrays in $O(n)$ time and $O(1)$ space.
- [Array Pair Sum Solution](ArrayPairSumSol.py): Finds all unique pairs in an array that sum up to a specific value $k$ using a set for $O(n)$ complexity.
File renamed without changes.
2 changes: 1 addition & 1 deletion deque/README.md → Deque/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ This directory contains Python implementations of the Deque (Double-Ended Queue)

## Contents

- [Deque Implementation](DequeImple.py): Basic implementation of a Deque using a Python list. Includes operations like `addFront`, `addRear`, `removeFront`, `removeRear`, `isEmpty`, and `size`.
- [Deque Implementation](DequeImple.py): Basic implementation of a Deque using a Python list. Includes operations like `addFront` ($O(1)$), `addRear` ($O(n)$), `removeFront` ($O(1)$), `removeRear` ($O(n)$), `isEmpty` ($O(1)$), and `size` ($O(1)$).
File renamed without changes.
2 changes: 1 addition & 1 deletion Error-debug/README.md → ErrorHandling/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Error and Debugging
# Error Handling and Debugging

This directory contains examples of error handling and debugging techniques in Python.

Expand Down
10 changes: 5 additions & 5 deletions GraphAlgorithms/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ This directory contains Python implementations of common graph-based algorithms

## Contents

- [Adjacency List Implementation](AdjacencyListGraphImple.py): Implements the Graph Abstract Data Type (ADT) using an adjacency list (dictionaries in Python). Includes `Vertex` and `Graph` classes.
- [Breadth First Search (BFS)](BFS.py): Implements BFS to solve the Word Ladder problem, finding the shortest transformation path between words.
- [General Depth First Search (DFS)](DFSGeneral.py): Provides a general implementation of DFS, including discovery and finish times for vertices.
- [DFS - Knight's Tour Problem](DFSImpleTheKnightsTourProblem.py): Another implementation of DFS specifically tailored to the Knight's Tour puzzle.
- [Adjacency List Implementation](AdjacencyListGraphImple.py): Implements the Graph Abstract Data Type (ADT) using an adjacency list (dictionaries in Python). Includes `Vertex` and `Graph` classes. Operations like adding a vertex or edge are $O(1)$.
- [Breadth First Search (BFS)](BFS.py): Implements BFS to solve the Word Ladder problem, finding the shortest transformation path between words in $O(V+E)$ time.
- [General Depth First Search (DFS)](DFSGeneral.py): Provides a general implementation of DFS, including discovery and finish times for vertices. Running time is $O(V+E)$.
- [DFS - Knight's Tour Problem](DFSImpleTheKnightsTourProblem.py): Another implementation of DFS specifically tailored to the Knight's Tour puzzle, with $O(k^N)$ complexity where $k$ is the branching factor.
- [The Knight's Tour Problem](TheKnightsTourProblem.py): Focuses on generating the knight's move graph and solving the tour using DFS and backtracking.
- [Word Ladder Problem](WordLadderProblem.py): Specifically focuses on building the word ladder graph where edges connect words that differ by only one letter.
- [Word Ladder Problem](WordLadderProblem.py): Specifically focuses on building the word ladder graph where edges connect words that differ by only one letter, in $O(n \cdot k^2)$ where $n$ is the number of words and $k$ is the word length.
10 changes: 5 additions & 5 deletions LinkedLists/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ This directory contains Python implementations of various types of linked lists

## Contents

- [Singly Linked List Implementation](SingleLinkedListImple.py): Basic implementation of a singly linked list node and basic linkage.
- [Doubly Linked List Implementation](DoublyLinkedListImple.py): Basic implementation of a doubly linked list node with `prev` and `next` pointers.
- [Singly Linked List Cycle Check](SinglyLinkedListCycleCheckImple.py): Implements Floyd's Cycle-Finding Algorithm (two pointers) to detect cycles in a linked list.
- [Linked List Reversal](LinkedListReversal.py): Reverses a singly linked list in-place in $O(n)$ time.
- [Nth to Last Node](LinkedListNthToLastNode.py): Finds the $n$-th to last node in a singly linked list using two pointers.
- [Singly Linked List Implementation](SingleLinkedListImple.py): Basic implementation of a singly linked list node and basic linkage. Insertion is $O(1)$, and access is $O(n)$.
- [Doubly Linked List Implementation](DoublyLinkedListImple.py): Basic implementation of a doubly linked list node with `prev` and `next` pointers. Both insertion and deletion are $O(1)$.
- [Singly Linked List Cycle Check](SinglyLinkedListCycleCheckImple.py): Implements Floyd's Cycle-Finding Algorithm (two pointers) to detect cycles in a linked list in $O(n)$ time and $O(1)$ space.
- [Linked List Reversal](LinkedListReversal.py): Reverses a singly linked list in-place in $O(n)$ time and $O(1)$ space.
- [Nth to Last Node](LinkedListNthToLastNode.py): Finds the $n$-th to last node in a singly linked list using two pointers in $O(n)$ time and $O(1)$ space.
4 changes: 2 additions & 2 deletions Queues/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ This directory contains Python implementations of the Queue data structure.

## Contents

- [Queue Implementation](QueueImple.py): Basic implementation of a FIFO (First-In-First-Out) queue using a Python list. Includes `enqueue`, `dequeue`, `isEmpty`, and `size` methods.
- [Queue with Two Stacks](QueueWith2StacksImple.py): Implements a queue using two stacks (represented by Python lists) to achieve FIFO behavior.
- [Queue Implementation](QueueImple.py): Basic implementation of a FIFO (First-In-First-Out) queue using a Python list. Includes `enqueue` ($O(n)$ due to `insert(0)`) and `dequeue` ($O(1)$) methods.
- [Queue with Two Stacks](QueueWith2StacksImple.py): Implements a queue using two stacks (represented by Python lists) to achieve FIFO behavior with $O(1)$ amortized time for `enqueue` and `dequeue`.
80 changes: 40 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for more details.
- [Getting Started](#getting-started)
- [Project Structure](#project-structure)
- [Data Structures](#data-structures)
- [Arrays](#arrays)
- [Linked Lists](#linked-lists)
- [Stacks](#stacks)
- [Queues](#queues)
- [Deque](#deque)
- [Trees](#trees)
- [Arrays](#arrays-)
- [Linked Lists](#linked-lists-)
- [Stacks](#stacks-)
- [Queues](#queues-)
- [Deque](#deque-)
- [Trees](#trees-)
- [Algorithms](#algorithms)
- [Sorting](#sorting)
- [Sorting](#sorting-)
- [Recursion & Dynamic Programming](#recursion--dynamic-programming)
- [Graph Algorithms](#graph-algorithms)
- [Graph Algorithms](#graph-algorithms-)
- [Error Handling & Debugging](#error-handling--debugging)
- [Usage](#usage)
- [Quick Reference](#quick-reference)
Expand Down Expand Up @@ -80,15 +80,15 @@ python3 Sorting/BubbleSortImple.py
```
.
├── Arrays/ # 🔤 Array-based problems and algorithms
├── Error-debug/ # ⚠️ Error handling and debugging examples
├── Deque/ # 🔄 Double-ended queue
├── ErrorHandling/ # ⚠️ Error handling and debugging examples
├── GraphAlgorithms/ # 🗺️ Graph traversal (BFS, DFS) and pathfinding
├── LinkedLists/ # 🔗 Singly and Doubly Linked Lists
├── Queues/ # 📦 Queue implementations (FIFO)
├── Recursion/ # 🔀 Recursive problems and Dynamic Programming
├── Sorting/ # 📊 Common sorting algorithms
├── Stacks/ # 📚 Stack implementations and applications
├── Trees/ # 🌳 Binary Trees, BSTs, Heaps, and Traversals
├── deque/ # 🔄 Double-ended queue
├── CONTRIBUTING.md # 🤝 Contribution guidelines
├── LICENSE # 📄 MIT License
└── README.md # 📖 This file
Expand All @@ -100,39 +100,39 @@ python3 Sorting/BubbleSortImple.py

### Arrays 🔤
Common array-based algorithms and manipulations.
- [Anagram Check](Arrays/): [Sorted](Arrays/Anagram_Check_Sorted_Sol.py) & [Manual](Arrays/Anagram_Check_manual_Sol.py) solutions
- [Array Pair Sum](Arrays/ArrayPairSumSol.py): Find pairs that sum to $k$
- [Find Missing Element](Arrays/): [XOR](Arrays/ArrayFindTheMissingElement_XOR_sol.py), [Brute Force](Arrays/ArrayFindTheMissingElement_brute_force_sol.py), [Hash Table](Arrays/ArrayFindTheMissingElement_hash_table_sol.py), & [Sum](Arrays/ArrayFindTheMissingElement_takingSumandSubtract_sol.py) approaches
- [Anagram Check](Arrays/): [Sorted](Arrays/Anagram_Check_Sorted_Sol.py) $O(n \log n)$ & [Manual](Arrays/Anagram_Check_manual_Sol.py) $O(n)$ solutions
- [Array Pair Sum](Arrays/ArrayPairSumSol.py): Find pairs that sum to $k$ in $O(n)$
- [Find Missing Element](Arrays/): [XOR](Arrays/ArrayFindTheMissingElement_XOR_sol.py) $O(n)$, [Brute Force](Arrays/ArrayFindTheMissingElement_brute_force_sol.py) $O(n \log n)$, [Hash Table](Arrays/ArrayFindTheMissingElement_hash_table_sol.py) $O(n)$, & [Sum](Arrays/ArrayFindTheMissingElement_takingSumandSubtract_sol.py) $O(n)$ approaches

### Linked Lists 🔗
Implementations and problems involving linked structures.
- [Singly Linked List](LinkedLists/SingleLinkedListImple.py) & [Doubly Linked List](LinkedLists/DoublyLinkedListImple.py)
- [Cycle Detection](LinkedLists/SinglyLinkedListCycleCheckImple.py): Detect cycles using two pointers (Floyd's algorithm)
- [Reverse Linked List](LinkedLists/LinkedListReversal.py): In-place reversal
- [Nth to Last Node](LinkedLists/LinkedListNthToLastNode.py): Find the $n$-th node from the end
- [Singly Linked List](LinkedLists/SingleLinkedListImple.py) $O(1)$ insertion, $O(n)$ access & [Doubly Linked List](LinkedLists/DoublyLinkedListImple.py) $O(1)$ insertion/deletion
- [Cycle Detection](LinkedLists/SinglyLinkedListCycleCheckImple.py): Detect cycles in $O(n)$ time using Floyd's algorithm
- [Reverse Linked List](LinkedLists/LinkedListReversal.py): In-place reversal in $O(n)$
- [Nth to Last Node](LinkedLists/LinkedListNthToLastNode.py): Find the $n$-th node from the end in $O(n)$

### Stacks 📚
LIFO (Last-In-First-Out) data structures.
- [Stack Implementation](Stacks/StackImple.py): Basic operations (push, pop, peek)
- [Balanced Parentheses](Stacks/BalanceParenthlessCheckImple.py): Check for balanced brackets using a stack
- [Stack Implementation](Stacks/StackImple.py): Basic operations (push, pop, peek) in $O(1)$
- [Balanced Parentheses](Stacks/BalanceParenthlessCheckImple.py): Check for balanced brackets in $O(n)$ using a stack

### Queues 📦
FIFO (First-In-First-Out) data structures.
- [Queue Implementation](Queues/QueueImple.py): Basic operations (enqueue, dequeue)
- [Queue with Two Stacks](Queues/QueueWith2StacksImple.py): Implementing FIFO using LIFO structures
- [Queue Implementation](Queues/QueueImple.py): $O(n)$ enqueue (using `insert(0)`) and $O(1)$ dequeue
- [Queue with Two Stacks](Queues/QueueWith2StacksImple.py): Implementing FIFO in $O(1)$ amortized time

### Deque 🔄
Double-ended queue operations.
- [Deque Implementation](deque/DequeImple.py): Operations at both ends
- [Deque Implementation](Deque/DequeImple.py): $O(1)$ front operations, $O(n)$ rear operations (due to list shifting)

### Trees 🌳
Hierarchical data structures.
- [Binary Search Tree](Trees/BinarySearchTreesImple.py): Complete BST implementation
- [BST Validation](Trees/): [Solution 1 (In-order)](Trees/BinarySearchTreeCheckImpleSol1.py) & [Solution 2 (Range check)](Trees/BinarySearchTreeCheckImpleSol2.py)
- [Binary Search](Trees/): [Iterative](Trees/BinarySearchImple.py) & [Recursive](Trees/BinarySearchRecursiveImple.py)
- [Binary Heap](Trees/BinaryHeapImple.py): Min-heap implementation
- [Tree Traversals](Trees/TreeLevelOrderPrintImple.py): Level order (BFS) printing
- [Trim BST](Trees/TrimBinarySearchTreeImple.py): Keep nodes within a range
- [Binary Search Tree](Trees/BinarySearchTreesImple.py): $O(\log n)$ average, $O(n)$ worst-case for search, insert, delete
- [BST Validation](Trees/): [Solution 1 (In-order)](Trees/BinarySearchTreeCheckImpleSol1.py) $O(n)$ & [Solution 2 (Range check)](Trees/BinarySearchTreeCheckImpleSol2.py) $O(n)$
- [Binary Search](Trees/): [Iterative](Trees/BinarySearchImple.py) $O(\log n)$ & [Recursive](Trees/BinarySearchRecursiveImple.py) $O(\log n)$
- [Binary Heap](Trees/BinaryHeapImple.py): $O(\log n)$ for insert and delete-min
- [Tree Traversals](Trees/TreeLevelOrderPrintImple.py): Level order (BFS) printing in $O(n)$
- [Trim BST](Trees/TrimBinarySearchTreeImple.py): Keep nodes within a range in $O(n)$
- [Tree Representations](Trees/): [Nodes & References](Trees/TreeRepresentationWithNodesReferences.py) & [List of Lists](Trees/buildTreeTest.py)

---
Expand All @@ -144,31 +144,31 @@ Algorithms for arranging elements in order.
- [Bubble Sort](Sorting/BubbleSortImple.py) - $O(n^2)$
- [Selection Sort](Sorting/SelectionSortImple.py) - $O(n^2)$
- [Insertion Sort](Sorting/InsertionSortImple.py) - $O(n^2)$
- [Shell Sort](Sorting/ShellSortImple.py) - $O(n \log n)$
- [Shell Sort](Sorting/ShellSortImple.py) - $O(n^2)$ worst-case
- [Merge Sort](Sorting/MergeSortImple.py) - $O(n \log n)$
- [Quick Sort](Sorting/QuickSortImple.py) - $O(n \log n)$ average

### Recursion & Dynamic Programming 🔀
Solving problems by breaking them into smaller sub-problems.
- [Fibonacci Sequence](Recursion/): [Iterative](Recursion/FibonacciSeqIterative.py), [Recursive](Recursion/FibonacciSeqRecursion.py), & [Dynamic Programming](Recursion/FibonacciSeqDynamic.py)
- [Coin Change Problem](Recursion/): [Recursive](Recursion/CoinChangeProblemRecursion.py) & [Dynamic Programming](Recursion/CoinChangeProblemDynamic.py)
- [String Operations](Recursion/): [Reverse](Recursion/RecursionReverseStr.py) & [Permutations](Recursion/RecursionStrPermutation.py)
- [Math Operations](Recursion/): [Cumulative Sum](Recursion/RecursionCumulativeSum.py) & [Sum of Digits](Recursion/RecursionSumOfDigits.py)
- [Word Split](Recursion/RecursionWordSplit.py): Dynamic Programming solution
- [Fibonacci Sequence](Recursion/): [Iterative](Recursion/FibonacciSeqIterative.py) $O(n)$, [Recursive](Recursion/FibonacciSeqRecursion.py) $O(2^n)$, & [Dynamic Programming](Recursion/FibonacciSeqDynamic.py) $O(n)$
- [Coin Change Problem](Recursion/): [Recursive](Recursion/CoinChangeProblemRecursion.py) $O(2^n)$ & [Dynamic Programming](Recursion/CoinChangeProblemDynamic.py) $O(n \cdot m)$
- [String Operations](Recursion/): [Reverse](Recursion/RecursionReverseStr.py) $O(n)$ & [Permutations](Recursion/RecursionStrPermutation.py) $O(n!)$
- [Math Operations](Recursion/): [Cumulative Sum](Recursion/RecursionCumulativeSum.py) $O(n)$ & [Sum of Digits](Recursion/RecursionSumOfDigits.py) $O(n)$
- [Word Split](Recursion/RecursionWordSplit.py): $O(n^2)$ recursive solution

### Graph Algorithms 🗺️
Algorithms for graph traversal and pathfinding.
- [Adjacency List](GraphAlgorithms/AdjacencyListGraphImple.py): Graph ADT implementation
- [Breadth First Search (BFS)](GraphAlgorithms/BFS.py): Word Ladder problem
- [Depth First Search (DFS)](GraphAlgorithms/DFSGeneral.py): General DFS implementation
- [Knight's Tour Problem](GraphAlgorithms/): [Graph Generation](GraphAlgorithms/TheKnightsTourProblem.py) & [DFS Solution](GraphAlgorithms/DFSImpleTheKnightsTourProblem.py)
- [Word Ladder Problem](GraphAlgorithms/WordLadderProblem.py): Building the word ladder graph
- [Adjacency List](GraphAlgorithms/AdjacencyListGraphImple.py): $O(1)$ to add vertex, $O(1)$ to add edge
- [Breadth First Search (BFS)](GraphAlgorithms/BFS.py): Word Ladder problem in $O(V+E)$
- [Depth First Search (DFS)](GraphAlgorithms/DFSGeneral.py): General DFS implementation in $O(V+E)$
- [Knight's Tour Problem](GraphAlgorithms/): [Graph Generation](GraphAlgorithms/TheKnightsTourProblem.py) & [DFS Solution](GraphAlgorithms/DFSImpleTheKnightsTourProblem.py) in $O(k^N)$ where $k$ is branching factor
- [Word Ladder Problem](GraphAlgorithms/WordLadderProblem.py): Building the word ladder graph in $O(n \cdot k^2)$ where $k$ is word length

---

## ⚠️ Error Handling & Debugging

- [Error and Exceptions](Error-debug/ErrorExceptions.py): Demonstrates `try`, `except`, `else`, and `finally` blocks for robust error handling.
- [Error and Exceptions](ErrorHandling/ErrorExceptions.py): Demonstrates `try`, `except`, `else`, and `finally` blocks for robust error handling.

---

Expand Down
Loading