|
1 | | -# TypeScript Algorithms and Data Structures |
| 1 | +# 🚀 TypeScript Algorithms and Data Structures |
2 | 2 |
|
3 | | -This repository is a collection of TypeScript algorithms and data structures. It is intended for educational purposes and serves as a reference for developers who want to learn and practice TypeScript. |
| 3 | +**A comprehensive collection of algorithms, data structures, and coding challenges implemented in TypeScript** |
4 | 4 |
|
5 | | - |
6 | | -[](https://app.codacy.com/gh/behzadam/algorithms/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade) |
7 | | - |
| 5 | +[](https://github.com/behzadam/algorithms) |
| 6 | +[](https://app.codacy.com/gh/behzadam/algorithms/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade) |
| 7 | +[](https://github.com/behzadam/algorithms) |
| 8 | +[](https://opensource.org/licenses/MIT) |
8 | 9 |
|
9 | | -## Introduction |
| 10 | +[Features](#-features) • [Quick Start](#-getting-started) • [Documentation](#-documentation) |
10 | 11 |
|
11 | | -It includes code and patterns from the "JavaScript Algorithms" repository, translated from JavaScript to TypeScript. [JavaScript Algorithms](https://github.com/trekhleb/javascript-algorithms) |
| 12 | +--- |
12 | 13 |
|
13 | | -## Data structure |
| 14 | +## 📋 Table of Contents |
14 | 15 |
|
15 | | -- [HashTable](src/data-structure/hash-table/hash-table.ts) |
16 | | -- [MinHeap](src/data-structure/heap/min-heap.ts) |
17 | | -- [MaxHeap](src/data-structure/heap/max-heap.ts) |
18 | | -- [LinkedList](src/data-structure/linked-list/linked-list.ts) |
19 | | -- [Queue](src/data-structure/queue/queue.ts) |
20 | | -- [Stack](src/data-structure/stack/stack.ts) |
21 | | -- [MaxPriorityQueue](src/data-structure/priority-queue/max-priority-queue.ts) |
22 | | -- [MinPriorityQueue](src/data-structure/priority-queue/min-priority-queue.ts) |
23 | | -- [Trie](src/data-structure/trie/trie.ts) |
| 16 | +<!-- markdownlint-disable MD033 --> |
| 17 | +<details> |
| 18 | +<summary>Click to expand</summary> |
| 19 | +<!-- markdownlint-enable MD033 --> |
24 | 20 |
|
25 | | -## Algorithms |
| 21 | +- [🚀 TypeScript Algorithms and Data Structures](#-typescript-algorithms-and-data-structures) |
| 22 | + - [📋 Table of Contents](#-table-of-contents) |
| 23 | + - [🎯 Introduction](#-introduction) |
| 24 | + - [✨ Features](#-features) |
| 25 | + - [📚 Documentation](#-documentation) |
| 26 | + - [📦 Data Structures](#-data-structures) |
| 27 | + - [🔍 Algorithms](#-algorithms) |
| 28 | + - [🔎 Search Algorithms](#-search-algorithms) |
| 29 | + - [🔄 Sorting Algorithms](#-sorting-algorithms) |
| 30 | + - [💻 Coding Challenges](#-coding-challenges) |
| 31 | + - [👉 Two Pointers](#-two-pointers) |
| 32 | + - [🛠️ Utilities](#️-utilities) |
| 33 | + - [🚀 Getting Started](#-getting-started) |
| 34 | + - [Prerequisites](#prerequisites) |
| 35 | + - [Installation](#installation) |
| 36 | + - [💻 Development](#-development) |
| 37 | + - [Available Scripts](#available-scripts) |
| 38 | + - [Project Structure](#project-structure) |
| 39 | + - [📝 License](#-license) |
| 40 | + - [📧 Contact](#-contact) |
26 | 41 |
|
27 | | -### Search |
| 42 | +<!-- markdownlint-disable MD033 --> |
| 43 | +</details> |
| 44 | +<!-- markdownlint-enable MD033 --> |
28 | 45 |
|
29 | | -- [BinarySearch](src/algorithms/search/binary-search/binary-search.ts) |
30 | | -- [LinearSearch](src/algorithms/search/linear-search/linear-search.ts) |
| 46 | +--- |
31 | 47 |
|
32 | | -### Sort |
| 48 | +## 🎯 Introduction |
33 | 49 |
|
34 | | -- [QuickSort](src/algorithms/sort/quick-sort/quick-sort.ts) |
35 | | -- [BubbleSort](src/algorithms/sort/bubble-sort/bubble-sort.ts) |
36 | | -- [BubbleSortSimple](src/algorithms/sort/bubble-sort/bubble-sort-simple.ts) |
| 50 | +This repository is a **comprehensive collection** of TypeScript algorithms and data structures designed for educational purposes. It serves as a reference for developers who want to learn, practice, and master TypeScript while understanding fundamental computer science concepts. |
37 | 51 |
|
38 | | -## Utils |
| 52 | +> 💡 **Note:** This repository includes code and patterns from the [JavaScript Algorithms](https://github.com/trekhleb/javascript-algorithms) repository, translated and enhanced from JavaScript to TypeScript. |
39 | 53 |
|
40 | | -- [Comparator](src/ds/comparator/comparator.ts) |
| 54 | +--- |
41 | 55 |
|
42 | | -Please note that the repository is still a work in progress, and new algorithms and patterns will be added over time. |
| 56 | +## ✨ Features |
43 | 57 |
|
44 | | -## Getting Started |
| 58 | +- 🔍 **Well-documented** code with TypeScript types |
| 59 | +- ✅ **Fully tested** with Jest test suites |
| 60 | +- 📚 **Educational** focus with clear implementations |
| 61 | +- 🎨 **Clean code** following best practices |
| 62 | +- 🚀 **Production-ready** implementations |
| 63 | +- 🔄 **Regularly updated** with new algorithms and patterns |
45 | 64 |
|
46 | | -To get started with the repository, follow these simple steps: |
| 65 | +--- |
47 | 66 |
|
48 | | -Clone the repository to your local machine using the command: |
| 67 | +## 📚 Documentation |
49 | 68 |
|
50 | | -```bash |
51 | | -git clone https://github.com/behzadam/algorithms.git |
52 | | -``` |
| 69 | +### 📦 Data Structures |
53 | 70 |
|
54 | | -Install the required dependencies by running the following command: |
| 71 | +| Data Structure | Description | Implementation | |
| 72 | +| -------------------- | ------------------------------------ | -------------------------------------------------------------------- | |
| 73 | +| **HashTable** | Key-value mapping with hash function | [View Code](src/data-structure/hash-table/hash-table.ts) | |
| 74 | +| **MinHeap** | Binary heap with minimum root | [View Code](src/data-structure/heap/min-heap.ts) | |
| 75 | +| **MaxHeap** | Binary heap with maximum root | [View Code](src/data-structure/heap/max-heap.ts) | |
| 76 | +| **LinkedList** | Linear collection of nodes | [View Code](src/data-structure/linked-list/linked-list.ts) | |
| 77 | +| **Queue** | FIFO (First In First Out) structure | [View Code](src/data-structure/queue/queue.ts) | |
| 78 | +| **Stack** | LIFO (Last In First Out) structure | [View Code](src/data-structure/stack/stack.ts) | |
| 79 | +| **MaxPriorityQueue** | Priority queue with max priority | [View Code](src/data-structure/priority-queue/max-priority-queue.ts) | |
| 80 | +| **MinPriorityQueue** | Priority queue with min priority | [View Code](src/data-structure/priority-queue/min-priority-queue.ts) | |
| 81 | +| **Trie** | Prefix tree for string operations | [View Code](src/data-structure/trie/trie.ts) | |
| 82 | +| **BinaryTree** | Hierarchical tree structure | [View Code](src/data-structure/tree/binary-tree.ts) | |
55 | 83 |
|
56 | | -```bash |
57 | | -pnpm install |
58 | | -``` |
| 84 | +### 🔍 Algorithms |
| 85 | + |
| 86 | +#### 🔎 Search Algorithms |
| 87 | + |
| 88 | +- **[Binary Search](src/algorithms/search/binary-search/binary-search.ts)** - Efficient search in sorted arrays |
| 89 | +- **[Linear Search](src/algorithms/search/linear-search/linear-search.ts)** - Simple sequential search |
| 90 | + |
| 91 | +#### 🔄 Sorting Algorithms |
| 92 | + |
| 93 | +- **[Quick Sort](src/algorithms/sort/quick/quick-sort.ts)** - Divide and conquer sorting algorithm |
| 94 | +- **[Bubble Sort](src/algorithms/sort/bubble-sort/bubble-sort.ts)** - Simple comparison-based sort |
| 95 | +- **[Bubble Sort Simple](src/algorithms/sort/bubble-sort/bubble-sort-simple.ts)** - Simplified bubble sort implementation |
| 96 | + |
| 97 | +### 💻 Coding Challenges |
| 98 | + |
| 99 | +#### 👉 Two Pointers |
| 100 | + |
| 101 | +- **[Pair Sum Sorted](src/code-challanges/two-pointers/pair-sum-sorted.ts)** - Find pairs in sorted array that sum to target |
| 102 | + |
| 103 | +### 🛠️ Utilities |
| 104 | + |
| 105 | +- **[Comparator](src/utils/comparator.ts)** - Comparison functions for sorting and searching |
| 106 | +- **[Range](src/utils/range.ts)** - Utility for generating number ranges |
| 107 | +- **[Type Definitions](src/types/)** - Common TypeScript type definitions |
| 108 | + |
| 109 | +--- |
| 110 | + |
| 111 | +## 🚀 Getting Started |
| 112 | + |
| 113 | +### Prerequisites |
| 114 | + |
| 115 | +- **Node.js** (v16 or higher) |
| 116 | +- **pnpm** (or npm/yarn) |
| 117 | + |
| 118 | +### Installation |
| 119 | + |
| 120 | +1. **Clone the repository** |
| 121 | + |
| 122 | + ```bash |
| 123 | + git clone https://github.com/behzadam/algorithms.git |
| 124 | + cd algorithms |
| 125 | + ``` |
| 126 | + |
| 127 | +2. **Install dependencies** |
| 128 | + |
| 129 | + ```bash |
| 130 | + pnpm install |
| 131 | + ``` |
| 132 | + |
| 133 | +3. **Run tests** |
| 134 | + |
| 135 | + ```bash |
| 136 | + pnpm test |
| 137 | + ``` |
59 | 138 |
|
60 | | -Run all tests |
| 139 | +--- |
| 140 | + |
| 141 | +## 💻 Development |
| 142 | + |
| 143 | +### Available Scripts |
| 144 | + |
| 145 | +<!-- markdownlint-disable MD033 --> |
| 146 | +<details> |
| 147 | +<summary><b>Test Commands</b></summary> |
| 148 | +<!-- markdownlint-enable MD033 --> |
61 | 149 |
|
62 | 150 | ```bash |
| 151 | +# Run all tests |
63 | 152 | pnpm test |
64 | | -``` |
65 | 153 |
|
66 | | -Format checking |
| 154 | +# Run tests in watch mode |
| 155 | +pnpm test:watch |
67 | 156 |
|
68 | | -```bash |
69 | | -pnpm format:check |
| 157 | +# Run tests with coverage |
| 158 | +pnpm test:coverage |
70 | 159 | ``` |
71 | 160 |
|
72 | | -Format fixing |
| 161 | +<!-- markdownlint-disable MD033 --> |
| 162 | +</details> |
| 163 | + |
| 164 | +<details> |
| 165 | +<summary><b>Code Quality Commands</b></summary> |
| 166 | +<!-- markdownlint-enable MD033 --> |
73 | 167 |
|
74 | 168 | ```bash |
75 | | -pnpm format:fix |
76 | | -``` |
| 169 | +# Check code formatting |
| 170 | +pnpm format:check |
77 | 171 |
|
78 | | -Run ESLint |
| 172 | +# Fix code formatting |
| 173 | +pnpm format:fix |
79 | 174 |
|
80 | | -```bash |
| 175 | +# Run ESLint |
81 | 176 | pnpm lint |
| 177 | + |
| 178 | +# Fix ESLint issues |
| 179 | +pnpm lint:fix |
| 180 | +``` |
| 181 | + |
| 182 | +<!-- markdownlint-disable MD033 --> |
| 183 | +</details> |
| 184 | +<!-- markdownlint-enable MD033 --> |
| 185 | + |
| 186 | +### Project Structure |
| 187 | + |
| 188 | +```text |
| 189 | +algorithms/ |
| 190 | +├── src/ |
| 191 | +│ ├── algorithms/ # Algorithm implementations |
| 192 | +│ │ ├── search/ # Search algorithms |
| 193 | +│ │ └── sort/ # Sorting algorithms |
| 194 | +│ ├── code-challanges/ # Coding challenges |
| 195 | +│ ├── data-structure/ # Data structure implementations |
| 196 | +│ ├── types/ # TypeScript type definitions |
| 197 | +│ └── utils/ # Utility functions |
| 198 | +├── jest.config.js # Jest configuration |
| 199 | +├── tsconfig.json # TypeScript configuration |
| 200 | +└── package.json # Project dependencies |
82 | 201 | ``` |
83 | 202 |
|
84 | | -## License |
| 203 | +--- |
| 204 | + |
| 205 | +## 📝 License |
| 206 | + |
| 207 | +This project is licensed under the **MIT License** - see the [LICENSE](LICENSE) file for details. |
| 208 | + |
| 209 | +--- |
| 210 | + |
| 211 | +## 📧 Contact |
| 212 | + |
| 213 | +Have questions or suggestions? Feel free to reach out! |
| 214 | + |
| 215 | + |
| 216 | +- **GitHub:** [@behzadam](https://github.com/behzadam) |
| 217 | + |
| 218 | +--- |
| 219 | + |
| 220 | +<!-- markdownlint-disable MD033 --> |
| 221 | +<div align="center"> |
85 | 222 |
|
86 | | -The "TypeScript Algorithms, Data Structures and Patterns" repository is licensed under the [MIT License](https://opensource.org/licenses/MIT). Feel free to use, modify, and distribute the code as per the terms of the license. |
| 223 | +**⭐ Star this repo if you find it helpful!** |
87 | 224 |
|
88 | | -## Contact |
| 225 | +Made with ❤️ by [behzadam](https://github.com/behzadam) |
89 | 226 |
|
90 | | -If you have any questions or suggestions regarding the repository, please feel free to [contact me ](mailto:[email protected]). |
| 227 | +</div> |
| 228 | +<!-- markdownlint-enable MD033 --> |
0 commit comments