Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1 . Problem Statement In a wedding party, there are n children invited and all of them are seated in a line. Initially, few candies
Problem Statement
In a wedding party, there are n children invited and all of them are seated in a line. Initially,
few candies were distributed to each child and some children were missed and did not
receive any candy. Our aim is to give an equal number of candies to each child.
In order to do so we can choose each move such that any m m n children can
pass one of their candy to their neighboring child at the same time.
Given an integer array candies representing the number of candies with each child from left
to right on the line, return the minimum number of moves to make all the children have the
same number of candies. If it is not possible to do return
Constraints:
n candies.length
n
candiesi
Requirements
Formulate an efficient algorithm using Greedy Technique.
Implement the above problem statement using Python
Read the input from a file inputPStxt and Print the sequence of events and total
time taken for the entire queue of processes to be executed.
You will output your answers to a file outputPStxt for each line.
Perform an analysis for the features above and give the running time in terms of
input size: n along with justification.
Example Input:
Sample Input:
Input will be taken from the fileinputPStxt
Sample Input Example
A candies
B candies
C candies
Sample Output:
Display the output in outputPStxt
A
Explanation: This is only written for your understanding, you dont need to
output the steps
st move:
nd move:
rd move:
B
Explanation: This is only written for your understanding, you dont need to
output the steps
st move:
nd move:
C
Explanation: This is only written for your understanding, you dont need to
output the steps
It is impossible to make all three children have the same number of candies.
Note that the inputoutput data shown here is only for understanding and
testing, the actual file used for evaluation will be different
Deliverables
PDF document designPSpdf detailing your design approach and time
complexity of the algorithm and alternate solutions.
Group idContribution.xlsx mentioning the contribution of each student in terms of
percentage of work done. Columns must be Student Registration NumberName
Percentage of contribution out of If a student did not contribute at all, it will be
if all contributed then for all.
inputPStxt file used for testing
outputPStxt file generated while testing
py file containing the python code. Create a single py file for code. Do not fragment
your code into multiple files.
Zip all of the above files including the design document and contribution file in a
folder with the name: Group idAPSzip and submit the zipped file in canvas.
Group Id should be given as Gxx where xx is your group number. For example, if your
group is then you will enter G as your group id
Instructions
It is compulsory to make use of the data structures algorithms mentioned in the
problem statement.
Ensure that all data structure insert and delete operations throw appropriate messages
when their capacity is empty or full. Also ensure basic error handling is implemented.
For the purposes of testing, you may implement some functions to print the data
structures or other test data. But all such functions must be commented before
submission.
Make sure that your read, understand, and follow all the instructions
Ensure that the input, prompt and output file guidelines are adhered to Deviations from
the mentioned formats will not be entertained.
The input, prompt and output samples shown here are only a representation of the
syntax to be used. Actual files used to evaluate the submissions will be different.
Hence, do not hard code any values into the code.
Run time analysis is to be provided in asymptotic notations and not timestamp based
runtimes in sec or milliseconds.
Please note that the design document must include:
a The data structure model you chose with justifications
b Details of each operations with the time complexity and reasons why the chosen
operations are efficient for the given representation
c One alternate way of modeling the problem with the cost implications.
Writing a good technical report and well documented code is an art. Your report cannot
exceed pages. Your code must be modular and quite well documented.
You may ask queries in the dedicated discussion section. Beware that only
hints will be provided and queries asked in other channels will not be
responded to
Instructions for use of Python:
Implement the above problem statement using Python
Use only native data types like lists andDeliverables
PDF document designPS
Step 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