Trang 2
Agenda - Announcements - And time to fill out surveys - Asymptotics Review - Problem 1,2 - Bits and Bitwise Operators - Problem 3
Đang tạo bản xem trước...
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!
Hiển thị 12 trang đầu. Tải tài liệu để xem đầy đủ.
Chưa có bình luận nào. Hãy là người đầu tiên!
Bình luận (0)
Chưa có bình luận nào. Hãy là người đầu tiên!