diff --git a/Arrays/Anagram_Check_manual_Sol.py b/Arrays/AnagramCheckManualSol.py similarity index 100% rename from Arrays/Anagram_Check_manual_Sol.py rename to Arrays/AnagramCheckManualSol.py diff --git a/Arrays/Anagram_Check_Sorted_Sol.py b/Arrays/AnagramCheckSortedSol.py similarity index 100% rename from Arrays/Anagram_Check_Sorted_Sol.py rename to Arrays/AnagramCheckSortedSol.py diff --git a/Arrays/ArrayFindTheMissingElement_brute_force_sol.py b/Arrays/ArrayFindTheMissingElementBruteForceSol.py similarity index 100% rename from Arrays/ArrayFindTheMissingElement_brute_force_sol.py rename to Arrays/ArrayFindTheMissingElementBruteForceSol.py diff --git a/Arrays/ArrayFindTheMissingElement_hash_table_sol.py b/Arrays/ArrayFindTheMissingElementHashTableSol.py similarity index 100% rename from Arrays/ArrayFindTheMissingElement_hash_table_sol.py rename to Arrays/ArrayFindTheMissingElementHashTableSol.py diff --git a/Arrays/ArrayFindTheMissingElement_takingSumandSubtract_sol.py b/Arrays/ArrayFindTheMissingElementSumSol.py similarity index 100% rename from Arrays/ArrayFindTheMissingElement_takingSumandSubtract_sol.py rename to Arrays/ArrayFindTheMissingElementSumSol.py diff --git a/Arrays/ArrayFindTheMissingElement_XOR_sol.py b/Arrays/ArrayFindTheMissingElementXORSol.py similarity index 100% rename from Arrays/ArrayFindTheMissingElement_XOR_sol.py rename to Arrays/ArrayFindTheMissingElementXORSol.py diff --git a/Arrays/README.md b/Arrays/README.md index 707a82e..d225aa4 100644 --- a/Arrays/README.md +++ b/Arrays/README.md @@ -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. -- [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. +- [Anagram Check (Sorted Solution)](AnagramCheckSortedSol.py): Checks if two strings are anagrams by comparing their sorted versions. Time Complexity: $O(n \log n)$. +- [Anagram Check (Manual Solution)](AnagramCheckManualSol.py): Checks if two strings are anagrams using a hash table (dictionary) to count character frequencies. Time Complexity: $O(n)$. +- [Array Find Missing Element (XOR Solution)](ArrayFindTheMissingElementXORSol.py): Efficiently finds a missing element in a shuffled array using bitwise XOR. Time Complexity: $O(n)$. +- [Array Find Missing Element (Brute Force Solution)](ArrayFindTheMissingElementBruteForceSol.py): Finds a missing element by sorting both arrays and comparing them. Time Complexity: $O(n \log n)$. +- [Array Find Missing Element (Hash Table Solution)](ArrayFindTheMissingElementHashTableSol.py): Finds a missing element using a hash table (dictionary) to track element counts. Time Complexity: $O(n)$. +- [Array Find Missing Element (Sum/Subtract Solution)](ArrayFindTheMissingElementSumSol.py): Finds a missing element by calculating the difference between the sums of the two arrays. Time Complexity: $O(n)$. +- [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. Time Complexity: $O(n)$. diff --git a/deque/DequeImple.py b/Deque/DequeImple.py similarity index 100% rename from deque/DequeImple.py rename to Deque/DequeImple.py diff --git a/deque/README.md b/Deque/README.md similarity index 70% rename from deque/README.md rename to Deque/README.md index 046a17f..068909a 100644 --- a/deque/README.md +++ b/Deque/README.md @@ -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`, and `size`. diff --git a/Error-debug/README.md b/Error-debug/README.md deleted file mode 100644 index c8bc4d4..0000000 --- a/Error-debug/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Error and Debugging - -This directory contains examples of error handling and debugging techniques in Python. - -## Contents - -- [Error and Exceptions](ErrorExceptions.py): Demonstrates the use of `try`, `except`, `else`, and `finally` blocks for robust error handling, specifically validating integer user input. diff --git a/Error-debug/ErrorExceptions.py b/ErrorHandling/ErrorExceptions.py similarity index 100% rename from Error-debug/ErrorExceptions.py rename to ErrorHandling/ErrorExceptions.py diff --git a/ErrorHandling/README.md b/ErrorHandling/README.md new file mode 100644 index 0000000..bc70352 --- /dev/null +++ b/ErrorHandling/README.md @@ -0,0 +1,7 @@ +# Error Handling + +This directory contains examples demonstrating error handling and debugging in Python. + +## Contents + +- [Error and Exceptions](ErrorExceptions.py): Demonstrates the use of `try`, `except`, `else`, and `finally` blocks to handle various types of errors and ensure robust program execution. diff --git a/GraphAlgorithms/README.md b/GraphAlgorithms/README.md index f0330f8..4302d99 100644 --- a/GraphAlgorithms/README.md +++ b/GraphAlgorithms/README.md @@ -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. -- [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. +- [Adjacency List Implementation](AdjacencyListGraphImple.py): Implements the Graph Abstract Data Type (ADT) using an adjacency list (dictionaries in Python). Includes `Vertex` and `Graph` classes. Time Complexity: $O(V+E)$. +- [Breadth First Search (BFS)](BFS.py): Implements BFS to solve the Word Ladder problem, finding the shortest transformation path between words. Time Complexity: $O(V+E)$. +- [General Depth First Search (DFS)](DFSGeneral.py): Provides a general implementation of DFS, including discovery and finish times for vertices. Time Complexity: $O(V+E)$. +- [DFS - Knight's Tour Problem](DFSImpleTheKnightsTourProblem.py): Another implementation of DFS specifically tailored to the Knight's Tour puzzle. Time Complexity: $O(k^N)$. +- [The Knight's Tour Problem](TheKnightsTourProblem.py): Focuses on generating the knight's move graph and solving the tour using DFS and backtracking. Time Complexity: $O(k^N)$. +- [Word Ladder Problem](WordLadderProblem.py): Specifically focuses on building the word ladder graph where edges connect words that differ by only one letter. Time Complexity: $O(V+E)$. diff --git a/LinkedLists/README.md b/LinkedLists/README.md index bead21d..9b860b2 100644 --- a/LinkedLists/README.md +++ b/LinkedLists/README.md @@ -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](SinglyLinkedListImple.py): Basic implementation of a singly linked list node and basic linkage. Time Complexity: $O(1)$. +- [Doubly Linked List Implementation](DoublyLinkedListImple.py): Basic implementation of a doubly linked list node with `prev` and `next` pointers. Time Complexity: $O(1)$. +- [Singly Linked List Cycle Check](SinglyLinkedListCycleCheckImple.py): Implements Floyd's Cycle-Finding Algorithm (two pointers) to detect cycles in a linked list. Time Complexity: $O(n)$. +- [Linked List Reversal](LinkedListReversal.py): Reverses a singly linked list in-place. Time Complexity: $O(n)$. +- [Nth to Last Node](LinkedListNthToLastNode.py): Finds the $n$-th to last node in a singly linked list using two pointers. Time Complexity: $O(n)$. diff --git a/LinkedLists/SingleLinkedListImple.py b/LinkedLists/SinglyLinkedListImple.py similarity index 100% rename from LinkedLists/SingleLinkedListImple.py rename to LinkedLists/SinglyLinkedListImple.py diff --git a/Queues/README.md b/Queues/README.md index a1c90d0..8d2c5c3 100644 --- a/Queues/README.md +++ b/Queues/README.md @@ -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)`), `dequeue` ($O(1)$), `isEmpty`, and `size` methods. +- [Queue with Two Stacks](QueueWith2StacksImple.py): Implements a queue using two stacks (represented by Python lists) to achieve FIFO behavior. Time Complexity: $O(1)$ amortized. diff --git a/README.md b/README.md index b8de7d5..fc159cc 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ Most scripts in this repository are standalone and can be executed directly: ```bash # Run any Python script -python3 Arrays/Anagram_Check_Sorted_Sol.py +python3 Arrays/AnagramCheckSortedSol.py # Or run from the repo root python3 Sorting/BubbleSortImple.py @@ -80,7 +80,8 @@ 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) @@ -88,7 +89,6 @@ python3 Sorting/BubbleSortImple.py β”œβ”€β”€ 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 @@ -100,13 +100,13 @@ 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 +- [Anagram Check](Arrays/): [Sorted](Arrays/AnagramCheckSortedSol.py) & [Manual](Arrays/AnagramCheckManualSol.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 +- [Find Missing Element](Arrays/): [XOR](Arrays/ArrayFindTheMissingElementXORSol.py), [Brute Force](Arrays/ArrayFindTheMissingElementBruteForceSol.py), [Hash Table](Arrays/ArrayFindTheMissingElementHashTableSol.py), & [Sum](Arrays/ArrayFindTheMissingElementSumSol.py) approaches ### Linked Lists πŸ”— Implementations and problems involving linked structures. -- [Singly Linked List](LinkedLists/SingleLinkedListImple.py) & [Doubly Linked List](LinkedLists/DoublyLinkedListImple.py) +- [Singly Linked List](LinkedLists/SinglyLinkedListImple.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 @@ -114,7 +114,7 @@ Implementations and problems involving linked structures. ### 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 +- [Balanced Parentheses](Stacks/BalanceParenthesesCheckImple.py): Check for balanced brackets using a stack ### Queues πŸ“¦ FIFO (First-In-First-Out) data structures. @@ -123,7 +123,7 @@ FIFO (First-In-First-Out) data structures. ### Deque πŸ”„ Double-ended queue operations. -- [Deque Implementation](deque/DequeImple.py): Operations at both ends +- [Deque Implementation](Deque/DequeImple.py): Operations at both ends ### Trees 🌳 Hierarchical data structures. @@ -133,7 +133,7 @@ Hierarchical data structures. - [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 -- [Tree Representations](Trees/): [Nodes & References](Trees/TreeRepresentationWithNodesReferences.py) & [List of Lists](Trees/buildTreeTest.py) +- [Tree Representations](Trees/): [Nodes & References](Trees/TreeRepresentationWithNodesReferences.py) & [List of Lists](Trees/BuildTreeTest.py) --- @@ -144,7 +144,7 @@ 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)$ - [Merge Sort](Sorting/MergeSortImple.py) - $O(n \log n)$ - [Quick Sort](Sorting/QuickSortImple.py) - $O(n \log n)$ average @@ -168,7 +168,7 @@ Algorithms for graph traversal and pathfinding. ## ⚠️ 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. --- diff --git a/Recursion/README.md b/Recursion/README.md index 7265340..affd207 100644 --- a/Recursion/README.md +++ b/Recursion/README.md @@ -5,17 +5,17 @@ This directory contains Python implementations of problems solved using recursio ## Contents ### Fibonacci Sequence -- [Fibonacci (Iterative)](FibonacciSeqIterative.py): Iterative implementation of the Fibonacci sequence. -- [Fibonacci (Recursive)](FibonacciSeqRecursion.py): Simple recursive implementation of the Fibonacci sequence. -- [Fibonacci (Dynamic Programming)](FibonacciSeqDynamic.py): Optimized Fibonacci sequence using memoization. +- [Fibonacci (Iterative)](FibonacciSeqIterative.py): Iterative implementation of the Fibonacci sequence. Time Complexity: $O(n)$. +- [Fibonacci (Recursive)](FibonacciSeqRecursion.py): Simple recursive implementation of the Fibonacci sequence. Time Complexity: $O(2^n)$. +- [Fibonacci (Dynamic Programming)](FibonacciSeqDynamic.py): Optimized Fibonacci sequence using memoization. Time Complexity: $O(n)$. ### Coin Change Problem -- [Coin Change (Recursive)](CoinChangeProblemRecursion.py): Basic recursive solution to find the minimum number of coins for change. -- [Coin Change (Dynamic Programming)](CoinChangeProblemDynamic.py): Optimized solution to the coin change problem using dynamic programming. +- [Coin Change (Recursive)](CoinChangeProblemRecursion.py): Basic recursive solution to find the minimum number of coins for change. Time Complexity: Exponential. +- [Coin Change (Dynamic Programming)](CoinChangeProblemDynamic.py): Optimized solution to the coin change problem using dynamic programming. Time Complexity: $O(n \cdot m)$. ### Other Recursive Problems -- [Cumulative Sum](RecursionCumulativeSum.py): Computes the cumulative sum from 0 to $n$ recursively. -- [Reverse a String](RecursionReverseStr.py): Reverses a string using recursive calls. -- [String Permutations](RecursionStrPermutation.py): Generates all possible permutations of a given string. -- [Sum of Digits](RecursionSumOfDigits.py): Calculates the sum of all individual digits in an integer recursively. -- [Word Split](RecursionWordSplit.py): Determines if a string can be split into words from a given list. +- [Cumulative Sum](RecursionCumulativeSum.py): Computes the cumulative sum from 0 to $n$ recursively. Time Complexity: $O(n)$. +- [Reverse a String](RecursionReverseStr.py): Reverses a string using recursive calls. Time Complexity: $O(n)$. +- [String Permutations](RecursionStrPermutation.py): Generates all possible permutations of a given string. Time Complexity: $O(n!)$. +- [Sum of Digits](RecursionSumOfDigits.py): Calculates the sum of all individual digits in an integer recursively. Time Complexity: $O(\log_{10} n)$. +- [Word Split](RecursionWordSplit.py): Determines if a string can be split into words from a given list. Time Complexity: $O(n^2)$. diff --git a/Sorting/README.md b/Sorting/README.md index 0b76399..74e35e0 100644 --- a/Sorting/README.md +++ b/Sorting/README.md @@ -4,9 +4,9 @@ This directory contains Python implementations of various sorting algorithms wit ## Contents -- [Bubble Sort](BubbleSortImple.py): Implementation of Bubble Sort with $O(n^2)$ complexity. -- [Selection Sort](SelectionSortImple.py): Implementation of Selection Sort, improving on Bubble Sort by making only one exchange per pass. -- [Insertion Sort](InsertionSortImple.py): Implementation of Insertion Sort, maintaining a sorted sublist. -- [Shell Sort](ShellSortImple.py): Implementation of Shell Sort (diminishing increment sort), improving on Insertion Sort. -- [Merge Sort](MergeSortImple.py): A recursive "divide and conquer" algorithm with $O(n \log n)$ complexity. -- [Quick Sort](QuickSortImple.py): Implementation of Quick Sort (partition exchange sort), using divide and conquer in-place. +- [Bubble Sort](BubbleSortImple.py): Implementation of Bubble Sort. Time Complexity: $O(n^2)$. +- [Selection Sort](SelectionSortImple.py): Implementation of Selection Sort, improving on Bubble Sort by making only one exchange per pass. Time Complexity: $O(n^2)$. +- [Insertion Sort](InsertionSortImple.py): Implementation of Insertion Sort, maintaining a sorted sublist. Time Complexity: $O(n^2)$. +- [Shell Sort](ShellSortImple.py): Implementation of Shell Sort (diminishing increment sort). Time Complexity: $O(n^2)$ (worst case). +- [Merge Sort](MergeSortImple.py): A recursive "divide and conquer" algorithm. Time Complexity: $O(n \log n)$. +- [Quick Sort](QuickSortImple.py): Implementation of Quick Sort (partition exchange sort), using divide and conquer in-place. Time Complexity: $O(n \log n)$ average, $O(n^2)$ worst case. diff --git a/Stacks/BalanceParenthlessCheckImple.py b/Stacks/BalanceParenthesesCheckImple.py similarity index 100% rename from Stacks/BalanceParenthlessCheckImple.py rename to Stacks/BalanceParenthesesCheckImple.py diff --git a/Stacks/README.md b/Stacks/README.md index e799a74..b69d45c 100644 --- a/Stacks/README.md +++ b/Stacks/README.md @@ -1,8 +1,8 @@ # Stacks -This directory contains Python implementations of the Stack data structure and its applications. +This directory contains Python implementations of the Stack data structure. ## Contents -- [Stack Implementation](StackImple.py): Basic implementation of a LIFO (Last-In-First-Out) stack using a Python list. Includes `push`, `pop`, `peek`, `isEmpty`, and `size` methods. -- [Balanced Parentheses Check](BalanceParenthlessCheckImple.py): Uses a stack to check if a string of opening and closing parentheses (round, square, and curly) is balanced. +- [Stack Implementation](StackImple.py): Basic implementation of a LIFO (Last-In-First-Out) stack using a Python list. Includes `push`, `pop`, `peek`, `isEmpty`, and `size` methods. Time Complexity: $O(1)$. +- [Balanced Parentheses](BalanceParenthesesCheckImple.py): Checks for balanced brackets in a string using a stack. Time Complexity: $O(n)$. diff --git a/Trees/buildTreeTest.py b/Trees/BuildTreeTest.py similarity index 100% rename from Trees/buildTreeTest.py rename to Trees/BuildTreeTest.py diff --git a/Trees/README.md b/Trees/README.md index 2047225..7ad36a5 100644 --- a/Trees/README.md +++ b/Trees/README.md @@ -4,20 +4,13 @@ This directory contains Python implementations of various tree-based data struct ## Contents -### Binary Search Trees (BST) -- [Binary Search Tree Implementation](BinarySearchTreesImple.py): A comprehensive implementation of a BST with `TreeNode` and `BinarySearchTree` classes, including insertion, deletion, and search. -- [Validate BST (Solution 1)](BinarySearchTreeCheckImpleSol1.py): Validates a BST by performing an in-order traversal and checking if the resulting values are sorted. -- [Validate BST (Solution 2)](BinarySearchTreeCheckImpleSol2.py): Validates a BST by keeping track of the minimum and maximum allowable values for each node. -- [Trim a BST](TrimBinarySearchTreeImple.py): Trims a BST so that all node values fall within a specified range $[min, max]$. - -### Search Algorithms -- [Binary Search (Iterative)](BinarySearchImple.py): Iterative implementation of the binary search algorithm on a sorted list. -- [Binary Search (Recursive)](BinarySearchRecursiveImple.py): Recursive implementation of the binary search algorithm. - -### Heaps -- [Binary Heap Implementation](BinaryHeapImple.py): Implements a min-heap using a recursive approach, including `insert`, `delMin`, and `buildHeap`. - -### Tree Representations & Traversals -- [Nodes and References Representation](TreeRepresentationWithNodesReferences.py): A simple implementation of a binary tree using a class-based nodes and references approach. -- [List of Lists Representation](buildTreeTest.py): Demonstrates building and manipulating a tree using a "list of lists" approach. -- [Tree Level Order Print](TreeLevelOrderPrintImple.py): Prints a binary tree in level order (breadth-first) using a queue, with each level on a new line. +- [Binary Heap Implementation](BinaryHeapImple.py): Implementation of a binary heap (Min-Heap). Time Complexity: $O(\log n)$. +- [Binary Search (Iterative)](BinarySearchImple.py): Standard iterative binary search algorithm. Time Complexity: $O(\log n)$. +- [Binary Search (Recursive)](BinarySearchRecursiveImple.py): Recursive implementation of binary search. Time Complexity: $O(\log n)$. +- [BST Validation (Solution 1)](BinarySearchTreeCheckImpleSol1.py): Validates if a binary tree is a Binary Search Tree using in-order traversal. Time Complexity: $O(n)$. +- [BST Validation (Solution 2)](BinarySearchTreeCheckImpleSol2.py): Validates if a binary tree is a Binary Search Tree by checking if each node falls within a specific range. Time Complexity: $O(n)$. +- [Binary Search Tree Implementation](BinarySearchTreesImple.py): Complete implementation of a Binary Search Tree. Time Complexity: Average $O(\log n)$, Worst Case $O(n)$. +- [Tree Level Order Print](TreeLevelOrderPrintImple.py): Prints nodes of a tree level by level using a queue. Time Complexity: $O(n)$. +- [Trim Binary Search Tree](TrimBinarySearchTreeImple.py): Trims a BST so all its elements are within a given range $[L, R]$. Time Complexity: $O(n)$. +- [Tree Representation (Nodes & References)](TreeRepresentationWithNodesReferences.py): Simple implementation of a tree using a class-based approach. +- [Tree Representation (List of Lists)](BuildTreeTest.py): Implementation of a tree using the "list of lists" technique.