{"id":18822897,"url":"https://github.com/salma-mamdoh/sorting-algorithms","last_synced_at":"2025-10-20T01:46:53.446Z","repository":{"id":178186669,"uuid":"661461240","full_name":"Salma-Mamdoh/Sorting-Algorithms","owner":"Salma-Mamdoh","description":"Our project for Data Structures Course taken during fall 2023 semester","archived":false,"fork":false,"pushed_at":"2023-07-03T00:04:40.000Z","size":16,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-30T04:18:38.957Z","etag":null,"topics":["analysis","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Salma-Mamdoh.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-07-02T23:10:25.000Z","updated_at":"2024-05-07T15:43:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"c13bbdc8-ecc4-454f-99fc-a07eb977a9c8","html_url":"https://github.com/Salma-Mamdoh/Sorting-Algorithms","commit_stats":null,"previous_names":["salma-mamdoh/sorting--algorithms"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Salma-Mamdoh%2FSorting-Algorithms","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Salma-Mamdoh%2FSorting-Algorithms/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Salma-Mamdoh%2FSorting-Algorithms/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Salma-Mamdoh%2FSorting-Algorithms/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Salma-Mamdoh","download_url":"https://codeload.github.com/Salma-Mamdoh/Sorting-Algorithms/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239758889,"owners_count":19692041,"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":["analysis","cpp","sorting-algorithms"],"created_at":"2024-11-08T00:52:01.930Z","updated_at":"2025-10-20T01:46:48.406Z","avatar_url":"https://github.com/Salma-Mamdoh.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n  \u003chead\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003ch1\u003eSorting Algorithms\u003c/h1\u003e\n    \u003cp\u003eIn this project, we implemented several sorting algorithms using templates to sort data of different types. The algorithms we implemented are:\u003c/p\u003e\n    \u003cul\u003e\n      \u003cli\u003eInsertion sort\u003c/li\u003e\n      \u003cli\u003eSelection sort\u003c/li\u003e\n      \u003cli\u003eBubble sort\u003c/li\u003e\n      \u003cli\u003eShell sort\u003c/li\u003e\n      \u003cli\u003eCount sort\u003c/li\u003e\n      \u003cli\u003eMerge sort\u003c/li\u003e\n      \u003cli\u003eQuick sort\u003c/li\u003e\n    \u003c/ul\u003e\n    \u003ch2\u003eImplementation\u003c/h2\u003e\n    \u003cp\u003eEach algorithm is implemented as a separate function using templates. We tested each algorithm on randomly generated arrays of sizes 200, 500, 1000, 5000, 10000, 20000, and 50000. We calculated the running time on each dataset and drew a plot for each algorithm to see how the running time changes according to the different sizes of datasets.\u003c/p\u003e\n    \u003ch2\u003eResults\u003c/h2\u003e\n    \u003ch3\u003eInsertion sort\u003c/h3\u003e\n    \u003cp\u003eInsertion sort is a simple sorting algorithm that works the way we sort playing cards in our hands. It has an average time complexity of O(n^2).\u003c/p\u003e\n    \u003cimg width =500 src=\"https://github.com/Salma-Mamdoh/Sorting--Algorithms/assets/52897508/5bcebbec-c505-4d45-a6da-aca9c4286072).png\" alt=\"Insertion sort plot\"\u003e\n    \u003cp\u003eAs we can see from the plot, the running time of insertion sort increases drastically as the size of the dataset increases. Therefore, it is not recommended to use insertion sort for large datasets.\u003c/p\u003e\n    \u003ch3\u003eSelection sort\u003c/h3\u003e\n    \u003cp\u003eSelection sort is an in-place comparison sorting algorithm that has an average time complexity of O(n^2).\u003c/p\u003e\n    \u003cimg width=500 src=\"https://github.com/Salma-Mamdoh/Sorting--Algorithms/assets/52897508/7a6c32cf-fbe4-4392-be68-6350caec43ab)\" alt=\"Selection sort plot\"\u003e\n    \u003cp\u003eAs we can see from the plot, the running time of selection sort increases significantly as the size of the dataset increases. Therefore, it is not recommended to use selection sort for large datasets.\u003c/p\u003e\n    \u003ch3\u003eBubble sort\u003c/h3\u003e\n    \u003cp\u003eBubble sort is a simple sorting algorithm that repeatedly steps through the list, compares adjacent elements and swaps them if they are in the wrong order. It has an average time complexity of O(n^2).\u003c/p\u003e\n    \u003cimg width=500 src=\"https://github.com/Salma-Mamdoh/Sorting--Algorithms/assets/52897508/d41568a6-fc53-4cf0-9919-94ac96b5885d)\" alt=\"Bubble sort plot\"\u003e\n    \u003cp\u003eAs we can see from the plot, the running time of bubble sort increases significantly as the size of the dataset increases. Therefore, it is not recommended to use bubble sort for large datasets.\u003c/p\u003e\n    \u003ch3\u003eShell sort\u003c/h3\u003e\n    \u003cp\u003eShell sort is an in-place comparison sorting algorithm that is a generalization of insertion sort. It has an average time complexity of O(n^2).\u003c/p\u003e\n    \u003cimg width=500 src=\"https://github.com/Salma-Mamdoh/Sorting--Algorithms/assets/52897508/4f6937b0-ebf6-4fe7-a7a8-e78a827f3167)\" alt=\"Shell sort plot\"\u003e\n    \u003cp\u003eAs we can see from the plot, the running time of shell sort increases significantly as the size of the dataset increases. Therefore, it is not recommended to use shell sort for large datasets.\u003c/p\u003e\n    \u003ch3\u003eCount sort\u003c/h3\u003e\n    \u003cp\u003eCount sort is an efficient algorithm for sorting arrays with small integer values. It has a time complexity of O(n+k), where k is the maximum value in the array.\u003c/p\u003e\n    \u003cimg width=500 src=\"https://github.com/Salma-Mamdoh/Sorting--Algorithms/assets/52897508/5e4c83c9-2ba0-4030-80e0-2087876a6f5a)\" alt=\"Count sort plot\"\u003e\n    \u003cp\u003eAs we can see from the plot, the running time of count sort is very low and almost constant, regardless of the size of the dataset. Therefore, count sort is a good choice for sorting arrays with small integer values.\u003c/p\u003e\n    \u003ch3\u003eMerge sort\u003c/h3\u003e\n    \u003cp\u003eMerge sort is a divide-and-conquer algorithm that recursively divides the input array into two halves, sorts each half, and then merges the sorted halves. It has a time complexity of O(n log n).\u003c/p\u003e\n    \u003cimg width=500 src=\"https://github.com/Salma-Mamdoh/Sorting--Algorithms/assets/52897508/3e4648d9-cfd5-44fa-acc4-e42819fc663c)\" alt=\"Merge sort plot\"\u003e\n    \u003cp\u003eAs we can see from the plot, the running time of merge sort increases slowly as the size of the dataset increases. Therefore, merge sort is a good choice for large datasets.\u003c/p\u003e\n    \u003ch3\u003eQuick sort\u003c/h3\u003e\n    \u003cp\u003eQuick sort is a divide-and-conquer algorithm that selects a pivot element and partitions the input array around the pivot, recursively sorting the two subarrays. It has an average time complexity of O(n log n).\u003c/p\u003e\n    \u003cimg width=500 src=\"https://github.com/Salma-Mamdoh/Sorting--Algorithms/assets/52897508/3dcaa791-0d83-42b3-8941-6f417c046d91)\" alt=\"Quick sort plot\"\u003e\n    \u003cp\u003eAs we can see from the plot, the running time of quick sort increases slowly as the size of the datasetincreases. Therefore, quick sort is a good choice for large datasets.\u003c/p\u003e\n    \u003ch2\u003eConclusion\u003c/h2\u003e\n    \u003cp\u003eIn conclusion, we implemented several sorting algorithms using templates and tested them on randomly generated arrays of different sizes to analyze their running time. We found that count sort is a good choice for sorting arrays with small integer values, while merge sort and quick sort are good choices for large datasets. On the other hand, insertion sort, selection sort, bubble sort, and shell sort are not recommended for large datasets due to their significantly increasing running time.\u003c/p\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsalma-mamdoh%2Fsorting-algorithms","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsalma-mamdoh%2Fsorting-algorithms","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsalma-mamdoh%2Fsorting-algorithms/lists"}