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

CSCI 4470 Algorithms Homework 1

Uploaded by

sofiya
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 views2 pages

CSCI 4470 Algorithms Homework 1

Uploaded by

sofiya
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

Homework Assignment No.

1
CSCI 4470/6470 Algorithms, CS@UGA, Fall 2019

Due Thursday August 29, 2019

The answers must be word-processed or typed. You may substitute formulae


and figures with hand-writings. Your submitted algorithms should be in the
pseudo-code, not in any specific programming language. Answers deviating
from these requirements will be returned without grading.
The answers must be the student’s own work. Idea sharing and referenc-
ing to others’ work (including those online) are not allowed. Plagiarism and
other forms of academic dishonesty will be handled within the guidelines of
the Student Handbook and reported to the University.

There are 7 questions and 140 points in total.

1. (20 points) Consider the following summation sum(n) =


1+
1 + 2+
...
1 + 2 + . . . + (n − 1)+
1 + 2 + . . . + (n − 1) + n

which can be computed recursively.


Write in pseudo-code recursive function sum(n) with input parameter
n. You are not allowed to use iterative statements in the pseudo-code.
However, if you wish, your function may call other auxiliary recursive
functions that you may design.

2. (20 points) Consider the following problem to find both the maximum
and second maximum elements from a set of n integers stored in a list

1
A[1..n]. One strategy to solve the problem is to first split the list into
two sublists of roughly the equal size, find the maximum and second
maximum elements from the first sublist and also find the maximum
and second maximum from the second sublist, and then compare the
4 elements to identify the maximum and second maximum for the
original list. Implement this idea into a recursive function in pseudo-
code. No iterative statements are allowed.

3. (20 points) (Independent of the previous Q2.) This question is about


upper bound and lower bound of number comparisons used to find
both the maximum and second maximum elements from a set of n
numbers. Try the following challenges:
(1). give an upper bound,
(2). give a non-trivial upper bound;
(3). give a lower bound;
(4). give a non-trivial lower bound.
A non-trivial bound is one that is not obvious.

4. (20 points) Use the definition of big-O to prove:


(1) 100n2 = O(n2 − 10n);
(2) nk = O(2n ), for any fixed k ≥ 1.

5. (20 points) Questions 3-4: page 62 (3rd ed), page 59 (2nd ed). Answer
questions for parts c and e only.

6. (20 points) Use a recursion tree to determine a good asymptotic


upper bound on time function T (n), where T (n) = T (n/2) + n log2 n
and T (1) = c for some constant c > 0. You may assume that n is
always a power of 2.

7. (20 points) Use the substitution method to verify your answer for the
above Q6.

Homework submission should be in hardcopy. If for a reason


an email submission is necessary, it needs an approval from this
instructor. Submission needs to be received by 5:00pm on the due
day. Thank you.

Common questions

Powered by AI

The recursion tree method visualizes recursive calls, their relationships, and costs, capturing an algorithm's entire execution step. By identifying similar patterns across levels of recursion and summing per-level costs, one estimates total execution growth relative to input size. This effectively results in finding a tight asymptotic upper bound of time complexities. For example, understanding the time function T(n) = T(n/2) + n log2 n would require tallying contributions at each level until the base case is reached.

A structured point distribution aligns different problem facets with respective learning goals, highlighting importance and complexity levels. It guides students in prioritizing effort and reinforces targeted learning outcomes, making assessment systematic in evaluating conceptual grasp and practical application proficiency. Each section’s weight enables nuanced feedback on specific skill areas.

Creating recursive solutions develops a student's ability to think in terms of solving smaller subproblems and using recursion's power to reduce complexity. It requires understanding base and recursive cases clearly, ensuring termination and correctness of the solution. This fosters a deeper conceptual understanding of problem breakdown and systematizes problem-solving strategies across differing complexities without relying on iteratives.

Big-O notation represents the upper bound of an algorithm's time complexity, encapsulating its worst-case performance behavior irrespective of implementational variance. Techniques like the definition-based approach, where functions are rigorously compared to simplifying asymptotic bounds, are employed to demonstrate such relationships. For instance, proving 100n² = O(n² - 10n) involves showing that as n grows large, 100n² is eventually dominated by the leading term of the comparison function.

Prohibiting iterative statements prioritizes teaching recursion fundamentals and deepens comprehension of direct problem sub-division, inherent to many advanced algorithms designs. This constraint forces learners to explore base and recursive scenarios, intricately identifying optimal subproblem boundaries and termination conditions. This enriches conceptual clarity and solutions’ elegance, fostering adaptability across complex problems.

Establishing upper and lower bounds for finding maximum and second maximum elements from a set requires understanding the number of comparisons involved. A trivial upper bound is n-1 comparisons to find the maximum, plus n-2 to find the second maximum, leading to a total of 2n-3 comparisons. A non-trivial upper bound can be lesser depending on the strategy employed. A lower bound derives from the decision tree model, where determining these elements necessitates at least n-1 comparisons in the worst case. A non-trivial lower bound involves recognizing comparisons’ inherent distribution inefficiencies, minimizing the number of comparisons.

Academic integrity in algorithm coursework mandates originality in student submissions and prohibits plagiarism and unauthorized collaboration. These considerations emphasize critical thinking, independent problem-solving, and intellectual honesty, fostering a learning environment based on trust and meritocratic achievement. Violations are stringently addressed under institutional guidelines, underscoring the weight academia places on these ethics.

Using pseudo-code allows students to focus on the logic and structure of the algorithm rather than syntax tied to a specific programming language. It emphasizes understanding algorithmic problem solving and design principles, which are crucial skills developed in academic settings. This practice also aids in clear communication of complex ideas, crucial for peer reviews and collaborative academic work.

The substitution method involves hypothesizing a bound and using induction to prove its validity across all inputs. After hypothesizing the asymptotic form, one assumes it holds for smaller values and then shows it extends to larger input sizes by substituting the hypothesis into the recursive formula. This rigorous approach complements recursion trees by providing a mathematical assurance of the proposed bound.

The divide-and-conquer strategy for finding maximum and second maximum elements efficiently uses recursion by splitting the list into two halves, solving the problem independently on each half, and then combining the results. This minimizes the number of comparisons by independently finding the largest and second largest in sublists and then using only a few additional comparisons to determine the overall maximums. The recursive calls replace iteration, allowing the algorithm to explore different subproblems simultaneously.

You might also like