COSC 175 Lecture 16: Computer Science 11:19

39 views2 pages

Document Summary

You start in the beginning and literally look through every single item: stop for 2 conditions; You found what you are looking for. What you are looking for is not there. Got to the end and nothing there. Conditions for while loop: bool = found, found = false, ix = 0; (means start the first item) Keep looking while still items in the array: while ((ix < length) && (!found), { if (cid:894)words[ix] == (cid:862)co(cid:373)puter(cid:863)(cid:895) Ix++; : {if (found == true) Cout << (cid:862)fou(cid:374)d at word (cid:862) << ix << e(cid:374)dl: else. Cout << (cid:862)ite(cid:373) (cid:374)ot fou(cid:374)d(cid:863) << e(cid:374)dl; Ways to speed up the search: put most commonly searched items at the beginning. What makes something being searched more or less: advertisement, time of year, items in the news. How do you find the middle of a list: loindex = 0, hiindex = length, midindex = length / 2; If (list[ix] == list: found = true;

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