0% found this document useful (0 votes)
123 views7 pages

CS 3510 Homework 1 Q

This document provides the instructions for Homework 1 in CS 3510 which involves analyzing algorithms using Big-O notation and designing divide-and-conquer algorithms. It includes 5 problems - clustering functions by asymptotic growth, classifying algorithm runtimes, comparing binary numbers using divide-and-conquer, analyzing a recursive algorithm, and designing an algorithm to multiply a vector by a Star matrix. Students are instructed to type their solutions and collaboration is allowed at a high level.
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)
123 views7 pages

CS 3510 Homework 1 Q

This document provides the instructions for Homework 1 in CS 3510 which involves analyzing algorithms using Big-O notation and designing divide-and-conquer algorithms. It includes 5 problems - clustering functions by asymptotic growth, classifying algorithm runtimes, comparing binary numbers using divide-and-conquer, analyzing a recursive algorithm, and designing an algorithm to multiply a vector by a Star matrix. Students are instructed to type their solutions and collaboration is allowed at a high level.
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/ 7

CS 3510: Design & Analysis of Algorithms 08/22/2023

HW 1: Big-O and Divide & Conquer Warm-up


Prof. Sahil Singla Due: 08/29/2023 11:59pm

• Please TYPE your solutions using Latex or any other software. Handwritten
solutions will not be accepted.

• Unless otherwise stated, use log to the base 2. receive more credit. If we ask
for a specific running time, a correct solution achieving it will receive full credit
even if a faster solution exists.

• Collaboration is allowed on a high-level, but your submissions must be individual.


Make sure to include the name of your collaborators.
1.) (10 points) For the following list of functions, cluster the functions of the same order (i.e., f
and g are in the same group if and only if f = Θ(g) into one group, and then rank the groups in
decreasing order of magnitude. You do not have to justify your answer.

(a.) n n5

(b.) n3.1415
log 50
(c.) 100n2 +n

(d.) 22024

(e.) 53 log3 n (Note: It’s 5 to the power of 3 log3 n)

(f.) 1024log n

(g.) (log n)log n

(h.) nlog log n

(i.) n log n + 2024n!


2.) (10 points) State whether the following functions are guaranteed to be bounded by a function
in the constant, polynomial, or exponential classes of functions, or if they are guaranteed not to
bounded by a function in a class. E.g. f (n) = ω(n2 ) is guaranteed to not be constant, but we
don’t know if f is bounded by a polynomial or exponential.

(a.) f (n) = nO(1)

(b.) f (n) = nω(1)

(c.) f (n) = 2O(log n)


2
(d.) f (n) = 2(log n)

(e.) f (n) = n!
3.) (30 points) Suppose you have two non-negative integers x, y each stored in binary represen-
tation as arrays of n bits (ordered least significant digit to most significant digit). We want to
determine if x > y, y > x, or x = y.

(a.) Design an algorithm in English and mathematical expressions that accomplishes this. Also,
provide pseudo-code for the same.

(b.) What is the running time of this algorithm, in the worst case over inputs x, y, using Θ(·)
notation, and assuming comparing two bits takes time 1.

(c.) Can you prove (or argue) that this running time is optimal (up to constants) over all correct
algorithms?

(d.) What is the fastest your algorithm can run (the best case scenario over inputs x, y)?
4.) (20 points) Assume n is a power of 4. Assume we are given an algorithmic routine f (n) as
follows:

function f(n):
if n>1:
for i in range(5):
f(n/4)
for i in range(n*n):
print("Hello")
else:
print("World")

(Note: range(k) is the set {0, 1, . . . , k − 1}).

(a.) What is the running time for this function f (n)? Justify your answer. (Hint: Compute the
recurrence first)

(b.) How many times will this function print “World”? Please provide the exact number in terms
of the input n. Justify your answer.
5.) (30 points) For any number n, such that n is a power of 2, the Star matrix, Sn is defined as
follows:

if n = 1, Sn = 1
 
3S n2 I n2
if n > 1, Sn =
S n2 −2S n2

Where Ik denotes the k × k identity matrix.

(a.) Design an O(n log n) algorithm (by explaining it in English) that calculates the vector Sn · v,
where n is a power of 2 and v is a vector of length n. Pseudo-code is not required.

(b.) Justify the runtime of your algorithm by providing a recurrence relation for the runtime and
solving it.
Practice Problem
Note: This problem won’t be graded.

Suppose Malav and Saigautam are trying to come up with Divide & Conquer approaches to some
problem P with input size n. Malav comes up with a solution that utilizes 6 sub-problems of size
n/3 with time n2 to combine subproblems,
√ while Saigautam comes up with a solution that utilizes
8 sub-problems of size n/4 with time n n + n to combine subproblems.

(a.) Find the runtime of both approaches, and choose the algorithm that runs faster at large
input size n. If both are the same speed, specify this.

(b.) Let’s say Jayanee also tries to solve P using an algorithm of her own. She utilizes 10 sub-
problems of size n/5 with time log n to combine subproblems. Is this algorithm faster than
the one you chose in part (a)? Why or why not?

You might also like