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
13 changes: 13 additions & 0 deletions Arrays/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Arrays

This directory contains Python implementations of common array-based algorithms.

## Contents

- [Anagram Check](Anagram_Check_Sorted_Sol.py) - Checks if two strings are anagrams of each other (Sorted solution).
- [Anagram Check (Manual)](Anagram_Check_manual_Sol.py) - Checks if two strings are anagrams of each other (Manual frequency count).
- [Array Pair Sum](ArrayPairSumSol.py) - Given an integer array, output all unique pairs that sum up to a specific value `k`.
- [Find Missing Element (XOR)](ArrayFindTheMissingElement_XOR_sol.py) - Find the missing element using XOR.
- [Find Missing Element (Brute Force)](ArrayFindTheMissingElement_brute_force_sol.py) - Find the missing element using brute force.
- [Find Missing Element (Hash Table)](ArrayFindTheMissingElement_hash_table_sol.py) - Find the missing element using a hash table.
- [Find Missing Element (Sum)](ArrayFindTheMissingElement_takingSumandSubtract_sol.py) - Find the missing element by comparing sums.
7 changes: 7 additions & 0 deletions Error-debug/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Error Handling and Debugging

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

## Contents

- [Basic Exception Handling](ErrorExceptions.py) - Demonstrates `try-except-else-finally` blocks and user input validation.
12 changes: 12 additions & 0 deletions GraphAlgorithms/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Graph Algorithms

This directory contains Python implementations of common graph algorithms.

## Contents

- [Adjacency List Implementation](AdjacencyListGraphImple.py) - Basic graph representation using an adjacency list.
- [Breadth First Search (BFS)](BFS.py) - Breadth First Search implementation, applied to the Word Ladder problem.
- [Word Ladder Problem](WordLadderProblem.py) - Implementation specifically for the Word Ladder problem.
- [Depth First Search (DFS)](DFSGeneral.py) - General implementation of Depth First Search.
- [Knight's Tour Problem (DFS)](TheKnightsTourProblem.py) - Depth First Search implementation for the Knight's Tour problem.
- [Knight's Tour Problem Implementation](DFSImpleTheKnightsTourProblem.py) - Detailed DFS implementation specifically for the Knight's Tour.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Pradeep K. Pant

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
11 changes: 11 additions & 0 deletions LinkedLists/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Linked Lists

This directory contains Python implementations of common linked list operations and algorithms.

## Contents

- [Singly Linked List Implementation](SingleLinkedListImple.py) - Basic skeleton for a Singly Linked List.
- [Doubly Linked List Implementation](DoublyLinkedListImple.py) - Basic skeleton for a Doubly Linked List.
- [Singly Linked List Cycle Check](SinglyLinkedListCycleCheckImple.py) - Check if a singly linked list contains a cycle using the "two runners" (slow and fast pointers) strategy.
- [Reverse a Linked List](LinkedListReversal.py) - Reverse a linked list in-place.
- [Nth to Last Node](LinkedListNthToLastNode.py) - Find the nth to last node in a linked list.
8 changes: 8 additions & 0 deletions Queues/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Queues

This directory contains Python implementations of queue-based data structures.

## Contents

- [Queue Implementation](QueueImple.py) - Basic queue operations (FIFO): `enqueue`, `dequeue`, `isEmpty`, `size`.
- [Queue with Two Stacks](QueueWith2StacksImple.py) - Implement a queue using two stacks.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ This repository contains a collection of common programming problems and data st
- [Sorting](#sorting)
- [Graph Algorithms](#graph-algorithms)
- [Error Handling](#error-handling)
- [Usage](#usage)
- [Acknowledgments](#acknowledgments)
- [License](#license)

---

Expand Down Expand Up @@ -149,6 +151,10 @@ Implementing a tree using classes and references.
Print a binary tree in level order.
- **File**: `Trees/TreeLevelOrderPrintImple.py`

### Tree Representation (List of Lists)
Implementing a tree using list of lists.
- **File**: `Trees/buildTreeTest.py`

---

## Sorting
Expand Down Expand Up @@ -204,7 +210,22 @@ Demonstrates `try-except-else-finally` blocks and user input validation.

---

## Usage
Most of the scripts can be run directly using Python 3:

```bash
python3 path/to/script.py
```

For example:
```bash
python3 Arrays/Anagram_Check_Sorted_Sol.py
```

## Acknowledgments
- [Python for Data Structures, Algorithms, and Interviews on Udemy](https://www.udemy.com)
- [Problem Solving with Algorithms and Data Structures using Python](http://interactivepython.org/runestone/static/pythonds/index.html)
- [Big O Notation - Plain English Explanation](https://stackoverflow.com/questions/487258/what-is-a-plain-english-explanation-of-big-o-notation/487278#487278)

## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
16 changes: 16 additions & 0 deletions Recursion/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Recursion

This directory contains Python implementations of various recursive algorithms.

## Contents

- [Cumulative Sum](RecursionCumulativeSum.py) - Compute the cumulative sum from 0 to `n`.
- [Sum of Digits](RecursionSumOfDigits.py) - Returns the sum of all individual digits in an integer.
- [Word Split](RecursionWordSplit.py) - Determine if a string can be split into words found in a given list.
- [Reverse a String](RecursionReverseStr.py) - Recursive implementation to reverse a string.
- [String Permutations](RecursionStrPermutation.py) - Output all possible permutations of a string.
- [Fibonacci Sequence (Iterative)](FibonacciSeqIterative.py) - Iterative Fibonacci implementation.
- [Fibonacci Sequence (Recursive)](FibonacciSeqRecursion.py) - Recursive Fibonacci implementation.
- [Fibonacci Sequence (Dynamic Programming)](FibonacciSeqDynamic.py) - Fibonacci implementation using memoization.
- [Coin Change Problem (Recursion)](CoinChangeProblemRecursion.py) - Find fewest coins needed using simple recursion.
- [Coin Change Problem (Dynamic Programming)](CoinChangeProblemDynamic.py) - Find fewest coins needed using dynamic programming.
12 changes: 12 additions & 0 deletions Sorting/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Sorting Algorithms

This directory contains implementations of various sorting algorithms in Python.

## Contents

- [Bubble Sort](BubbleSortImple.py) - Complexity $O(n^2)$ worst and average case, $O(n)$ best case.
- [Selection Sort](SelectionSortImple.py) - Complexity $O(n^2)$ for all cases.
- [Insertion Sort](InsertionSortImple.py) - Complexity $O(n^2)$ worst and average case, $O(n)$ best case.
- [Merge Sort](MergeSortImple.py) - Complexity $O(n \log n)$ for all cases.
- [Quick Sort](QuickSortImple.py) - Complexity $O(n^2)$ worst case, $O(n \log n)$ average/best case.
- [Shell Sort](ShellSortImple.py) - Complexity between $O(n)$ and $O(n^2)$ depending on increment sequence.
8 changes: 8 additions & 0 deletions Stacks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Stacks

This directory contains Python implementations of stack-based algorithms.

## Contents

- [Stack Implementation](StackImple.py) - Basic stack operations (LIFO): `push`, `pop`, `peek`, `isEmpty`, `size`.
- [Balanced Parentheses Check](BalanceParenthlessCheckImple.py) - Check if a string of opening and closing parentheses is balanced.
16 changes: 16 additions & 0 deletions Trees/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Tree Algorithms

This directory contains Python implementations of common tree algorithms and data structures.

## Contents

- [Binary Search Tree Implementation](BinarySearchTreesImple.py) - Basic operations for a Binary Search Tree.
- [Binary Heap Implementation](BinaryHeapImple.py) - Implementation of a Binary Heap.
- [Binary Search](BinarySearchImple.py) - Recursive and iterative binary search.
- [Binary Search (Recursive)](BinarySearchRecursiveImple.py) - Dedicated recursive binary search implementation.
- [Validate BST (Sol 1)](BinarySearchTreeCheckImpleSol1.py) - Check if a binary tree is a valid Binary Search Tree (Sol 1).
- [Validate BST (Sol 2)](BinarySearchTreeCheckImpleSol2.py) - Check if a binary tree is a valid Binary Search Tree (Sol 2).
- [Trim a BST](TrimBinarySearchTreeImple.py) - Trim a BST so all nodes are within a given range `[min, max]`.
- [Tree Representation (Nodes & References)](TreeRepresentationWithNodesReferences.py) - Implementing a tree using classes and references.
- [Tree Level Order Print](TreeLevelOrderPrintImple.py) - Print a binary tree in level order.
- [Tree Representation (List of Lists)](buildTreeTest.py) - Implementing a tree using list of lists.
7 changes: 7 additions & 0 deletions deque/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Deque

This directory contains Python implementations of double-ended queues.

## Contents

- [Deque Implementation](DequeImple.py) - Double-ended queue operations: `addFront`, `addRear`, `removeFront`, `removeRear`, `isEmpty`, `size`.