Intro to Asymptotics and Bits (Discussion 6) (Ký hiệu tiệm cận và các phép toán bit) - Christine Zhou

UN
Uni24h
다운로드 0회
12
0

자료 내용

2쪽

Agenda - Announcements - And time to fill out surveys - Asymptotics Review - Problem 1,2 - Bits and Bitwise Operators - Problem 3

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

4쪽

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

5쪽

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)

6쪽

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)

7쪽

1 Basic Algorithmic Analysis Solutions: 1. f ∈ 𝛳(g) 2. f ∈ O(g) 3. f ∈ O(g) 4. f ∈ Ω(g) 5. f ∈ 𝛳(g)

11쪽

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

12쪽

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)

로그인 하여 토론에 참여하기

댓글이 없습니다. 첫 댓글을 남겨보세요!