{"id":15397327,"url":"https://github.com/bloomca/algorithms","last_synced_at":"2025-03-28T00:18:52.395Z","repository":{"id":84079380,"uuid":"63779615","full_name":"Bloomca/algorithms","owner":"Bloomca","description":"Computer Science Algorithms in Python for educational purposes","archived":false,"fork":false,"pushed_at":"2016-07-26T19:15:06.000Z","size":12,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-02T02:15:53.801Z","etag":null,"topics":["algorithms","dijkstra","heap","learning","python","sorting-algorithms"],"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/Bloomca.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":"2016-07-20T12:29:20.000Z","updated_at":"2017-06-28T18:21:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"5fc49153-7481-47ad-856f-5ec33596a402","html_url":"https://github.com/Bloomca/algorithms","commit_stats":{"total_commits":3,"total_committers":1,"mean_commits":3.0,"dds":0.0,"last_synced_commit":"a36fc0334b02793c914959664dbc11c4e71a72a3"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bloomca%2Falgorithms","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bloomca%2Falgorithms/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bloomca%2Falgorithms/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bloomca%2Falgorithms/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Bloomca","download_url":"https://codeload.github.com/Bloomca/algorithms/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245944109,"owners_count":20697960,"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","dijkstra","heap","learning","python","sorting-algorithms"],"created_at":"2024-10-01T15:37:03.022Z","updated_at":"2025-03-28T00:18:52.368Z","avatar_url":"https://github.com/Bloomca.png","language":"Python","readme":"# Algorithms\n\nThis repository contains self-written algorithms in Python strictly for educational purposes. Don't try to run it in production!\nHere there are pretty basic algorithms — I've tried to comment source code and add tests to all of them.\n\nNow I have next algorithms:\n\n- Merge sort with inversions counting implementation\n    \n    It is the simplest [algorithm](https://en.wikipedia.org/wiki/Merge_sort) which just cut array into smallest versions and then combine in subroutine. It is running in `O(n * log(n))`\n\n- Quicksort algorithm\n    \n    This algorithm is a bit trickier -- we select pivot element, and partition elements around it into new arrays, and then combine them (they will be sorted in place). For better result it is usually written as randomized algorithm, and has average complexity as `O(n * log(n))`, and in worst case it has `O(n^2)`. Here I've implemented non-randomized pivot selection, so it is `O(n^2)` complexity, though the randomized pivot selection function is the easiest one.\n\n- Minimum cut algorithm\n    \n    This algorithm finds [minimum cut](https://en.wikipedia.org/wiki/Minimum_cut) of the given graph. It uses [contraction algorithm of Karger](https://en.wikipedia.org/wiki/Karger%27s_algorithm), which is randomized algorithm with pretty small chances, but when running a lot of times, chances are pretty good. I run it n^2 times, where `n` is number of edges\n\n- Strongly connected components\n    \n    This algorithms finds strongly connected components in given directed graph. It is an implementation of [Kosaraju's algorithm](https://en.wikipedia.org/wiki/Kosaraju%27s_algorithm).\n\n- Dijkstra's shortest path algorithm\n    \n    This is a naive implementation of famous [Dijkstra's algorithm](https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm) to find shortest path from vertex `s` to `v`, if it exists. It works only edges are non-negative (or, strictly speaking, if all edges, except those who go from the initial vertex `s`).\n\nAnd data structures:\n\n- Heap\n\n    [Heap](https://en.wikipedia.org/wiki/Heap_%28data_structure%29) is a data structure to quickly extract minimum (or maximum) element, in `O(log(n))`, and insert new elements without violating heap property in the same time. O(log(n)).\n    Here I have the most basic implementation of [binary heap](https://en.wikipedia.org/wiki/Binary_heap) data structure, which supports both min and max usage, storing all data in single array with few rules. First — each node has it's children in `i * 2 + 1/2` indices, and the second is that after extracting and insertion we have to rearrange internal array. When we insert a new element, we add it to the end, and then start to swap with parent if it violates the heap property. If we extract an element, then we have to place the last element to root position, and then swap it with children if it violates. \n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbloomca%2Falgorithms","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbloomca%2Falgorithms","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbloomca%2Falgorithms/lists"}