Discrete Math Learning Goals and Base Expansions

cse 20 discrete math n.w
1 / 20
Embed
Share

Explore the learning goals of a Discrete Math course covering algorithm tracing, base expansion of positive integers, and converting between different bases like decimal, binary, hexadecimal, and octal. Understand integer representations in various contexts and delve into the concept of base b expansion. Dive into pseudocode and algorithms to solve problems effectively.

  • Discrete Math
  • Base Expansion
  • Algorithm Tracing
  • Integer Representations
  • Pseudocode

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. CSE 20 DISCRETE MATH Fall 2020 http://cseweb.ucsd.edu/classes/fa20/cse20-a/

  2. Today's learning goals Trace an algorithm specified in pseudocode Define the base expansion of a positive integer, specifically decimal, binary, hexadecimal, and octal. Convert between expansions in different bases of a positive integer. Define and use the div and mod operators.

  3. Learning goals Multiple Representations In the past two classes, when have we used numbers?

  4. Integer representations Different contexts call for different representations. Base 10 Base 2

  5. Base b expansion of n Also known as positional representation of positive integers Rosen p. 246 Using the terminology from last class: the base b expansion of n is a string over the alphabet and whose leftmost character is nonzero.

  6. Base b expansion In what base could this expansion be (1401)? A. Binary (base 2) B. Octal (base 8) C. Decimal (base 10) D. Hexadecimal (base 16) E. More than one of the above

  7. Base b expansion In what base could this expansion be (1401)? A. Binary (base 2) B. Octal (base 8) C. Decimal (base 10) D. Hexadecimal (base 16) (1401)16 =1*163+4*162+1=5121 E. More than one of the above (1401)8 = 1*83+4*82+1=(769)10 (1401)10 =1*103+4*102+1=1401

  8. Converting between bases xkcd

  9. Algorithm? Rosen 3.1 p. 191 Finite sequence of precise instructions for solving problem.

  10. Algorithm: Pseudocode Appendix Finite sequence of precise instructions for solving problem. At the end of running log(6) what values are in the variables r and n? A. r = 6, n = 0 B. r = 6, n = 6 C. r = 2, n = 0 D. r = 2, n = 1 E. None of the above.

  11. Algorithm: constructing base b expansion Input n,b English description. Output k, coefficients in expansion Pseudocode.

  12. Algorithm 1: constructing base b expansion Input n,b English description. Initialize value remaining to be n Find biggest power of b that is less than or equal to value remaining. Increment appropriate coefficient. Update value remaining by subtract this power of b from it. Repeat until value remaining is 0. Output k, coefficients in expansion

  13. Ternary representation of 17 A. (17)3 B. (211)3 C. (122)3 D. (221)3 E. (112)3

  14. Algorithm 1: constructing base b expansion ak-1 is coefficient of biggest power of b that is less than n Thus: k is 1 more than integer part of logbn

  15. Algorithm 2: constructing base b expansion Input n,b Output k, coefficients in expansion Idea: Find smallest digit first, then next smallest, etc. . but how? Rosen p. 249

  16. Bases and Divisibility Rosen p. 237-239 Theorem: For n an integer and d a positive integer, there are unique integers q and r with 0 r < d and n = dq + r. Notation: q = ndiv d and r = nmod d When k>1 n = ak-1bk-1+ + a1b + a0 n = b (ak-1bk-2+ + a1) + a0 d q = n div d r = n mod d

  17. Algorithm 2: constructing base b expansion Input n,b Output k, coefficients in expansion Idea: Use n mod b to compute least significant digit. Use n div b to compute new integer whose expansion we need. Repeat.

  18. Algorithm 2: constructing base b expansion

  19. Representing more Base b expansions can express any positive integers What about Zero? negative integers? rational numbers? other real numbers?

  20. There are 10 types of people in the world: those who understand ternary, those who don't, and those who mistake it for binary For next time Read website carefully http://cseweb.ucsd.edu/classes/fa20/cse20-a/ No pre-class reading for next lecture

Related


More Related Content