pixel assume that each pixel can take any integer value in the range to the problem is to find the number of pixels of each color value and then sort the color values with respect to the number of times each value appears in the picture assume that the picture is rectangle with pixels pseudocode algorithm to solve the problem follows for ( = <ci++/initialize count count[ for ( = <pi++/look at all of the pixels count[value( )]++/increment pixel value count sort(count)/sort pixel value counts in this examplecount is an array of size that stores the number of pixels for each color value function value(ireturns the color value for pixel the time for the first for loop (which initializes countis based on the number of colorsc the time for the second loop (which determines the number of pixels with each coloris th( the time for the final linethe call to sortdepends on the cost of the sorting algorithm used from the discussion of section we can assume that the sorting algorithm has cost th( log if items are sortedthus yielding th( log as the total algorithm cost is this good representation for the cost of this algorithmwhat is actually being sortedit is not the pixelsbut rather the colors what if is much smaller than then the estimate of th( log is pessimisticbecause much fewer than items are being sorted insteadwe should use as our analysis variable for steps that look at each pixeland as our analysis variable for steps that look at colors then we get th(cfor the initialization loopth( for the pixel count loopand th( log cfor the sorting operation this yields total cost of th( log cwhy can we not simply use the value of for input size and say that the cost of the algorithm is th( log )becausec is typically much less than for examplea picture might have pixels and range of possible colors sop is one millionwhich is much larger than log butif is smalleror larger (even if it is still less than )then log can become the larger quantity thusneither variable should be ignored space bounds besides timespace is the other computing resource that is commonly of concern to programmers just as computers have become much faster over the yearsthey have also received greater allotments of memory even sothe amount of available disk space or main memory can be significant constraints for algorithm designers