human
Find Second largest element in an array | Set 2 | Function to find the largest element in the array arr [ ].
Base Condition.
Initialize an empty list.
Divide the array into two equal length subarrays and recursively find the largest among the two.
Store length of compared1 [ ] in the first index.
Store the maximum element.
Return compared1 which contains the maximum element.
Store length of compared2 [ ] in the first index.
Store the maximum element.
Return compared2 [ ] which contains the maximum element.
Function to print the second largest element in the array arr [ ].
Find the largest element in arr [ ].
Find the second largest element in arr [ ].
Print the second largest element.
Driver Code"
How can the above be solved in Python?
 ... Can you provide a code to find Second largest element in an array and the other steps required?
assistant
#Here is code to find Second largest element in an array and the other steps required.
 def findLargest ( beg , end , arr , n ) :
	if ( beg == end ) :
		compared = [ 0 ] * n
		compared [ 0 ] = 1
		compared [ 1 ] = arr [ beg ]
		return compared
	compared1 = findLargest ( beg , ( beg + end ) // 2 , arr , n )
	compared2 = findLargest ( ( beg + end ) // 2 + 1 , end , arr , n )
	if ( compared1 [ 1 ] > compared2 [ 1 ] ) :
		k = compared1 [ 0 ] + 1
		compared1 [ 0 ] = k
		compared1 [ k ] = compared2 [ 1 ]
		return compared1
	else :
		k = compared2 [ 0 ] + 1
		compared2 [ 0 ] = k
		compared2 [ k ] = compared1 [ 1 ]
		return compared2
def findSecondLargest ( end , arr ) :
	compared1 = findLargest ( 0 , end - 1 , arr , end )
	compared2 = findLargest ( 2 , compared1 [ 0 ] + 2 , compared1 , compared1 [ 0 ] )
	print ( compared2 [ 1 ] )
N = 10
arr = [ 20 , 1990 , 12 , 1110 , 1 , 59 , 12 , 15 , 120 , 1110 ]
findSecondLargest ( N , arr )