Header Image
Creative Commons image courtesy of Flickr user StormPetrel1-
Recent Posts
Recent Comments
- In the Spotlight: MAT2540 – Discrete Structures and Algorithms II – The Open Road on Links
- OpenLab Workshop for Opening Gateways Fellows | 2018-2019 Opening Gateways Faculty Seminar on Final Exam Review
- Eric on Eric’s Final Review
- Kate Poirier on Hints/reminders from today’s class
- Kate Poirier on Final Exam Review
Archives
Categories
Meta
Test #1 Review – [Benjamin Lin] section 3.1 #20
Code: Find max and min (a1,a2…..an)
max = min = ai
i = 2
from ( i to n)
if ai < min
min = ai
if ai> max
max = ai
return min, max
Posted in Test #1 Review, Uncategorized
1 Comment
Test #1 Review – Brian Gil
Section 3.3 = #3
Give a big-θ estimate for the number of operations of this algorithm:
m := 0
for i := 1 to n
for j := i +1 to n
m := max(aiaj, m)
The values of i and j:
i := 1 <= n → n (rounds)
j := i + 1 <= n → n – 1 (rounds)
i := n + 1 <= n → 1 (Ends loop)
j := n + 1 <= n → 1 (Ends loop)
n(n – 1) + 1 + 1 = n^2 – n + 2
Exactly n^2 – n + 2 comparisons are used whenever this algorithm is applied. Hence, the algorithm has time complexity θ(n^2).
Posted in Test #1 Review
1 Comment
Section 3.2 #42
42. Suppose that f (x) is O(g(x)). Does it follow that 2^f (x) is O(2^g(x))?
f (x) is O(g(x)) or f(x) ≤ g(x)
Then 2^ f(x) ≤ 2^g(x)
Therefore, 2^f(x) is O(2^g(x))
Posted in Homework, Test #1 Review
3 Comments
Test #1 and OpenLab Review Assignment
Test #1 will be given in class next Wednesday, March 9. (The calendar has not yet been updated to reflect this.)
Your review assignment is due by 8am on Monday, March 7. Select one of the practice problems listed in the calendar, or any of the homework exercises that you have been assigned. Submit an OpenLab post with the full question and your full solution. Do not submit a question that has already been submitted. You may type directly (you can use to typeset mathematical symbols if you know how) or you can upload a photo of your beautiful and neat hand-written work. Select the category “Test #1 Review” from the right-hand side of the screen before publishing your post. Title your post “Test #1 Review – [your name].” Try not to choose the easiest problems; remember that this exercise is designed for you and your classmates to review for next week’s test. For extra credit, find an error in someone else’s submission and correct it in a comment.
By 8am Monday there will be 28 questions and answers for you to review from. You can click on the “Test #1 Review” category at any time to see all the submissions in one place.
Posted in Homework, Test #1 Review
1 Comment