human
Find Union and Intersection of two unsorted arrays | Prints union of arr1 [ 0. . m - 1 ] and arr2 [ 0. . n - 1 ].
Before finding union , make sure arr1 [ 0. . m - 1 ] is smaller.
Now arr1 [ ] is smaller Sort the first array and print its elements ( these two steps can be swapped as order in output is not important ).
Search every element of bigger array in smaller array and print the element if not found.
Prints intersection of arr1 [ 0. . m - 1 ] and arr2 [ 0. . n - 1 ].
Before finding intersection , make sure arr1 [ 0. . m - 1 ] is smaller.
Now arr1 [ ] is smaller Sort smaller array arr1 [ 0. . m - 1 ].
Search every element of bigger array in smaller array and print the element if found.
A recursive binary search function . It returns location of x in given array arr [ l . . r ] is present , otherwise - 1.
If the element is present at the middle itself.
If element is smaller than mid , then it can only be presen in left subarray.
Else the element can only be present in right subarray.
We reach here when element is not present in array.
Driver code.
Function call"
How can the above be solved in Python?

=====
What is a code to find Union and Intersection of two unsorted arrays and the other steps required?
assistant
#Here is code to find Union and Intersection of two unsorted arrays and the other steps required.
 def printUnion ( arr1 , arr2 , m , n ) :
	if ( m > n ) :
		tempp = arr1
		arr1 = arr2
		arr2 = tempp
		temp = m
		m = n
		n = temp
	arr1 . sort ( )
	for i in range ( 0 , m ) :
		print ( arr1 [ i ] , end = " ▁ " )
	for i in range ( 0 , n ) :
		if ( binarySearch ( arr1 , 0 , m - 1 , arr2 [ i ] ) == - 1 ) :
			print ( arr2 [ i ] , end = " ▁ " )
def printIntersection ( arr1 , arr2 , m , n ) :
	if ( m > n ) :
		tempp = arr1
		arr1 = arr2
		arr2 = tempp
		temp = m
		m = n
		n = temp
	arr1 . sort ( )
	for i in range ( 0 , n ) :
		if ( binarySearch ( arr1 , 0 , m - 1 , arr2 [ i ] ) != - 1 ) :
			print ( arr2 [ i ] , end = " ▁ " )
def binarySearch ( arr , l , r , x ) :
	if ( r >= l ) :
		mid = int ( l + ( r - l ) / 2 )
		if ( arr [ mid ] == x ) :
			return mid
		if ( arr [ mid ] > x ) :
			return binarySearch ( arr , l , mid - 1 , x )
		return binarySearch ( arr , mid + 1 , r , x )
	return - 1
arr1 = [ 7 , 1 , 5 , 2 , 3 , 6 ]
arr2 = [ 3 , 8 , 6 , 20 , 7 ]
m = len ( arr1 )
n = len ( arr2 )
print ( " Union ▁ of ▁ two ▁ arrays ▁ is ▁ " )
printUnion ( arr1 , arr2 , m , n )
print ( " Intersection of two arrays is   " )
printIntersection ( arr1 , arr2 , m , n )