Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are in charge of distributing chairs to children at a recreational event. You have a stock of n chairs available for n children. Each

You are in charge of distributing chairs to children at a recreational event. You have a stock
of n chairs available for n children. Each child and each chair has a size, which is an integer
between 1 and k, inclusive. Ideally, a size i chair should be used by a size i child. However,
any child can use any available chair, although a bit uncomfortably.
You are given two size-n arrays: chair[] and child[]. chair[i] is the size of the ith chair, and
child[i is the size of the ith child. The discomfort a child experiences is the absolute value of
the difference between the size of the child and the size of the chair that is paired with the
child. The total discomfort is the sum of the discomfort experienced by each of the children.
Provide an efficient algorithm to minimize the total discomfort between all children and their
paired chairs. Prove that your algorithm is correct.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions