cps6-111027

# cps6-111027 - Susan: Smith Brandt Rodger Crackers One way...

This preview shows pages 1–8. Sign up to view the full content.

CompSci 6 Introduction to Computer Science October 27, 2011 Prof. Rodger

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

View Full Document
Announcements • Read for next time Chap. 9.2-9.4 • Reading Quiz on Blackboard – Due before class next time • Assignment 5 out tonight or tomorrow, due Nov 3 • Today – Apt – uniqueNames – Problem – most popular name
Popular Name Problem: • Given a list of names, determine the most popular first name and print that name with all of its last names. • Input: Names are always two words, names are in a file. If multiple names are on the same line they are separated by a “:” • Output: Most popular first name, followed by a “:”, followed by corresponding last names separated by a blank

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

View Full Document
Example Input File with 5 lines Susan Smith:Jackie Long:Mary White Susan Brandt Jackie Johnson:Susan Rodger:Mary Rodger Eric Long:Susan Crackers:Mary Velios Jack Frost:Eric Lund Corresponding Output

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

View Full Document

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Susan: Smith Brandt Rodger Crackers One way to solve Create a list of unique first names Create a list of lists of last names that are associated with each first name Example two lists Susan Jackie Jack Eric Mary [ Smith,Brandt,Rodger,Crackers] [ Long, Johnson] [ White,Rodger,Velios] [ Long, Lund] [ Frost] 1 2 3 4 5 1 2 3 4 5 Unique First names Corresponding Last names Now can we solve the problem? Compute those two lists that are associated with each other List of unique first names List of corresponding last names Compute the max list of last names Now easy to print the answer. Expanding the Problem Suppose we want to read from multiple data files names1.txt, names2.txt, names3.txt...
View Full Document

## This document was uploaded on 01/17/2012.

### Page1 / 8

cps6-111027 - Susan: Smith Brandt Rodger Crackers One way...

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

View Full Document
Ask a homework question - tutors are online