Skip to content

hashibk/CountingSort

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Counting Sort Algorithm

This C++ program implements the Counting Sort algorithm to sort a list of integers. It first counts the occurrences of each integer and then sorts the integers based on these counts.

Features

  • Dynamic Array Allocation: Allocates arrays dynamically based on user input.
  • Counting Occurrences: Counts how many times each integer appears in the input.
  • Sorting: Sorts integers using the counting sort algorithm.
  • Display Results: Outputs the sorted integers.

Usage

  1. Enter Value for x: Input the number of integers you want to sort.
  2. Input Integers: Provide the integers one by one.
  3. Sort and Display: The program sorts the integers using counting sort and displays the sorted result.

Example

In the given code:

  • User inputs the number of integers, for example, 5.
  • User then inputs the integers, for example, 3 1 2 1 0.
  • The program counts the occurrences of each integer and sorts them.

Output:

1 2 3 4 5

About

This C++ program implements the Counting Sort algorithm. It reads a list of integers from the user, counts the occurrences of each integer, and then sorts the integers in ascending order using the counting technique.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages