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
21 changes: 21 additions & 0 deletions Arrays/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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)
- [Anagram_Check_manual_Sol.py](Anagram_Check_manual_Sol.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)

### Array Pair Sum
Given an integer array, output all unique pairs that sum up to a specific value `k`.
- [ArrayPairSumSol.py](ArrayPairSumSol.py)
9 changes: 9 additions & 0 deletions Error-debug/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Error Handling and Debugging

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

## Contents

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

This directory contains implementations of various graph-related algorithms and problems.

## Contents

### Graph Implementation
- [AdjacencyListGraphImple.py](AdjacencyListGraphImple.py): Basic Adjacency List implementation.

### Breadth First Search (BFS)
- [BFS.py](BFS.py): Implementation of Breadth First Search.
- [WordLadderProblem.py](WordLadderProblem.py): Solving the Word Ladder problem using BFS.

### Depth First Search (DFS)
- [DFSGeneral.py](DFSGeneral.py): A general implementation of Depth First Search.
- [DFSImpleTheKnightsTourProblem.py](DFSImpleTheKnightsTourProblem.py): Implementation of the Knight's Tour problem using DFS.
- [TheKnightsTourProblem.py](TheKnightsTourProblem.py): Another implementation/part of the Knight's Tour problem.
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.
16 changes: 16 additions & 0 deletions LinkedLists/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Linked Lists

This directory contains implementations of linked list data structures and related algorithms.

## Contents

### Singly Linked List
- [SingleLinkedListImple.py](SingleLinkedListImple.py): Basic Singly Linked List implementation.
- [SinglyLinkedListCycleCheckImple.py](SinglyLinkedListCycleCheckImple.py): Check if a singly linked list contains a cycle.

### Doubly Linked List
- [DoublyLinkedListImple.py](DoublyLinkedListImple.py): Basic Doubly Linked List implementation.

### Operations
- [LinkedListReversal.py](LinkedListReversal.py): In-place reversal of a linked list.
- [LinkedListNthToLastNode.py](LinkedListNthToLastNode.py): Find the nth to last node in a linked list.
13 changes: 13 additions & 0 deletions Queues/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Queues

This directory contains implementations of queue data structures.

## Contents

### Basic 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)
16 changes: 16 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 @@ -204,6 +206,20 @@ Demonstrates `try-except-else-finally` blocks and user input validation.

---

## Usage
Most of these scripts can be executed directly using the Python 3 interpreter. For example:
```bash
python3 Arrays/Anagram_Check_Sorted_Sol.py
```
Some scripts may have dependencies or require specific setup as described in their respective subdirectory READMEs.

---

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

This directory contains recursive implementations of various algorithms and 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.

### String Manipulation
- [RecursionReverseStr.py](RecursionReverseStr.py): Recursive implementation to reverse a string.
- [RecursionStrPermutation.py](RecursionStrPermutation.py): Output all possible permutations of a string.

### Word Problems
- [RecursionWordSplit.py](RecursionWordSplit.py): Determine if a string can be split into words found in a given list.

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

This directory contains Python implementations of common sorting algorithms.

## Contents

### Bubble Sort
- [BubbleSortImple.py](BubbleSortImple.py): $O(n^2)$ worst and average case, $O(n)$ best case.

### Selection Sort
- [SelectionSortImple.py](SelectionSortImple.py): $O(n^2)$ for all cases.

### Insertion Sort
- [InsertionSortImple.py](InsertionSortImple.py): $O(n^2)$ worst and average case, $O(n)$ best case.

### Merge Sort
- [MergeSortImple.py](MergeSortImple.py): $O(n \log n)$ for all cases.

### Quick Sort
- [QuickSortImple.py](QuickSortImple.py): $O(n^2)$ worst case, $O(n \log n)$ average/best case.

### Shell Sort
- [ShellSortImple.py](ShellSortImple.py): Complexity between $O(n)$ and $O(n^2)$ depending on increment sequence.
13 changes: 13 additions & 0 deletions Stacks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Stacks

This directory contains implementations of stack data structures and related problems.

## Contents

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

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

## Contents

### Binary Search Trees
- [BinarySearchTreesImple.py](BinarySearchTreesImple.py): Implementation of Binary Search Trees.
- [BinarySearchTreeCheckImpleSol1.py](BinarySearchTreeCheckImpleSol1.py): Validate BST Solution 1.
- [BinarySearchTreeCheckImpleSol2.py](BinarySearchTreeCheckImpleSol2.py): Validate BST Solution 2.
- [TrimBinarySearchTreeImple.py](TrimBinarySearchTreeImple.py): Trim a BST so all nodes are within a given range `[min, max]`.

### Binary Heaps
- [BinaryHeapImple.py](BinaryHeapImple.py): Implementation of Binary Heap.

### Binary Search
- [BinarySearchImple.py](BinarySearchImple.py): Iterative Binary Search implementation.
- [BinarySearchRecursiveImple.py](BinarySearchRecursiveImple.py): Recursive Binary Search implementation.

### Tree Traversal and Representation
- [TreeLevelOrderPrintImple.py](TreeLevelOrderPrintImple.py): Print a binary tree in level order.
- [TreeRepresentationWithNodesReferences.py](TreeRepresentationWithNodesReferences.py): Tree representation using classes and references.
- [buildTreeTest.py](buildTreeTest.py): Tree representation using a list-of-lists approach.
9 changes: 9 additions & 0 deletions deque/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Deque

This directory contains implementations of double-ended queues.

## Contents

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