COMP 202 Study Guide - Pariah Dog, Public Account, Dynamic Array

54 views7 pages
jc123 and 40170 others unlocked
COMP 202 Full Course Notes
100
COMP 202 Full Course Notes
Verified Note
100 documents

Document Summary

* output: a series of bits {0,1}^m while (n != 0) { Determine whether the number is even or odd. If n is odd, write 1 n = n / 2 (rounding down) Read the bit sequence in the reverse order (bottom-up) 42 is even -> 0 42 / 2 = 21. 10 is even -> 0 10 / 2 = 5. Note: the last bit you write must be a 1. If your last bit is a 0, you did something wrong. To convert from decimal to any base b, the algorithm is very similar: * instead of determining whether n is even or odd, you divide n by b, and take the remainder. * instead of dividing n by 2 at each step, you divide it by b. Let"s try with a number: 42 (base 4) Let"s try with another number: 54 (base 4)

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers

Related Documents

Related Questions