csc 151 spring 2020 topic: binary searcheikmeier/csc151s20/slides/day_34.pdf · check 2: binary...
TRANSCRIPT
![Page 1: CSC 151 Spring 2020 Topic: Binary Searcheikmeier/csc151S20/slides/Day_34.pdf · Check 2: Binary Search a. Explain the role of may-precede? in binary-search b. Explain the role of](https://reader034.vdocuments.site/reader034/viewer/2022050215/5f618479efea1e6a8f2b4c9d/html5/thumbnails/1.jpg)
CSC 151 Spring 2020Topic: Binary Search
April 22, 2020Day 34
![Page 2: CSC 151 Spring 2020 Topic: Binary Searcheikmeier/csc151S20/slides/Day_34.pdf · Check 2: Binary Search a. Explain the role of may-precede? in binary-search b. Explain the role of](https://reader034.vdocuments.site/reader034/viewer/2022050215/5f618479efea1e6a8f2b4c9d/html5/thumbnails/2.jpg)
Self-ChecksCheck 1: Where are my keys?
a. Explain the role of the pred? parameter in list-sequential-search
b. Explain the role of the get-key parameter in keyed-list-sequential-search
c. If we double the length of the list, what is the worst case effect on the number or recursive calls in list-sequential-search?
![Page 3: CSC 151 Spring 2020 Topic: Binary Searcheikmeier/csc151S20/slides/Day_34.pdf · Check 2: Binary Search a. Explain the role of may-precede? in binary-search b. Explain the role of](https://reader034.vdocuments.site/reader034/viewer/2022050215/5f618479efea1e6a8f2b4c9d/html5/thumbnails/3.jpg)
Self-ChecksCheck 2: Binary Search
a. Explain the role of may-precede? in binary-search
b. Explain the role of point-of-division, separating-element, sep-elt-key, left? And right? which are bound in the let* of binary-search.
c. Describe how and why the upper-bound of kernel search-portionchanges when left? is true.
d. Describe how and why the lower-bound of kernel search-portionchanges when right? is true.
e. If we double the length of the vector, what is the worst case effect on the number of recursive calls in binary-search?
![Page 4: CSC 151 Spring 2020 Topic: Binary Searcheikmeier/csc151S20/slides/Day_34.pdf · Check 2: Binary Search a. Explain the role of may-precede? in binary-search b. Explain the role of](https://reader034.vdocuments.site/reader034/viewer/2022050215/5f618479efea1e6a8f2b4c9d/html5/thumbnails/4.jpg)
Types of Problems in CSWhat are some example problems we could solve with each of the following approaches? Think about it for a minute before moving on to the answers.
RepeatingCombiningSearchingSorting
![Page 5: CSC 151 Spring 2020 Topic: Binary Searcheikmeier/csc151S20/slides/Day_34.pdf · Check 2: Binary Search a. Explain the role of may-precede? in binary-search b. Explain the role of](https://reader034.vdocuments.site/reader034/viewer/2022050215/5f618479efea1e6a8f2b4c9d/html5/thumbnails/5.jpg)
Types of Problems in CSWhat are some example problems we could solve with each of the following approaches? Think about it for a minute before moving on to the answers.
Repeating: Anything where we use recursion. Make-listCombining: appending lists, cons, reduceSearching: using predicates to find matches, finding the first odd value in a list or vectorSorting: prioritizing
![Page 6: CSC 151 Spring 2020 Topic: Binary Searcheikmeier/csc151S20/slides/Day_34.pdf · Check 2: Binary Search a. Explain the role of may-precede? in binary-search b. Explain the role of](https://reader034.vdocuments.site/reader034/viewer/2022050215/5f618479efea1e6a8f2b4c9d/html5/thumbnails/6.jpg)
Examples of SearchingThink of at least three procedures you could write that involve some kind of searching. I’ll start you off with one example.
(look-up-word word dictionary)
![Page 7: CSC 151 Spring 2020 Topic: Binary Searcheikmeier/csc151S20/slides/Day_34.pdf · Check 2: Binary Search a. Explain the role of may-precede? in binary-search b. Explain the role of](https://reader034.vdocuments.site/reader034/viewer/2022050215/5f618479efea1e6a8f2b4c9d/html5/thumbnails/7.jpg)
Examples of SearchingThink of at least three procedures you could write that involve some kind of searching. I’ll start you off with one example.
(look-up-word word dictionary)(first-odd lst)(find-name name table)(find-by-house-number num directory)(catch-bitcoin-miners network-data)
![Page 8: CSC 151 Spring 2020 Topic: Binary Searcheikmeier/csc151S20/slides/Day_34.pdf · Check 2: Binary Search a. Explain the role of may-precede? in binary-search b. Explain the role of](https://reader034.vdocuments.site/reader034/viewer/2022050215/5f618479efea1e6a8f2b4c9d/html5/thumbnails/8.jpg)
Lab Time
![Page 9: CSC 151 Spring 2020 Topic: Binary Searcheikmeier/csc151S20/slides/Day_34.pdf · Check 2: Binary Search a. Explain the role of may-precede? in binary-search b. Explain the role of](https://reader034.vdocuments.site/reader034/viewer/2022050215/5f618479efea1e6a8f2b4c9d/html5/thumbnails/9.jpg)
Upcoming Work
Project Proposal is due Friday! Be sure to read the grading rubric!
Please submit all exercises before the extras by Friday 4/24 at 10:30 pm. Include documentation for problem 4.
To: [email protected]: CSC 151-02 Lab 4/22