KodeKnight
  • Data Structures
    Array Stack Queue Linked List Tree Heap Graph Trie HashTable
  • Algorithms
    Recursion Divide And Conquer Greedy Dynamic Programming Backtracking Randomized Searching Sorting
  • About
    About Resume
  • Tags
  • Categories
  • Companies
  • Difficulty
  • Search
KodeKnight

Search KodeKnight

×
 
Custom Search
Sort by
Relevance
Date

counting-sort


Given an array of 100,000 pixel color values and each of which is an integer in the range (0,255). Give sorting algorithm.

 Posted on January 22, 2014  (Last modified on August 7, 2020)  |  1 minutes  |  Kinshuk Chandra

We should use counting sort.

There are only 256 key value, so aux array will have only 256 values, and in O(n) time and 2 passes we will be able to sort in efficient way.

kodeknight  range  counting-sort  sorting  integer-sort  count 

Kinshuk Chandra  • © 2020  •  KodeKnight

Hugo v0.74.3 powered  •  Theme Beautiful Hugo adapted from Beautiful Jekyll