Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 35 – Unit 6 – Under the Hood Binary Encoding – Part 1

Similar presentations


Presentation on theme: "Lecture 35 – Unit 6 – Under the Hood Binary Encoding – Part 1"— Presentation transcript:

1 Lecture 35 – Unit 6 – Under the Hood Binary Encoding – Part 1
CMPT 120 Lecture 35 – Unit 6 – Under the Hood Binary Encoding – Part 1

2 Homework - What does Big O Notation tell us?
What if I have 5 algorithms (or functions) that do the same thing, for example, extract red jelly beans from a bag of multicolour jelly beans Algorithm A -> O(1) Algorithm B -> O(n) Algorithm C -> O(log2 n) Algorithm D -> O(n log2 n) Algorithm E -> O(n!) Which one is the fastest?

3 Homework – What does Big O Notation tell us?
# of comparisons

4 Complexity of Selection Sort
Selection Sort looks for the smallest element multiple times, by going through n elements, then n-1 elements, then n-2 elements, … The total number of comparisons is therefore = n + (n-1) + (n-2) + … = n (n + 1) 2 = n2 + n Computing scientists mainly care about the highest order term. Therefore we consider selection sort to be quadratic -> O(n2)

5 Unit 6. Under The Hood Ever wonder how computers represent data?
You got it! -> Computers use 0 and 1 to represent everything In this module, we shall discover Why computers use 0 and 1 to represent everything How they do it Binary Numeral System

6 Unit 6. Under The Hood

7 Let’s open the hood! Source:

8 Main Memory

9 “Computers use 0 and 1 to represent everything“
Computer memory: integer colour floating point number character CPU instruction sound

10 Why the 0’s and the 1’s Fundamentally, digital computers are machines that convert high and low electrical signals (called voltage) into 0’s and 1’s. Let’s learn to speak its native language!

11 Decimal numeral system
Binary numeral system Decimal -> (Base 10) Ten symbols (digits): Positional system When counting: Binary -> (Base 2) Two symbols (bits): (bits -> binary digits) Positional system When counting:

12 How computers represent characters
Source: See ASCII Table:

13 How computers represent integers
Which integer is : bit byte A bit either contains a 0 or 1 A byte is 8 bits

14 Next Lecture More about Binary Numeral System Binary -> Decimal
Decimal -> Binary


Download ppt "Lecture 35 – Unit 6 – Under the Hood Binary Encoding – Part 1"

Similar presentations


Ads by Google