amanraj1608 / dsa-implementation Goto Github PK
View Code? Open in Web Editor NEWData Structure and Algorithms Implementation
Home Page: https://amanraj1608.github.io/DSA-Implementation/
Data Structure and Algorithms Implementation
Home Page: https://amanraj1608.github.io/DSA-Implementation/
Overview:
Our repository currently offers a variety of sorting algorithms, such as bubble sort, insertion sort, merge sort, quick sort, and selection sort. However, an important sorting algorithm that is missing from our collection is Counting Sort. Counting Sort is known for its efficiency in scenarios where the range of input values is known and relatively small compared to the number of elements to be sorted. It operates in linear time complexity, making it one of the fastest sorting algorithms for such scenarios.
Proposal:
This issue proposes the addition of Counting Sort to our repository's collection of sorting algorithms. By incorporating Counting Sort, we can provide users with a more comprehensive suite of sorting options and showcase the versatility of different sorting techniques.
Tasks:
Implement Counting Sort: Write an implementation of Counting Sort in C++, Python, Java, or any other language supported by our repository. Ensure that the implementation adheres to best practices and follows a clear, understandable coding style.
Documentation: Provide comprehensive documentation for the Counting Sort implementation. This documentation should include details about the algorithm's time complexity analysis, use cases, and any limitations or considerations for its usage. Clear and concise documentation will help users understand when and how to use Counting Sort effectively.
Testing: Write test cases to verify the correctness and performance of the Counting Sort implementation. Thorough testing is essential to ensure that the algorithm behaves as expected and performs efficiently across various input scenarios.
Integration: Integrate the Counting Sort implementation into our repository's existing sorting algorithms module. Ensure consistency in code style and organization to maintain the overall quality of the codebase.
Update Documentation: Update relevant documentation files, such as README.md, to reflect the addition of Counting Sort. Provide usage instructions for users, including examples demonstrating how to use Counting Sort in their projects.
Expected Outcome:
By addressing this issue, we aim to enhance the functionality and completeness of our repository's sorting algorithms collection. The addition of Counting Sort will empower users with another valuable tool for efficient data sorting, further solidifying our repository as a comprehensive resource for sorting algorithms.
Contributors are encouraged to take on this task and contribute their implementation of Counting Sort to our repository. Let's collaborate to expand and improve our sorting algorithms library!
C++ Implementation:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
void countingSort(vector<int>& arr) {
int maxElement = *max_element(arr.begin(), arr.end());
int minElement = *min_element(arr.begin(), arr.end());
int range = maxElement - minElement + 1;
vector<int> count(range), output(arr.size());
for (int i = 0; i < arr.size(); i++) {
count[arr[i] - minElement]++;
}
for (int i = 1; i < range; i++) {
count[i] += count[i - 1];
}
for (int i = arr.size() - 1; i >= 0; i--) {
output[count[arr[i] - minElement] - 1] = arr[i];
count[arr[i] - minElement]--;
}
for (int i = 0; i < arr.size(); i++) {
arr[i] = output[i];
}
}
int main() {
vector<int> arr = {4, 2, 2, 8, 3, 3, 1};
countingSort(arr);
cout << "Sorted array: ";
for (int num : arr) {
cout << num << " ";
}
cout << endl;
return 0;
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.