Answered step by step
Verified Expert Solution
Question
1 Approved Answer
solve this code in python Task 03 [10 Points ]: Somewhere in the universe, the Biannual Regional Alien Competition is taking place. There are N
solve this code in python
Task 03 [10 Points ]: Somewhere in the universe, the Biannual Regional Alien Competition is taking place. There are N aliens standing in a line. You will be given a permutation of N, which denotes the height of each alien. A sequence of N numbers is called permutation if it contains all integers from 1 to N exactly once. For example, the sequences [3,1,4,2],[1] and [2,1] are permutations, but [1,2,1],[0,1] and [1,3,4] - are not. In the competition, for each alien, the judge wants to count how many aliens are standing on its right side with a strictly smaller height. The judge writes the following code to solve the problem. count =0 for i in range (n): for j in range (i+1,n): if H[i]>H[j]: count+=1 However, their algorithm wasn't efficient at all. Hence, the alien calls you to write a better solution for the program. More formally, you have to count how many pairs of aliens are standing in the line such that H[i]>H[j] and iStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started