{"id":21377546,"url":"https://github.com/zeyu-li/algorithms","last_synced_at":"2025-07-13T10:31:41.845Z","repository":{"id":120380065,"uuid":"233163861","full_name":"Zeyu-Li/algorithms","owner":"Zeyu-Li","description":"A useful collections of algorithms, formulas, APTs, and some other notes 🗒","archived":false,"fork":false,"pushed_at":"2022-10-13T18:41:27.000Z","size":169,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-07T09:11:11.286Z","etag":null,"topics":["algorithms","cpp","data-structure","data-structures","formulas","graph","graph-algorithms","graph-theory","graph-theory-algorithms","python","school"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Zeyu-Li.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"Zeyu-Li"}},"created_at":"2020-01-11T02:24:13.000Z","updated_at":"2023-05-16T18:10:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"d22c8bce-8608-4e42-88a8-faa587d41cf8","html_url":"https://github.com/Zeyu-Li/algorithms","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Zeyu-Li/algorithms","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zeyu-Li%2Falgorithms","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zeyu-Li%2Falgorithms/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zeyu-Li%2Falgorithms/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zeyu-Li%2Falgorithms/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Zeyu-Li","download_url":"https://codeload.github.com/Zeyu-Li/algorithms/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zeyu-Li%2Falgorithms/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265128281,"owners_count":23715621,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithms","cpp","data-structure","data-structures","formulas","graph","graph-algorithms","graph-theory","graph-theory-algorithms","python","school"],"created_at":"2024-11-22T09:21:55.152Z","updated_at":"2025-07-13T10:31:41.836Z","avatar_url":"https://github.com/Zeyu-Li.png","language":"C++","readme":"# Quick Algorithms or Formulas\r\n\r\n[![Testing](https://github.com/Zeyu-Li/algorithms/actions/workflows/main.yml/badge.svg)](https://github.com/Zeyu-Li/algorithms/actions/workflows/main.yml)\r\n\r\n## About\r\n\r\nThis is a collection of algorithms, formulas, or  written in different programing languages\r\n\r\n## ADT\r\n\r\n### Python\r\n\r\n* Stack [O(1) constant]\r\n* Bounded Queues [O(n) linear time]\r\n* Circular Queues [O(1) constant]\r\n\r\nThe next two have a node (SLinkedListNode or DLinkedListNode) and the implementation (SLinkedList or DLinkedList)\r\n\r\n* Singly Linked List [O(n) linear time] \r\n* Doubly Linked List [O(n) linear time] \r\n\r\n\r\n\r\n### C++\r\n\r\n**Included in STL**\r\n\r\n* Stack\r\n* Queue\r\n* Priority Queue\r\n* Vectors\r\n* Lists (similar to Vectors)\r\n* Sets\r\n* Heaps\r\n* Sorting O(nlog(n))\r\n\r\n**Mine**\r\n\r\n* Binary Tree (has template class)\r\n* Hash Table\r\n* Graphs\r\n  * Matrix representation (has template class)\r\n  * List/Hash-like table representation (has template class)\r\n  * List of edges with weights\r\n* Heaps\r\n\r\n\r\n\r\n## Algorithms\r\n\r\n### Python\r\n\r\n* GCD (greatest common denominator) by Euclidean algorithm\r\n* LCM (least common multiple) uses GCD\r\n* Pi Approximator via Monte Carlo\r\n* Matrix Multiplication O(n^3)\r\n* Strassen's Matrix Multiplication ~O(n^2.81) (less precise than the one above)\r\n* Power set ~O(n * 2^n) (Generates a power set given iterator)\r\n\r\n### C++\r\n\r\n* GCD via Euclidean algorithm\r\n* LCM (least common multiple) uses GCD\r\n* BFS - Breath first search (+ shortest path) O(V+E)\r\n* DFS - Depth first search O(V+E)\r\n* Dijkstra's Algorithm - Shortest path O(V^2)\r\n* A Star Search - Shortest path O(V^2)\r\n* Bellman-Ford - Shortest path (dp) O(E*V)\r\n* Floyd-Warshall - Shortest path for all pairs of points O(V^3)\r\n* Kruskal's Algorithm - Minimum spanning tree O(E log E)\r\n* Prim's Algorithm - Minimum spanning tree O(V^2)\r\n* Quick Square Root from [Quake III](https://www.youtube.com/watch?v=p8u_k2LIZyo\u0026ab_channel=Nemean)\r\n\r\n### Go\r\n\r\n* Is prime\r\n\r\n### TypeScript\r\n\r\n* Is prime\r\n\r\n## Sorting\r\n\r\n### Python\r\n\r\n* Insertion O(n^2)\r\n* Bubble O(n^2)\r\n* Merge O(nlogn)\r\n* Quick O(nlogn)\r\n* Count O(n+k)\r\n* Radix O(n)\r\n\r\n## Concepts\r\n\r\n### Greedy\r\n\r\nTake the best in current case and continue for all cases (don't look back)\r\n\r\n### Divide and Conquer\r\n\r\nDivides problems into many subproblems that can be tackled (usually in similar ways)\r\n\r\n### Dynamic Programming\r\n\r\nKeep a table or array of calculated values such that items in table or array need to be calculated only once\r\n\r\n### Hash Tables/Maps\r\n\r\nVery efficient data structures that can speed up search, push and many others. Most of the time, modulus will be used as the hash function. In Python, dictionaries are hash maps and are really useful. JavaScript has objects that can also act like hash tables! \r\n\r\n### Randomness\r\n\r\nRandomness in so algorithms can improve running time, especially if you are parallelize it such that the randomness can help you get the answer with the fastest sub-processes\r\n\r\n\r\n\r\n## How to Use\r\n\r\n### Python\r\n\r\nFor MacOS or Linux:\r\n\r\n```shell\r\npython3 name_of_program.py\r\n```\r\n\r\nFor Windows:\r\n\r\n```powershell\r\npy name_of_program.py\r\n```\r\n\r\n### C++\r\n\r\nNeeds to be complied (recommended gcc)\r\n\r\n### Usage\r\n\r\nCan be copied and pasted directly to the file or drag in the file and be include with `#include \"NameOfFile.cpp\"` header\r\n\r\n\r\n\r\n## Licence\r\n\r\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) \r\n\r\nThe rules for copy and distributing this project licence are \r\noutlined in the licence.txt file.\r\n\r\nThis project is under an MIT licence ","funding_links":["https://github.com/sponsors/Zeyu-Li"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzeyu-li%2Falgorithms","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzeyu-li%2Falgorithms","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzeyu-li%2Falgorithms/lists"}