26-CS106X-Practice-Midterm

26-CS106X-Practice-Midterm - CS106X Autumn 2010 Handout 26...

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

View Full Document Right Arrow Icon
CS106X Handout 26 Autumn 2010 October 30 th , 2010 CS106X Practice Midterm Exam Facts: When: Wednesday, November 3 rd from 7:00 – 9:00 p.m. Where: TBA Note this practice exam is about twice as long as most real midterms. Coverage The midterm covers everything up through recursive backtracking, memoization, searching, sorting, big-oh analysis, pointers, and dynamic memory allocation. I will not test you on linked lists until the final exam. We will not be especially picky about syntax or other conceptually shallow ideas. We are looking for a clear understanding of the core programming concepts in C++. The exam is open-reader and open-notes, but no computers allowed. Don't let the open- reader nature mislead you. There isn’t enough time to learn or even re -learn everything during a two-hour window. You should be experienced enough with the material to readily answer the questions, relying on your notes only for the occasional detail. Writing code on paper in a relatively short time period is not quite the same as working with the compiler and a keyboard. I recommend that you practice writing out solutions to these practice problems—starting with a blank sheet of paper—until you’re certain you can write code without a computer to guide you.
Background image of page 1

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

View Full DocumentRight Arrow Icon
Problem 1: Acronyms [courtesy of Julie Zelenski] An acronym is an abbreviation formed from the first letter of each of a series of words, such as NATO (North American Treaty Organization) or HTML (Hyper Text Markup Language). In this problem, you are to write two functions that operate on a table of acronyms. An acronym data file contains a list of expanded acronyms, one per line, such as shown here: American Automobile Association Internal Revenue Service Standard Query Language Parent Teacher Association Animal Acupuncture Academy Inertial Reference System Abdominal Aortic Aneurysm National Direct Student Loan The terms within each expansion are separated by at least one and possibly more spaces. All terms within an expansion are capitalized and thus the acronym formed is uppercase. a) The ReadIntoMap function reads an acronym data file and builds a map from acronyms to expansions. The two parameters to the function are a correctly opened ifstream and an empty map. The function should fill the map with entries where acronym (e.g. "IRS" ) is the key, and the associated value is its expansion(s) (e.g., "Internal Revenue Service" and "Inertial Reference System"). An acronym may have more than one expansion (e.g., there are three options for "AAA" in the above file) and thus the value for each key is a vector, where each entry is a possible expansion. A Scanner will be useful here. void ReadIntoMap(ifstream& in, Map<Vector<string> >& map) { b) Although using acronyms can be convenient, it can be confusing when one acronym has many different expansions. Given a map such as the one created by the function from part (a), the PercentConfusing function returns the percentage of acronyms in the map that have more than one expansion. For a map constructed from the data file
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/13/2011 for the course CS 106X taught by Professor Cain,g during the Fall '08 term at Stanford.

Page1 / 9

26-CS106X-Practice-Midterm - CS106X Autumn 2010 Handout 26...

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

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