Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

CMSC 351 Homework Explanation by TA Shang-chieh J Wu - Prof. Samir Khuller, Assignments of Algorithms and Programming

Explanations by the teaching assistant (ta) shang-chieh j wu for problem solutions in cmsc 351 homework #1. Concepts such as summations, constant execution time, minimizing the maximum sum of a pair, and the lower bound for comparison-based sorting.

Typology: Assignments

Pre 2010

Uploaded on 02/13/2009

koofers-user-bd3
koofers-user-bd3 🇺🇸

10 documents

1 / 2

Toggle sidebar

Related documents


Partial preview of the text

Download CMSC 351 Homework Explanation by TA Shang-chieh J Wu - Prof. Samir Khuller and more Assignments Algorithms and Programming in PDF only on Docsity! CMSC 351 HW #1 TA’s Explanation Shang-chieh J Wu Problem 1 The answer can be got from inspection as in the following two tables. i j Printing # 1 1 to 4 4 2 2 to 7 6 3 3 to 10 8 … … … n i Printing # 1 1 to 1 4 2 1 to 2 10 3 1 to 3 18 … … … But you must offer some concrete “evidence” to say the answer is something. Inspection is not good enough for such a kind course. (Algorithm) The inner loop is only a print statement, so the constant execution time is needed. You can use a “c” or “k” to denote the constant, or just using 1 (unity). Either is O (1). Take a look at your textbook pp.1058-1060 for some concepts about summations, and don’t been fooled by the index term (k in the following example) and the summed term (b in the following example). ∑ + = +=+== =++= 2 11 3 a ak akakak bbbbb In the above example, the exact value of a is NOT important, as long as it won’t change during summation. The same idea applies to professors’ solution. When doing ∑ + = +=+== +=+−+=+++= 13 131 221)()13(1...111 i ij ijijij iii i won’t change during the summation, which can be known by inspecting the code. The second equal sign can be got from a simple counting. I (TA) learned it when I was 10 years old.
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved