32-section-5

32-section-5 - Sample thesaurus.txt The file that youll...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Handout #32 CS 106A July 28, 2009 Section Handout #5 HashMaps 1. Using Maps During lecture this week, we talked about the special data structure known as the Map. Discuss how you could use a Map in the following problems: Keeping track of email addresses (linking a person to his/her email address) Maintaining Facebook profiles (to look up using the person’s name) How would you use a Map for these problems? (These are slightly more complicated.) Holding students’ study lists (to lookup using a student’s name) Figuring out which Marguerite lines serve a particular bus stop 2. Synonyms Write a simple program that reads in a file with synonyms, and then allows the user to look up synonyms for words of their choice. A sample run of the program follows (on the left):
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Sample thesaurus.txt The file that youll read in is called thesaurus.txt . It is formatted with a single word on each line, as in the example to the top-right. Each pair of words represents a pair of synonyms; for example: Skinny is a synonym of Thin Dent is a synonym of Chip 2 Student is a synonym of Pupil If time permits: your solution to number 4 is likely case-sensitive that is, the program treats the words Funny and funny as different words. This has a profound impact, as looking up one string results in a successful lookup, while the other one fails which, at the very least, would be very counter-intuitive (and annoying) to the user. How would you insulate your program from this issue, and make it case-insensitive ?...
View Full Document

This note was uploaded on 10/14/2010 for the course CS 106A taught by Professor Sahami,m during the Fall '08 term at Stanford.

Page1 / 2

32-section-5 - Sample thesaurus.txt The file that youll...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online