human
Median and Mode using Counting Sort | Function that sort input array a [ ] and calculate mode and median using counting sort.
The output array b [ ] will have sorted array.
Variable to store max of input array which will to have size of count array.
Auxiliary ( count ) array to store count . Initialize count array as 0. Size of count array will be equal to ( max + 1 ) ..
Store count of each element of input array.
Mode is the index with maximum count.
Update count [ ] array with sum.
Sorted output array b [ ] to calculate median.
Median according to odd and even array size respectively ..
Output the result.
Driver Code"
Solution in Python:

Write me a code to median and Mode using Counting Sort and the other steps required?
assistant
#Here is code to median and Mode using Counting Sort and the other steps required.
 def printModeMedian ( a , n ) :
	b = [ 0 ] * n
	Max = max ( a )
	t = Max + 1
	count = [ 0 ] * t
	for i in range ( n ) :
		count [ a [ i ] ] += 1
	mode = 0
	k = count [ 0 ]
	for i in range ( 1 , t ) :
		if ( count [ i ] > k ) :
			k = count [ i ]
			mode = i
	for i in range ( 1 , t ) :
		count [ i ] = count [ i ] + count [ i - 1 ]
	for i in range ( n ) :
		b [ count [ a [ i ] ] - 1 ] = a [ i ]
		count [ a [ i ] ] -= 1
	median = 0.0
	if ( n % 2 != 0 ) :
		median = b [ n // 2 ]
	else :
		median = ( ( b [ ( n - 1 ) // 2 ] + b [ n // 2 ] ) / 2.0 )
	print ( " median ▁ = " , median )
	print ( " mode ▁ = " , mode )
if __name__ == ' _ _ main _ _ ' :
	arr = [ 1 , 4 , 1 , 2 , 7 , 1 , 2 , 5 , 3 , 6 ]
	n = len ( arr )
	printModeMedian ( arr , n )