{"id":19241825,"url":"https://github.com/sanjaraiy/dsa_series","last_synced_at":"2026-06-13T06:33:28.421Z","repository":{"id":245633603,"uuid":"722570070","full_name":"sanjaraiy/DSA_Series","owner":"sanjaraiy","description":"Explore the efficiency of countSort in this DSA playground! 📊✨ Master sorting algorithms with hands-on practice.","archived":false,"fork":false,"pushed_at":"2024-06-23T00:41:25.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-23T14:35:09.066Z","etag":null,"topics":["alogrithms","countsort","cpp","data-structure-and-algorithm","data-structures","vscode"],"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/sanjaraiy.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-11-23T12:37:37.000Z","updated_at":"2024-06-23T00:41:28.000Z","dependencies_parsed_at":"2024-06-23T04:45:07.469Z","dependency_job_id":"179257b5-db1f-462e-8d33-d576600e9256","html_url":"https://github.com/sanjaraiy/DSA_Series","commit_stats":null,"previous_names":["sanjaraiy/dsa_series"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sanjaraiy/DSA_Series","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanjaraiy%2FDSA_Series","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanjaraiy%2FDSA_Series/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanjaraiy%2FDSA_Series/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanjaraiy%2FDSA_Series/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sanjaraiy","download_url":"https://codeload.github.com/sanjaraiy/DSA_Series/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanjaraiy%2FDSA_Series/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34275068,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-13T02:00:06.617Z","response_time":62,"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":["alogrithms","countsort","cpp","data-structure-and-algorithm","data-structures","vscode"],"created_at":"2024-11-09T17:12:38.369Z","updated_at":"2026-06-13T06:33:28.404Z","avatar_url":"https://github.com/sanjaraiy.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CountSort Algorithm Implementation\nThis repository contains a C++ implementation of the CountSort algorithm. CountSort is a non-comparison based sorting algorithm suitable for sorting integers within a specified range.\n\n## Overview\nCountSort operates by counting occurrences of each unique element in the input array, computing the cumulative count, and placing elements in their correct positions in the output array. It works efficiently for a limited range of integers, making it suitable for scenarios where the range of input elements is known beforehand.\n\n## Features\n- **Efficient Sorting:** CountSort achieves linear time complexity O(n + k), where n is the number of elements and k is the range of input.\n- **Stable Sorting:** Maintains the relative order of records with equal keys.\n- **Simple Implementation:** Easy to understand and implement in scenarios where the range of elements is not very large.\n\n## Usage\nTo use CountSort for sorting an array of integers:\n1. Clone the repository or download the `countSort.cpp` file.\n2. Compile the code using a C++ compiler.\n3. Execute the compiled program, providing input integers to be sorted.\n\n## Example\nConsider an input array: [4, 2, 2, 8, 3, 3, 1]\nAfter sorting using CountSort: [1, 2, 2, 3, 3, 4, 8]\n\n## How to Run\nEnsure you have a C++ compiler installed. Compile the code using the following command:\n```bash\ng++ countSort.cpp -o countSort\n```\nRun the executable:\n```bash\n./countSort\n```\n## code.cpp \n```cpp\n#include\u003ciostream\u003e\n#include\u003cvector\u003e\nusing namespace std;\n\nvoid CountSort(vector\u003cint\u003e \u0026v){\n    int n=v.size();\n\n    //find the max element\n    int max_ele=INT_MIN;\n    for(int i=0;i\u003cn;i++){\n         \n        // if(max_ele\u003cv[i]){\n        //     max_ele=v[i];\n        // }\n\n        max_ele=max(v[i],max_ele);\n\n    }\n    \n    //create the freq array\n    vector\u003cint\u003efreq(max_ele+1,0);\n    for(int i=0;i\u003cn;i++){\n        freq[v[i]]++;\n    }\n\n    //calculate cumulative freq\n    for(int i=1;i\u003c=max_ele;i++){\n        freq[i]+=freq[i-1];\n    }\n\n    //create  the ans array\n      vector\u003cint\u003eans(n);\n\n    //calculate sorted array\n    for(int i=n-1;i\u003e=0;i--){\n        ans[--freq[v[i]]]=v[i];\n    }\n\n    //copy back the ans to origional array\n    for(int i=0;i\u003cn;i++){\n        v[i]=ans[i];\n    }\n\n}\nint main(){\n    int n;\n    cin\u003e\u003en;\n    vector\u003cint\u003ev(n);\n    for(int i=0;i\u003cv.size();i++){\n        cin\u003e\u003ev[i];\n    }\n\n    CountSort(v);\n    cout\u003c\u003c\"sorted Array:\"\u003c\u003cendl;\n    for(int i=0;i\u003cn;i++){\n        cout\u003c\u003cv[i]\u003c\u003c\" \";\n    }\n}\n```\n## Contribution\nContributions are welcome! If you find any issues or have suggestions for improvements, feel free to open an issue or submit a pull request.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsanjaraiy%2Fdsa_series","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsanjaraiy%2Fdsa_series","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsanjaraiy%2Fdsa_series/lists"}