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

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

## Contents

- **Anagram Check**: Checks if two strings are anagrams of each other.
- [Anagram_Check_Sorted_Sol.py](Anagram_Check_Sorted_Sol.py)
- [Anagram_Check_manual_Sol.py](Anagram_Check_manual_Sol.py)
- **Array Pair Sum**: Given an integer array, output all unique pairs that sum up to a specific value `k`.
- [ArrayPairSumSol.py](ArrayPairSumSol.py)
- **Find Missing Element**: Find the missing element in a shuffled second array.
- [ArrayFindTheMissingElement_XOR_sol.py](ArrayFindTheMissingElement_XOR_sol.py)
- [ArrayFindTheMissingElement_brute_force_sol.py](ArrayFindTheMissingElement_brute_force_sol.py)
- [ArrayFindTheMissingElement_hash_table_sol.py](ArrayFindTheMissingElement_hash_table_sol.py)
- [ArrayFindTheMissingElement_takingSumandSubtract_sol.py](ArrayFindTheMissingElement_takingSumandSubtract_sol.py)
8 changes: 8 additions & 0 deletions Error-debug/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Error Handling and Debugging

This directory demonstrates common error handling and debugging techniques in Python.

## Contents

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

This directory contains Python implementations of common graph-based algorithms and data structures.

## Contents

- **Adjacency List Implementation**: [AdjacencyListGraphImple.py](AdjacencyListGraphImple.py)
- **Breadth First Search (BFS)**: [BFS.py](BFS.py)
- **Word Ladder Problem**: Using BFS to solve the word ladder problem. [WordLadderProblem.py](WordLadderProblem.py)
- **Depth First Search (DFS)**:
- [DFSImpleTheKnightsTourProblem.py](DFSImpleTheKnightsTourProblem.py)
- [DFSGeneral.py](DFSGeneral.py)
- **Knight's Tour Problem**: [TheKnightsTourProblem.py](TheKnightsTourProblem.py)
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) 2017 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 structures and problems.

## Contents

- **Singly Linked List Implementation**: Basic skeleton for a Singly Linked List. [SingleLinkedListImple.py](SingleLinkedListImple.py)
- **Doubly Linked List Implementation**: Basic skeleton for a Doubly Linked List. [DoublyLinkedListImple.py](DoublyLinkedListImple.py)
- **Singly Linked List Cycle Check**: Check if a singly linked list contains a cycle using the "two runners" (slow and fast pointers) strategy. [SinglyLinkedListCycleCheckImple.py](SinglyLinkedListCycleCheckImple.py)
- **Reverse a Linked List**: Reverse a linked list in-place. [LinkedListReversal.py](LinkedListReversal.py)
- **Nth to Last Node**: Find the nth to last node in a linked list. [LinkedListNthToLastNode.py](LinkedListNthToLastNode.py)
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 common queue-based data structures.

## Contents

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

---
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`

### Build Tree Test
Demonstrates building a tree and manipulating nodes using a list-of-lists approach.
- **File**: `Trees/buildTreeTest.py`

---

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

---

## Usage
Most scripts in this repository are standalone and can be executed directly using Python 3. For example:

```bash
python3 Arrays/ArrayPairSumSol.py
```

---

## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

---

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

This directory contains Python implementations of common recursive algorithms and problems.

## Contents

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

This directory contains Python implementations of common sorting algorithms.

## Contents

- **Bubble Sort**: [BubbleSortImple.py](BubbleSortImple.py)
- Complexity: O(n²) worst/average, O(n) best.
- **Selection Sort**: [SelectionSortImple.py](SelectionSortImple.py)
- Complexity: O(n²) for all cases.
- **Insertion Sort**: [InsertionSortImple.py](InsertionSortImple.py)
- Complexity: O(n²) worst/average, O(n) best.
- **Merge Sort**: [MergeSortImple.py](MergeSortImple.py)
- Complexity: O(n log n) for all cases.
- **Quick Sort**: [QuickSortImple.py](QuickSortImple.py)
- Complexity: O(n²) worst, O(n log n) average/best.
- **Shell Sort**: [ShellSortImple.py](ShellSortImple.py)
- Complexity: Between O(n) and O(n²) 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 common stack-based data structures and problems.

## Contents

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

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

## Contents

- **Binary Search Tree Implementation**: [BinarySearchTreesImple.py](BinarySearchTreesImple.py)
- **Binary Heap Implementation**: [BinaryHeapImple.py](BinaryHeapImple.py)
- **Binary Search**: Recursive and iterative implementations.
- [BinarySearchImple.py](BinarySearchImple.py)
- [BinarySearchRecursiveImple.py](BinarySearchRecursiveImple.py)
- **Validate BST**: Check if a binary tree is a valid Binary Search Tree.
- [BinarySearchTreeCheckImpleSol1.py](BinarySearchTreeCheckImpleSol1.py)
- [BinarySearchTreeCheckImpleSol2.py](BinarySearchTreeCheckImpleSol2.py)
- **Trim a BST**: Trim a BST so all nodes are within a given range [min, max]. [TrimBinarySearchTreeImple.py](TrimBinarySearchTreeImple.py)
- **Tree Representation (Nodes & References)**: Implementing a tree using classes and references. [TreeRepresentationWithNodesReferences.py](TreeRepresentationWithNodesReferences.py)
- **Tree Level Order Print**: Print a binary tree in level order. [TreeLevelOrderPrintImple.py](TreeLevelOrderPrintImple.py)
- **Build Tree Test**: Demonstrates building a tree and manipulating nodes using a list-of-lists approach. [buildTreeTest.py](buildTreeTest.py)
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 a Python implementation of the Deque data structure.

## Contents

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