human
Kth smallest or largest element in unsorted Array | Set 4 | Function to find the Kth smallest element in Unsorted Array.
Initialize the max Element as 0.
Iterate arr [ ] and find the maximum element in it.
Frequency array to store the frequencies.
Counter variable.
Counting the frequencies.
Iterate through the freq [ ].
Check if num is present in the array.
Increment the counter with the frequency of num.
Checking if we have reached the Kth smallest element.
Return the Kth smallest element.
Driver Code.
Given array.
Function Call"
Solution in Python:

=====
Write me a code to kth smallest or largest element in unsorted Array and the other steps required?
assistant
#Here is code to kth smallest or largest element in unsorted Array and the other steps required.
 def findKthSmallest ( arr , n , k ) :
	max = 0
	for i in range ( n ) :
		if ( arr [ i ] > max ) :
			max = arr [ i ]
	counter = [ 0 ] * ( max + 1 )
	smallest = 0
	for i in range ( n ) :
		counter [ arr [ i ] ] += 1
	for num in range ( 1 , max + 1 ) :
		if ( counter [ num ] > 0 ) :
			smallest += counter [ num ]
		if ( smallest >= k ) :
			return num
if __name__ == " _ _ main _ _ " :
	arr = [ 7 , 1 , 4 , 4 , 20 , 15 , 8 ]
	N = len ( arr )
	K = 5
	print ( findKthSmallest ( arr , N , K ) )