{"id":38521070,"url":"https://github.com/summerrainet2008/python_algorithms_library","last_synced_at":"2026-01-17T06:40:09.811Z","repository":{"id":204220306,"uuid":"711094555","full_name":"SummerRainET2008/PYthon_Algorithms_Library","owner":"SummerRainET2008","description":"Migrating popular data structures and algorithms in C++ to Python, such as linked list, balanced search tree, heap with a support of updating and deletion, as well as other commonly used small functions.","archived":false,"fork":false,"pushed_at":"2025-07-13T16:41:10.000Z","size":222,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-29T08:09:15.255Z","etag":null,"topics":["algorithm","list","python","tree"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SummerRainET2008.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2023-10-28T07:41:15.000Z","updated_at":"2025-07-13T16:41:13.000Z","dependencies_parsed_at":"2023-11-06T23:03:24.494Z","dependency_job_id":"bfce5aaf-67b4-4422-8160-2fcb788b9c4d","html_url":"https://github.com/SummerRainET2008/PYthon_Algorithms_Library","commit_stats":{"total_commits":144,"total_committers":1,"mean_commits":144.0,"dds":0.0,"last_synced_commit":"b8ef075fcbc4cdf81d82381df7afcdea6e223056"},"previous_names":["summerrainet2008/python_algorithms_library"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SummerRainET2008/PYthon_Algorithms_Library","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SummerRainET2008%2FPYthon_Algorithms_Library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SummerRainET2008%2FPYthon_Algorithms_Library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SummerRainET2008%2FPYthon_Algorithms_Library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SummerRainET2008%2FPYthon_Algorithms_Library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SummerRainET2008","download_url":"https://codeload.github.com/SummerRainET2008/PYthon_Algorithms_Library/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SummerRainET2008%2FPYthon_Algorithms_Library/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28502805,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T04:31:57.058Z","status":"ssl_error","status_checked_at":"2026-01-17T04:31:45.816Z","response_time":85,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["algorithm","list","python","tree"],"created_at":"2026-01-17T06:40:09.099Z","updated_at":"2026-01-17T06:40:09.797Z","avatar_url":"https://github.com/SummerRainET2008.png","language":"Python","readme":"# PYthon Algorithms Library (pyal)\n\nUnlike the STL in C++ which provides misceneous data structures, Python does not have some important structures, like `linked list`, `tree map`. \nThis library aims to provide a python counterpart of C++ STL.\n\n# 1. Install \n ```bash\n python3 -m pip install Python-Algorithm-pyal psutil pytz\n ```\n\n# 2. Examples [github](https://github.com/SummerRainET2008/PYthon_Algorithms_Library)\n\nBalanced search tree based map, ```TreeMap```\n\n```python\nimport pyal\n\ndef main():\n  tree_map = pyal.TreeMap()\n  data = [(0, \"a\"), (1, \"b\"), (2, \"c\"), (3, \"d\"), (4, \"e\"), (5, \"f\")]\n  for key, value in data:\n    tree_map[key] = value\n\n  key = -1\n  value = tree_map.get(key)\n  if value is None:\n    print(f\"key={key} does not exist\")\n\n  key = 0\n  print(f\"key={key}, value={tree_map[key]}\")\n\n  key = 1\n  node = tree_map.lower_bound(key)\n  print(f\"lower_bound({key=}): {node.get()=}\")\n\n  node = tree_map.upper_bound(key)\n  print(f\"upper_bound({key=}): {node.get()=}\")\n\n  print(f\"min key: {tree_map.key_list_begin().get()}\")\n  print(f\"max key: {tree_map.key_list_end().prev().get()}\")\n```\n\nOutput\n```\nkey=-1 does not exist\nkey=0, value=a\nlower_bound(key=1): node.get()=1\nupper_bound(key=1): node.get()=2\nmin key: 0\nmax key: 5\n```\n\n\n# 3. Popular data structures and algorithms.\n  Please check [github](https://github.com/SummerRainET2008/PYthon_Algorithms_Library) for all examples.\n  * ### Tree\n    \u003e* TreeMap [example](doc/example_TreeMap.md)\n    \u003e   * ___Balanced___ binary search tree.\n    \u003e   * ___insert___ \u0026 ___delete___: O(log N)\n    \u003e   * ___get___:  O(1)\n    \u003e* DynamicHeap [example](doc/example_DynamicHeap.md)\n    \u003e   * ___update___ \u0026 ___deletion___: O(log N)\n    \u003e* MinHeap, MaxHeap [example](doc/example_MinHeap.md)\n    \u003e* DisjointSet [example](doc/example_DisjointSet.md)\n  * ### List\n    \u003e * LinkedList [example](doc/example_LinkedList.md)\n    \u003e * Queue [example](doc/example_Queue.md)\n    \u003e * Dequeue [example](doc/example_Deque.md)\n    \u003e * Stack [example](doc/example_Stack.md)\n    \u003e * LRUCache [example](doc/example_LRUCache.md)\n    \u003e   * ___get___ \u0026 ___set___: O(1)\n    \u003e * LFUCache [example](doc/example_LFUCache.md)\n    \u003e   * `get` \u0026 `set`: O(1) \n  * ### String\n    \u003e* search_KMP\n    \u003e* search_multipatterns\n    \u003e  * todo\n  * ### Graph\n    \u003e * Graph\n    \u003e * Dijkstra\n    \u003e * topological_traversal\n  * ### Common useful functions\n    \u003e * `binary_search`\n    \u003e   * General binary search, binary_search(sorted_data, from, to, user_func), where user_func(x) defines the data as [False, ..., False, True, ..., True], this function returns the first position of 'True'.\n    \u003e   * Many practical problems can be converted to this form, like binary_find, lower_bound, upper_bound, peak position in a rotated sorted array and etc.\n    \u003e * `is_none_or_empty`\n    \u003e * `histogram_ascii`\n    \u003e * `is_sorted` \n    \u003e * `unique` \n    \u003e * `cmp`\n    \u003e * `split_data_by_func` \n    \u003e * `eq`\n    \u003e * `discrete_sample` \n    \u003e * `group_by_key_fun` \n    \u003e * `top_n`\n    \u003e * `clamp`\n    \u003e * `argmax`\n    \u003e * `argmin`\n    \u003e * `make_list`\n    \u003e * `swap`\n    \u003e * `rotate`\n    \u003e * `copy_to`\n    \u003e * `kth_smallest_element`\n    \u003e * `lower_bound`\n    \u003e * `upper_bound`\n    \u003e * `reverse_in_place`\n    \u003e * `sort_in_place`\n    \u003e * `find_first_if`\n    \u003e * `find_last_if`\n    \u003e * `next_permutation`\n    \u003e * `prev_permutation`\n    \u003e * `factorial`\n    \u003e * `combinatorial_number`\n    \u003e * `permutation_number`\n    \u003e * `combinations_with_duplicate`\n    \u003e * `longest_common_substr`\n    \u003e * `top_k_similar`\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsummerrainet2008%2Fpython_algorithms_library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsummerrainet2008%2Fpython_algorithms_library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsummerrainet2008%2Fpython_algorithms_library/lists"}