diff --git a/Arrays/README.md b/Arrays/README.md new file mode 100644 index 0000000..00d1bc4 --- /dev/null +++ b/Arrays/README.md @@ -0,0 +1,20 @@ +# Arrays + +This directory contains Python implementations of common array-related algorithms and problems. + +## Contents + +### Anagram Check +Checks if two strings are anagrams of each other. +- [Anagram_Check_Sorted_Sol.py](Anagram_Check_Sorted_Sol.py): Easy and direct solution using sorting. +- [Anagram_Check_manual_Sol.py](Anagram_Check_manual_Sol.py): Manual implementation using a dictionary to count character frequencies. + +### Array Pair Sum +- [ArrayPairSumSol.py](ArrayPairSumSol.py): Given an integer array, output all unique pairs that sum up to a specific value `k`. + +### Find Missing Element +Find the missing element in a shuffled second array. +- [ArrayFindTheMissingElement_XOR_sol.py](ArrayFindTheMissingElement_XOR_sol.py): Using XOR logic. +- [ArrayFindTheMissingElement_brute_force_sol.py](ArrayFindTheMissingElement_brute_force_sol.py): Brute force approach. +- [ArrayFindTheMissingElement_hash_table_sol.py](ArrayFindTheMissingElement_hash_table_sol.py): Using a hash table/dictionary. +- [ArrayFindTheMissingElement_takingSumandSubtract_sol.py](ArrayFindTheMissingElement_takingSumandSubtract_sol.py): Using the difference of sums. diff --git a/Error-debug/README.md b/Error-debug/README.md new file mode 100644 index 0000000..fda8bcc --- /dev/null +++ b/Error-debug/README.md @@ -0,0 +1,7 @@ +# Error and Exception Handling + +This directory contains examples and scripts for handling errors and exceptions in Python. + +## Contents + +- [ErrorExceptions.py](ErrorExceptions.py): Demonstrates `try-except-else-finally` blocks and common error-handling practices, such as validating user input. diff --git a/GraphAlgorithms/README.md b/GraphAlgorithms/README.md new file mode 100644 index 0000000..6d2d877 --- /dev/null +++ b/GraphAlgorithms/README.md @@ -0,0 +1,12 @@ +# Graph Algorithms + +This directory contains implementations of fundamental graph algorithms and their application to specific problems. + +## Contents + +- [AdjacencyListGraphImple.py](AdjacencyListGraphImple.py): Implementation of an adjacency list graph representation. +- [BFS.py](BFS.py): Breadth-First Search (BFS) implementation. +- [DFSGeneral.py](DFSGeneral.py): A general implementation of Depth-First Search (DFS). +- [TheKnightsTourProblem.py](TheKnightsTourProblem.py): Modeling the Knight's Tour problem as a graph. +- [DFSImpleTheKnightsTourProblem.py](DFSImpleTheKnightsTourProblem.py): Solving the Knight's Tour problem using DFS. +- [WordLadderProblem.py](WordLadderProblem.py): Solving the Word Ladder problem using BFS and graphs. diff --git a/LinkedLists/README.md b/LinkedLists/README.md new file mode 100644 index 0000000..65dd4a3 --- /dev/null +++ b/LinkedLists/README.md @@ -0,0 +1,14 @@ +# Linked Lists + +This directory contains implementations of singly and doubly linked list data structures and related algorithms. + +## Contents + +### Implementations +- [SingleLinkedListImple.py](SingleLinkedListImple.py): Basic skeleton for a Singly Linked List. +- [DoublyLinkedListImple.py](DoublyLinkedListImple.py): Basic skeleton for a Doubly Linked List. + +### Algorithms +- [SinglyLinkedListCycleCheckImple.py](SinglyLinkedListCycleCheckImple.py): Check if a singly linked list contains a cycle using the "two runners" (slow and fast pointers) strategy (Floyd's Cycle-Finding Algorithm). +- [LinkedListReversal.py](LinkedListReversal.py): Reverse a linked list in-place. +- [LinkedListNthToLastNode.py](LinkedListNthToLastNode.py): Find the nth to last node in a linked list. diff --git a/Queues/README.md b/Queues/README.md new file mode 100644 index 0000000..a64142b --- /dev/null +++ b/Queues/README.md @@ -0,0 +1,8 @@ +# Queues + +This directory contains implementations of queue data structures. + +## Contents + +- [QueueImple.py](QueueImple.py): Basic queue operations (FIFO): `enqueue`, `dequeue`, `isEmpty`, `size`. +- [QueueWith2StacksImple.py](QueueWith2StacksImple.py): Implementing a queue using two stacks for enqueue and dequeue operations. diff --git a/Recursion/README.md b/Recursion/README.md new file mode 100644 index 0000000..f1d1ad8 --- /dev/null +++ b/Recursion/README.md @@ -0,0 +1,21 @@ +# Recursion + +This directory contains recursive implementations of common algorithms and mathematical problems. + +## Contents + +### Basic Recursion +- [RecursionCumulativeSum.py](RecursionCumulativeSum.py): Compute the cumulative sum from 0 to `n`. +- [RecursionSumOfDigits.py](RecursionSumOfDigits.py): Returns the sum of all individual digits in an integer. +- [RecursionWordSplit.py](RecursionWordSplit.py): Determine if a string can be split into words found in a given list. +- [RecursionReverseStr.py](RecursionReverseStr.py): Recursive implementation to reverse a string. +- [RecursionStrPermutation.py](RecursionStrPermutation.py): Output all possible permutations of a string. + +### Fibonacci Sequence +- [FibonacciSeqIterative.py](FibonacciSeqIterative.py): Iterative implementation of Fibonacci. +- [FibonacciSeqRecursion.py](FibonacciSeqRecursion.py): Recursive implementation of Fibonacci. +- [FibonacciSeqDynamic.py](FibonacciSeqDynamic.py): Dynamic programming (memoization) implementation of Fibonacci. + +### Coin Change Problem +- [CoinChangeProblemRecursion.py](CoinChangeProblemRecursion.py): Recursive implementation. +- [CoinChangeProblemDynamic.py](CoinChangeProblemDynamic.py): Dynamic programming implementation to find the fewest coins needed for change. diff --git a/Sorting/README.md b/Sorting/README.md new file mode 100644 index 0000000..4e6e2c5 --- /dev/null +++ b/Sorting/README.md @@ -0,0 +1,12 @@ +# Sorting Algorithms + +This directory contains Python implementations of fundamental sorting algorithms and their time complexity analyses. + +## Contents + +- [BubbleSortImple.py](BubbleSortImple.py): Bubble Sort. Complexity: $O(n^2)$ worst/average case, $O(n)$ best case. +- [SelectionSortImple.py](SelectionSortImple.py): Selection Sort. Complexity: $O(n^2)$ for all cases. +- [InsertionSortImple.py](InsertionSortImple.py): Insertion Sort. Complexity: $O(n^2)$ worst/average case, $O(n)$ best case. +- [MergeSortImple.py](MergeSortImple.py): Merge Sort. Complexity: $O(n \log n)$ for all cases. +- [QuickSortImple.py](QuickSortImple.py): Quick Sort. Complexity: $O(n^2)$ worst case, $O(n \log n)$ average/best case. +- [ShellSortImple.py](ShellSortImple.py): Shell Sort. Complexity: Between $O(n)$ and $O(n^2)$ depending on the increment sequence. diff --git a/Stacks/README.md b/Stacks/README.md new file mode 100644 index 0000000..419b443 --- /dev/null +++ b/Stacks/README.md @@ -0,0 +1,11 @@ +# Stacks + +This directory contains implementations of stack data structures and related algorithms. + +## Contents + +### Implementation +- [StackImple.py](StackImple.py): Basic stack operations (LIFO): `push`, `pop`, `peek`, `isEmpty`, `size`. + +### Algorithms +- [BalanceParenthlessCheckImple.py](BalanceParenthlessCheckImple.py): Check if a string of opening and closing parentheses is balanced using a stack. diff --git a/Trees/README.md b/Trees/README.md new file mode 100644 index 0000000..5bc22be --- /dev/null +++ b/Trees/README.md @@ -0,0 +1,19 @@ +# Trees + +This directory contains implementations of binary trees, heaps, and tree-related search and validation algorithms. + +## Contents + +### Binary Trees & Heaps +- [BinarySearchTreesImple.py](BinarySearchTreesImple.py): Implementation of a Binary Search Tree (BST). +- [BinaryHeapImple.py](BinaryHeapImple.py): Implementation of a Binary Heap. +- [TreeRepresentationWithNodesReferences.py](TreeRepresentationWithNodesReferences.py): Basic tree structure using nodes and references. +- [buildTreeTest.py](buildTreeTest.py): Building a tree and inserting nodes using a list-of-lists approach. + +### Search and Validation +- [BinarySearchImple.py](BinarySearchImple.py): Iterative implementation of Binary Search. +- [BinarySearchRecursiveImple.py](BinarySearchRecursiveImple.py): Recursive implementation of Binary Search. +- [BinarySearchTreeCheckImpleSol1.py](BinarySearchTreeCheckImpleSol1.py): Validating a BST using recursive properties. +- [BinarySearchTreeCheckImpleSol2.py](BinarySearchTreeCheckImpleSol2.py): Validating a BST using in-order traversal logic. +- [TrimBinarySearchTreeImple.py](TrimBinarySearchTreeImple.py): Trimming a BST so all nodes are within a given range `[min, max]`. +- [TreeLevelOrderPrintImple.py](TreeLevelOrderPrintImple.py): Printing a binary tree in level order. diff --git a/deque/README.md b/deque/README.md new file mode 100644 index 0000000..3236cb5 --- /dev/null +++ b/deque/README.md @@ -0,0 +1,7 @@ +# Deque (Double-Ended Queue) + +This directory contains the implementation of a deque data structure. + +## Contents + +- [DequeImple.py](DequeImple.py): Implementation of a double-ended queue, supporting operations: `addFront`, `addRear`, `removeFront`, `removeRear`, `isEmpty`, `size`.