human
Maximum element in connected component of given node for Q queries | Function to perform the find operation to find the parent of a disjoint set.
FUnction to perform union operation of disjoint set union.
If the rank are the same.
Update the maximum value.
Function to find the maximum element of the set which belongs to the element queries [ i ].
Stores the parent elements of the sets.
Stores the rank of the sets.
Stores the maxValue of the sets.
Update parent [ i ] and maxValue [ i ] to i.
Add arr [ i ] . first and arr [ i ] . second elements to the same set.
Find the parent element of the element queries [ i ].
Print the maximum value of the set which belongs to the element P.
Driver Code"
How can the above be solved in Python?

=====
Give me a code to maximum element in connected component of given node for Q queries and the other steps required?
assistant
#Here is code to maximum element in connected component of given node for Q queries and the other steps required.
 def Find ( parent , a ) :
	if ( parent [ parent [ a ] ] != parent [ a ] ) :
		parent [ a ] = findParent ( parent , parent [ a ] )
	return parent [ a ]
def Union ( parent , rank , maxValue , a , b ) :
	a = Find ( parent , a )
	b = Find ( parent , b )
	if ( a == b ) :
		return
	if ( rank [ a ] == rank [ b ] ) :
		rank [ a ] += 1
	if ( rank [ a ] < rank [ b ] ) :
		temp = a
		a = b
		b = temp
	parent [ b ] = a
	maxValue [ a ] = max ( maxValue [ a ] , maxValue [ b ] )
def findMaxValueOfSet ( arr , queries , R , N , M ) :
	parent = [ 1 for i in range ( R + 1 ) ]
	rank = [ 0 for i in range ( R + 1 ) ]
	maxValue = [ 0 for i in range ( R + 1 ) ]
	for i in range ( 1 , R + 1 , 1 ) :
		parent [ i ] = maxValue [ i ] = i
	for i in range ( N ) :
		Union ( parent , rank , maxValue , arr [ i ] [ 0 ] , arr [ i ] [ 1 ] )
	for i in range ( M ) :
		P = Find ( parent , queries [ i ] )
		print ( maxValue [ P ] , end = " ▁ " )
if __name__ == ' _ _ main _ _ ' :
	R = 5
	arr = [ [ 1 , 2 ] , [ 2 , 3 ] , [ 4 , 5 ] ] ;
	queries = [ 2 , 4 , 1 , 3 ]
	N = len ( arr )
	M = len ( queries )
	findMaxValueOfSet ( arr , queries , R , N , M )