CS 101 – Nov. 6 The Joy of Text Software for text –Text formatters vs. word processors Spell checking
Text Software Text editor (Notepad, Wordpad, emacs, vi) (Web) Browser (Netscape, Opera) Text formatter (LaTeX, Groff) Word processor (MS Word)
example.html browser See on screen example.tex LaTeX example.ps printer example.doc Word Different strategies for creating formatted text file:
Text Formatters Groff was first in 1969 LaTeX most popular since 1974 Used extensively in scientific pub’s Formatting commands embedded in text. Run “latex” to convert.tex to.ps file Advantages: free & saves space!
Word Processors Popular among general public since 1980s. WYSIWYG –Formatting commands are invisible Entire document in 1 file Many features: spell checking, word count, readability, etc. Not free, generally requires more space.
Example My vita is a 2-page document LaTeX –vita.tex has 4,210 bytes –vita.ps has 43,675 bytes (can delete!) Microsoft Word –vita.doc has 31,232 bytes
Spell Checking One feature of MS Word is spell checking Looks up each word in its “dictionary” Uses binary search to make lookup fast! Analogy: Try to guess my number
Binary Search If dictionary has 100 words, need 7 guesses to see if word is spelled right. log ~ 7 What if 1,000 words? A real dictionary may have > 25,000 words.
Example Looking for “goat”. Here are guesses: Joachin, degumming, gale, holly, guideline, gloomy, granite, golly, gnu, … Notice they go back and forth.
Search summary By now, we have seen 4 ways to search for data. –If the data is arranged linearly: Linear search Binary search (linear data, already sorted) –If the data is arranged non-linearly: Breadth-first search Depth-first search