0% found this document useful (0 votes)
6 views5 pages

Problem Set 2: Divide & Conquer: CS 3510: Design & Analysis of Algorithms

This document outlines Problem Set 2 for CS 3510, focusing on Divide & Conquer algorithms, with a due date of January 20th, 2025. It includes four problems requiring the design of algorithms, justification of correctness, and runtime analysis, emphasizing the need for clear explanations and adherence to specific formatting guidelines. Solutions must be typed, and handwritten submissions will not be accepted.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views5 pages

Problem Set 2: Divide & Conquer: CS 3510: Design & Analysis of Algorithms

This document outlines Problem Set 2 for CS 3510, focusing on Divide & Conquer algorithms, with a due date of January 20th, 2025. It includes four problems requiring the design of algorithms, justification of correctness, and runtime analysis, emphasizing the need for clear explanations and adherence to specific formatting guidelines. Solutions must be typed, and handwritten submissions will not be accepted.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

CS 3510: Design & Analysis of Algorithms January 14th 2025

Problem Set 2: Divide & Conquer


YOUR NAME HERE Due: January 20th 2025

• Please type your solutions using LATEX or any other software. Handwritten solutions will not
be accepted for this assignment.

• Your algorithms must be in plain English & mathematical expressions. Pseudo-code without
sufficient explanation will receive no credit.

• If we ask for an algorithm with a specific runtime, we will only accept answers with that
specific runtime, even if a faster solution exists. If we ask for an “efficient” algorithm, we
will not accept answers if a faster algorithm than the one provided exists.

• Unless a question explicitly states that no work is required to be shown, you must provide
an explanation or justification for your answer.

• Unless otherwise stated, all logarithms are to base two and all arrays are 1-indexed.
1.) Let A be an array of strictly increasing integers. We want to be able to find the index of the
number closest to its index. Specifically, we want to find i such that |A[i] − i| is minimized. If
there are multiple candidates, you only need to return one of them. Provide an efficient divide-
and-conquer algorithm to find such an i. See the note about 1-indexing on the first page
of the assignment.

As an example, let the array be A = [−10, −3, 0, 6, 9, 14, 15, 20]. The expected return value is
i = 4.

(a.) Describe your algorithm to a degree where someone could implement it if given your answer.
Please reference “Algorithm Design” in the Assignment Guidelines uploaded to
Canvas.

Solution: [Write your answer here]

(b.) Argue why your algorithm is correct (given any input, why does your algorithm produce the
correct outputs). Please reference “Algorithm Analysis” in the Assignment Guide-
lines uploaded to Canvas.

Solution: [Write your answer here]

(c.) Give the runtime of your algorithm and explain the reasoning.

Solution: [Write your answer here]


2.) Given a list of jobs, J, where each job requires a certain number of minutes to complete, and
an integer c representing the number of computers you have, you need to assign the jobs to your
computers. Each computer must handle a contiguous group of jobs, and your goal is to minimize
the maximum number of work hours assigned to any computer.

For example, if J = [50, 100, 150, 200, 250, 300] and c = 3, the most balanced assignment would
be to give the first computer the tasks requiring [50, 100, 150] minutes, the second computer the
tasks requiring [200, 250] minutes, and the third computer the task requiring [300] minutes. This
results in workloads of 300, 450, and 300 minutes, respectively, and no assignment would reduce
the maximum workload below 450 minutes.

(a.) Describe your algorithm to a degree where someone could implement it if given your answer.
Please reference “Algorithm Design” in the Assignment Guidelines uploaded to
Canvas.

Solution: [Write your answer here]

(b.) Argue why your algorithm is correct (given any input, why does your algorithm produce the
correct outputs). Please reference “Algorithm Analysis” in the Assignment Guide-
lines uploaded to Canvas.

Solution: [Write your answer here]

(c.) Give the runtime of your algorithm and explain the reasoning.

Solution: [Write your answer here]


3.) Let P [0, . . . , n − 1] be an array which contains the varying price of a house over a period of n
days:

P = [p0 , p1 , p2 , . . . , pn−1 ].

For every day you own the house, you have to pay a tax t on it, where t is a constant input.
The profit gained from purchasing the house on day i and selling the house on day j ≥ i is equal
to pj − pi − t · (j − i). Our goal is to find indices i and j ≥ i that maximize the profit with a
divide-and-conquer algorithm in O(n log n) time.

Note: you must always buy the house and sell the house (i.e. you must return an i and j in the
bounds of P ).

(a.) Describe your algorithm to a degree where someone could implement it if given your answer.
Please reference “Algorithm Design” in the Assignment Guidelines uploaded to
Canvas.

Solution: [Write your answer here]

(b.) Argue why your algorithm is correct (given any input, why does your algorithm produce the
correct outputs). Please reference “Algorithm Analysis” in the Assignment Guide-
lines uploaded to Canvas.

Solution: [Write your answer here]

(c.) Give the runtime of your algorithm and explain the reasoning.

Solution: [Write your answer here]


4.) You are at a music festival with n attendees, each of whom is a fan of exactly one band. It is
impossible to tell which band any attendee supports directly; asking them explicitly will result in
being escorted out of the festival. However, you can determine whether two attendees support the
same band by forcing them to interact: fans of the same band greet each other with cheers and
high-fives, while fans of different bands engage in awkward silences or heated debates.

There exists a single band of which more than half the attendees are fans. There are no guarantees
about the remaining attendees or the other bands.

Design an efficient divide and conquer algorithm to find the most popular band. You can either
have your algorithm return one fan of the band or all fans of the band.

(a.) Describe your algorithm to a degree where someone could implement it if given your answer.
Please reference “Algorithm Design” in the Assignment Guidelines uploaded to
Canvas.

Solution: [Write your answer here]

(b.) Argue why your algorithm is correct (given any input, why does your algorithm produce the
correct outputs). Please reference “Algorithm Analysis” in the Assignment Guide-
lines uploaded to Canvas.

Solution: [Write your answer here]

(c.) Give the runtime of your algorithm and explain the reasoning.

Solution: [Write your answer here]

You might also like