There is a group of n children standing in a queue, where their ages are listed in the array A[ ]. The children are standing randomly in the queue. Most probably, their ages in the array A[ ] are randomly listed too. For each child, you are required to search for the next older child in the queue and to print the difference of their ages. Print all the outputs in an array Out[ ]. a) Design an efficient algorithm to solve this problem. [The efficiency of your algorithm is the main driver of the mark], and analyze the complexity of your solution. [full explanation of your answer should be provided] b) Develop a python code to implement your efficient algorithm. [The marks depend on the correctness of the code, indentation, comments, test-case] c) Prepare a brief report (250 words) comparing the two algorithms
There is a group of n children standing in
a queue, where their ages are listed in
the array A[ ]. The children are standing
randomly in the queue. Most probably,
their ages in the array A[ ] are randomly
listed too. For each child, you are
required to search for the next older child
in the queue and to print the difference of
their ages. Print all the outputs in an array
Out[ ].
a) Design an efficient
algorithm is the main driver of the mark], and analyze the complexity of your solution.
[full explanation of your answer should be provided]
b) Develop a python code to implement your efficient algorithm. [The marks
depend on the correctness of the code, indentation, comments, test-case]
c) Prepare a brief report (250 words) comparing the two algorithms
Step by step
Solved in 2 steps