Looking up a word in a dictionary can be a complicated process. For example, ass
ID: 3752087 • Letter: L
Question
Looking up a word in a dictionary can be a complicated process. For example, assume you want to look up “logic.” You might open the dictionary to a random page and see “juice.” You know this word comes alphabetically before “logic,” so you flip forward and see “lamb.” That is still not far enough, so you flip forward and see “monkey.” You have gone too far, so you flip back, and so on. Draw a structured flowchart or write pseudocode that describes the process of looking up a word in a dictionary. Pick a word at random and have a fellow student attempt to carry out your instructions. Required: Data Dictionary, Hierarchy Chart, Flowchart, and Pseudocode
Explanation / Answer
1: Open dictionary in the middle. call the first half the first section, and the second half the second section.
2: If your WORD is on the page, we are done. If your WORD should be on this page, we are done.
3: If your WORD is alphabetically less than the first word on the page, choose the first section, divide that section in half. Call the first half the (new) first section, and the second half the (new) second section. Proceed with Instruction 2.
4: Your WORD must be alphabetically larger than the last word on the page, choose the second section, divide that section in half. Call the first half the (new) first section, and the second half the (new) second section. Proceed with Instruction 2.
Note that you should be dealing with successive halves of the dictionary. Each half should bring you closer to your WORD. If the dictionary has 1000 pages, we expect to look at 10 pages (and 10 halvings) to find your WORD (1000 divided in half 10 times is approximately 1).
Pseudocode:
Start
Declarations
String wordToLookup
String nextWord
Output “Enter the word you would like to find in the dictionary”
Input wordToLookUp
Output “Enter the next word found in the dictionary by random searching”
input nextWord
while wordToLookUp is less than nextWord then
if wordToLookUp is less than nextWord then
output “You need to go forward in the dictionary”
else
output “You need to go forward in the dictionary”
input “Enter the next word found in the dictionary”
input nextWord
endwhile
finish()
finish()
“You found your word”
return
stop
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.