{"id":21327694,"url":"https://github.com/mostafa-wael/hybrid-sorting-algorithm","last_synced_at":"2026-05-15T22:01:34.091Z","repository":{"id":112397947,"uuid":"310942893","full_name":"Mostafa-wael/Hybrid-Sorting-Algorithm","owner":"Mostafa-wael","description":"A hybrid sorting algorithm that is independent of the input sample size and its sorting status 🃏","archived":false,"fork":false,"pushed_at":"2021-02-07T16:45:54.000Z","size":187,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-22T12:45:52.904Z","etag":null,"topics":["cpp","sorting-algorithms"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Mostafa-wael.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2020-11-07T22:26:54.000Z","updated_at":"2021-02-07T16:45:57.000Z","dependencies_parsed_at":"2023-06-19T05:36:57.306Z","dependency_job_id":null,"html_url":"https://github.com/Mostafa-wael/Hybrid-Sorting-Algorithm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mostafa-wael%2FHybrid-Sorting-Algorithm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mostafa-wael%2FHybrid-Sorting-Algorithm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mostafa-wael%2FHybrid-Sorting-Algorithm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mostafa-wael%2FHybrid-Sorting-Algorithm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mostafa-wael","download_url":"https://codeload.github.com/Mostafa-wael/Hybrid-Sorting-Algorithm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243806084,"owners_count":20350775,"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":["cpp","sorting-algorithms"],"created_at":"2024-11-21T21:19:03.874Z","updated_at":"2025-10-20T11:02:11.058Z","avatar_url":"https://github.com/Mostafa-wael.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hybrid Sorting Algorithm\n\n## Objective:\n-\tCreating a hybrid sorting algorithm that is independent of the input sample size and its sorting status.\n\n## Approach:\n-\tCreating a hybrid optimized version of the merge and quick sorts.\n-\tChecking the sorting status of the list to choose the proper algorithm to procced with it.\n- If more than 90% of the list were sorted, Insertion sort is chosen since, it has the least running time for sorted lists.\n- If less than 90% and more than 60% of the list were sorted, hybrid merge sort proved to have the least running time for the semi-sorted lists.\n- If less than 60% of the list were sorted, hybrid quick sort proved to have the least running time for the unsorted lists.\n\n### Hybrid Quick Sort:\n-\tChoosing a pivot that represents the median value of the first, middle and last elements.\n-\tIf the size of the list after portioning is less than a specified threshold, an adapted version of insertion sort is used since that, it proved to have the least running time for small lists regardless of their sorting status.\n\n### Hybrid Merge Sort:\n-\tIf the size of the list after portioning is less than a specified threshold, an adapted version of insertion sort is used since that, it proved to have the least running time for small lists regardless of their sorting status.\n\n## Achievements:\n- Creating a hybrid quick sort that is two times faster than the normal quick sort for sorted lists.\n-\tCrating a hybrid sort that has the best-case time complexity (O(nlogn)) for any input size regardless of the data being sorted or not.\n\n---\n\u003eTo test the code:\n\u003e 1. Open the terminal in your current working directory.\n\u003e 2. Type \"python runscript.py n data.txt\" where n is any valid integer.\n\u003e 3. Type \"g++ -O3 SortingAlgo.cpp -o SortingAlgo\".\n\u003e 4. Type \"SortingAlgo 1 data.txt sorted_data.txt running_time.txt\", you can change the name of the second two files.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmostafa-wael%2Fhybrid-sorting-algorithm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmostafa-wael%2Fhybrid-sorting-algorithm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmostafa-wael%2Fhybrid-sorting-algorithm/lists"}