CSC148H5 Lecture Notes - Lecture 4: Local Variable, Umber, Binary Search Algorithm

60 views11 pages
24 Jan 2017
School
Course

Document Summary

Try solving examples that we do, without using recursions. Classic example that profs use on day 1 of recursion: factorial. Thinking of numbers in a recursive way is not the useful way to contrast loops and recursion. We can look at binary codes of speci c length. Length 0: (empty string is a valid binary string) Length 3: 000 001 010 011 100 101 110 111 x8. If we increase the length of the binary string by one we get double binary code = binary string, they are strings of 0 and 1. Characterize your problem in terms of smaller subproblems of the same structure. Suppose that we wanted to generate all binary codes of length 3. Also, suppose that we know how to generate all binary codes of length 2. Lets add a 1 to the end that gives us 001. Can i get another one by starting 00.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents