3. Python implementation of pseudocode:
1. defcompareIt(arr,genList):
2. foriinxrange(len(arr[0])):
3. genList[i]=arr[0][i]#storethefirstpair
4. print("Firststoredpair:",genList[i])
5. recurse(arr,1,genList)#recursetothenextline
6.
7. defrecurse(arr,ind,genList):
8. ifind==40:
9. print("Solutionis:",genList)
10. else:
11. #print("hitelse")
12. foriinxrange(len(arr[ind])):
13. #print("iis",i)
14. #print("arraypair:",arr[ind][i])
15. pair=arr[ind][i]#selectapair
16. foriinxrange(ind):#selecteachpreviouslineingenList
17. #print("currentgenListis:")
18. forrinxrange(ind):
19. print(genList[r])
20. #print("pair[0]is",pair[0],"genList[i][0]is:",genList[i][0])
21. ifpair[0]!=genList[i][0]:
22. #noproblem,checkotheritem
23. ifpair[1]!=genList[i][1]:
24. #noproblem,addpair
25. genList[i+1]=pair
26. #print("Recursed")
27. recurse(arr,ind+1,genList)
28. else:
29. #problem,don'tadd
30. c=0
31. #endif
32. else:
33. #problem,don'tadd
34. c=0
35. #endif
36. #endfor
37. #endfor
38. #endif
39.#endrecurse
Analysis
The time complexity of this algorithm is O(n^4). In order to reduce the actual execution
time of the program, a Hadoop cluster could be used with an advanced message queue
protocol such as RabbitMQ. RabbitMQ can be used to distribute bits and pieces of the required
computation to separate machines in each cluster. Hadoop is used for distributing processing
power and computations of a large data set throughout multiple clusters of computers. The
execution time of an optimized algorithm then relies heavily on how much computational