第 2 页
Agenda - Announcements - And time to fill out surveys - Asymptotics Review - Problem 1,2 - Bits and Bitwise Operators - Problem 3
正在生成预览...
Agenda - Announcements - And time to fill out surveys - Asymptotics Review - Problem 1,2 - Bits and Bitwise Operators - Problem 3
Announcements - Midterm grades have been released! - Place to Vent (ANONYMOUS): tinyurl.com/placetovent - HW3 due yesterday - TLDR: Make sure everything works on the instructional account - Start Project 1 if you haven’t already! - (PLEASE FILL OUT TODAY) Discussion survey: tinyurl.com/disc6cz
Asymptotics: Big Ө(...) - Called “big theta notation” - R(N) = runtime, f(N) = function, k’s = constants - The runtime can be both upper and lower bounded by the function - Let’s say R(N) = 3n3 + 2n2 + 1 - What is a good f(N), k , k ? 1 2 - f(N) = n3, k = 2, k = 4 1 2
Asymptotics: Big O(...) - Called “big oh notation” - R(N) = runtime, f(N) = function, k = constant - The function is an upper bound on the runtime - DOES NOT MEAN WORST CASE - True or false? - N2 ∈ O(N2) - N2 ∈ O(N500) - N log N ∈ O(N) - log N ∈ O(N2)
Asymptotics: Big Ω(...) - Called “big omega notation” - R(N) = runtime, f(N) = function, k = constant - The function is a lower bound on the runtime - DOES NOT MEAN BEST CASE - True or false? - N2 ∈ Ω(N2) - N ∈ Ω(1) - N2 ∈ Ω(N3)
1 Basic Algorithmic Analysis Solutions: 1. f ∈ 𝛳(g) 2. f ∈ O(g) 3. f ∈ O(g) 4. f ∈ Ω(g) 5. f ∈ 𝛳(g)
Bitwise Operators AND (&) OR (|) 0 __ 0 0 0 0 __ 1 0 1 1 __ 1 1 1 - x << y: shift the bit representation of x by y to the left (rest are filled with 0’s) - If x is 10011 and y is 2 - x << y is 01100 - x >> y: shift the bit representation of x by y to the right (rest are filled with 0’s) - If x is 10011 and y is 2
3 A Bit with some Bits Let’s figure out what this question is asking first... Complete the following method such that it does what it is intended to do: given a list of integers, it returns an integer such that the i-th bit of the return value is 1 if and only if more than half of the integers in the list have 1 in the ith bit. Keep in mind that Java ints are 32 bits long!
显示前 12 页。下载资料查看完整内容。
暂无评论。快来抢沙发吧!
评论 (0)
暂无评论。快来抢沙发吧!