{"id":20063284,"url":"https://github.com/markdtw/algorithms","last_synced_at":"2025-07-27T12:40:02.212Z","repository":{"id":93067249,"uuid":"50934633","full_name":"markdtw/algorithms","owner":"markdtw","description":"Some algorithms implemented in C","archived":false,"fork":false,"pushed_at":"2017-06-29T09:05:59.000Z","size":13,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-02T10:31:13.940Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","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/markdtw.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-02-02T16:33:13.000Z","updated_at":"2019-02-24T09:09:32.000Z","dependencies_parsed_at":"2023-06-04T15:15:42.154Z","dependency_job_id":null,"html_url":"https://github.com/markdtw/algorithms","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/markdtw/algorithms","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markdtw%2Falgorithms","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markdtw%2Falgorithms/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markdtw%2Falgorithms/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markdtw%2Falgorithms/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/markdtw","download_url":"https://codeload.github.com/markdtw/algorithms/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markdtw%2Falgorithms/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267359984,"owners_count":24074867,"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","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-11-13T13:41:30.384Z","updated_at":"2025-07-27T12:40:02.027Z","avatar_url":"https://github.com/markdtw.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Algorithms\nSome algorithms implemented in C.\n\n## Bellman-Ford:\nComputes shortest paths from a single source to all other vertices in a weighted directed graph.\n\n```bash\n./a.out \u003cinput file\u003e \u003csource\u003e\n```\n`input file`: line1: number of vertices, line2~n: adjacency matrix of the graph.\u003cbr\u003e\n`source`: the source vertice.\n\nThis will save a `bellman_ford_out.txt` file to the directory.\n\n## Find Max Sum in Array:\nFind maximum sub-array in an array.\n\n```bash\n./a.out\n```\n`elements`: the size of the randomly generated array\n\nAlso provide an optimized version.\n\n## Johnson Algorithm:\nComputes shortest paths between all pairs of vertices in a sparse, edge weighted, directed graph.\n\nThe algorithm works as this:\n1. add a node q to the graph, connected by zero-weight edges to each of the other nodes.\n2. do bellman ford algorithm from source q, resulting h(v) of a path from q to v. Terminate if negative weight cycle is found.\n3. reweight the graph by w(u, v)' = w(u, v) + h(u) - h(v)\n4. remove q and do dijkstra algorithm to find the shortest paths from each node s to every other vertex in the reweighted graph.\n\n```bash\n./a.out \u003cinput file\u003e\n```\n`input file`: line1: number of vertices, line2: number of edges, line3~n: \u003cvertex\u003e \u003cvertex\u003e \u003cedge weight\u003e.\n\nThis will save a `johnson_out.txt` file to the directory.\n   \n## Merge Inversion:\nCounts how many inversions used in a merge sort.\n\n```bash\n./a.out\n```\n`10 numbers`: give an array.\n\n## N-Queen problem:\nThe classic N-Queen problem.\n\n## Optimal Binary Search Tree:\nComputes the optimal binary search tree given probabilities pi and qj.\n\n```bash\n./a.out \u003cinput file\u003e\n```\n`input file`: line1: (node 1, probability p1) (node 2, proba...), line2: (dummy keys 0, probability q0) (dummy keys 1, proba...)\n\nThis will save a `optimal_bst_out.txt` file to the directory.\n\n## Shannon-Fano coding:\nConstruct a prefix code based on a set of symbols and their probabilities.\n\n```bash\n./a.out\n```\n`8 elements`: number in sorted order\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkdtw%2Falgorithms","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarkdtw%2Falgorithms","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkdtw%2Falgorithms/lists"}