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 for common array-related problems and algorithms.

## Contents

- **Anagram Check**: Checks if two strings are anagrams of each other.
- `Anagram_Check_Sorted_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`
- **Find Missing Element**: Find the missing element in a shuffled second array.
- `ArrayFindTheMissingElement_XOR_sol.py`
- `ArrayFindTheMissingElement_brute_force_sol.py`
- `ArrayFindTheMissingElement_hash_table_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 Python exception handling patterns and debugging practices.

## Contents

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

This directory contains implementations of fundamental graph algorithms and their applications to classic computer science problems.

## Contents

- **Adjacency List Graph Implementation**: A common way to represent a graph in Python.
- `AdjacencyListGraphImple.py`
- **Breadth First Search (BFS)**: Implementation of BFS and its application to the Word Ladder problem.
- `BFS.py`
- `WordLadderProblem.py`
- **Depth First Search (DFS)**: General DFS implementation and its application to the Knight's Tour problem.
- `DFSGeneral.py`
- `DFSImpleTheKnightsTourProblem.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) 2024 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.
15 changes: 15 additions & 0 deletions LinkedLists/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Linked Lists

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

## Contents

- **Singly Linked List**: Basic implementation and cycle detection.
- `SingleLinkedListImple.py`
- `SinglyLinkedListCycleCheckImple.py`
- **Doubly Linked List**: Basic implementation of a doubly linked list.
- `DoublyLinkedListImple.py`
- **Reversal**: In-place reversal of a linked list.
- `LinkedListReversal.py`
- **Nth to Last Node**: Find the nth element from the end of a linked list.
- `LinkedListNthToLastNode.py`
10 changes: 10 additions & 0 deletions Queues/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Queues

This directory contains implementations of queue data structures using various approaches.

## Contents

- **Basic Queue**: Implementation of a standard queue (FIFO) with standard operations.
- `QueueImple.py`
- **Queue with Two Stacks**: Implementation of a queue using two stacks as its internal data structure.
- `QueueWith2StacksImple.py`
28 changes: 28 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`

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

---

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

---

## Usage

Most scripts in this repository are standalone and can be executed directly using the Python 3 interpreter. To run a script, navigate to the repository's root directory and use the following command:

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

For example, to run the Array Pair Sum solution:

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

---

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more 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
23 changes: 23 additions & 0 deletions Recursion/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Recursion

This directory contains implementations of recursive algorithms and their applications to various programming problems.

## Contents

- **Cumulative Sum**: Compute the cumulative sum from 0 to `n`.
- `RecursionCumulativeSum.py`
- **Sum of Digits**: Compute the sum of all individual digits in an integer.
- `RecursionSumOfDigits.py`
- **Word Split**: Determine if a string can be split into words from a given list.
- `RecursionWordSplit.py`
- **Reverse a String**: Recursive implementation of string reversal.
- `RecursionReverseStr.py`
- **String Permutations**: Output all possible permutations of a string.
- `RecursionStrPermutation.py`
- **Fibonacci Sequence**: Recursive, iterative, and dynamic programming implementations.
- `FibonacciSeqRecursion.py`
- `FibonacciSeqIterative.py`
- `FibonacciSeqDynamic.py`
- **Coin Change Problem**: Minimum number of coins needed to make change.
- `CoinChangeProblemRecursion.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 implementations of various sorting algorithms and their complexity analysis.

## Contents

- **Bubble Sort**: Simple sorting algorithm that repeatedly swaps adjacent elements.
- `BubbleSortImple.py`
- **Selection Sort**: Sorting algorithm that selects the smallest element in each pass.
- `SelectionSortImple.py`
- **Insertion Sort**: Sorting algorithm that builds the final sorted array one element at a time.
- `InsertionSortImple.py`
- **Merge Sort**: Divide-and-conquer sorting algorithm.
- `MergeSortImple.py`
- **Quick Sort**: Divide-and-conquer sorting algorithm using a pivot element.
- `QuickSortImple.py`
- **Shell Sort**: Generalization of insertion sort that allows for swapping distant elements.
- `ShellSortImple.py`
10 changes: 10 additions & 0 deletions Stacks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Stacks

This directory contains implementations of stack data structures and their related algorithms.

## Contents

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

This directory contains implementations of binary trees, binary heaps, and various tree-based algorithms.

## Contents

- **Binary Search Tree (BST)**: Basic implementation and validation.
- `BinarySearchTreesImple.py`
- `BinarySearchTreeCheckImpleSol1.py`
- `BinarySearchTreeCheckImpleSol2.py`
- `TrimBinarySearchTreeImple.py`
- **Binary Heap**: Implementation of binary heaps.
- `BinaryHeapImple.py`
- **Binary Search**: Recursive and iterative implementations of binary search.
- `BinarySearchImple.py`
- `BinarySearchRecursiveImple.py`
- **Tree Representation**: Different ways of representing binary trees in Python.
- `TreeRepresentationWithNodesReferences.py`
- `buildTreeTest.py` (List of Lists)
- **Level Order Print**: Print a binary tree in level order.
- `TreeLevelOrderPrintImple.py`
8 changes: 8 additions & 0 deletions deque/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Deque

This directory contains implementations of double-ended queue (deque) data structures.

## Contents

- **Deque Implementation**: Basic operations (FIFO/LIFO): `addFront`, `addRear`, `removeFront`, `removeRear`, `isEmpty`, `size`.
- `DequeImple.py`