L-37 MCS 275 Wed 11 Apr 2001
Review Sheet for Exam II, Friday 13 April 2001
The aim of this sheet is to help you to prepare for the
upcoming exam. While it contains some sample questions, the list of
questions is by no means exhaustive.
The material covered are chapters 12 and 13 of the text book.
Although no specific questions on materials of previous chapters
will be asked, you must be familiar with recursion, since Chapter 12
deals with "recursive" data structures.
In addition to the text book, look at
- The programs posted at
the course web site.
- The solution of the quizzes. If you missed the handout,
look at the course web site.
- Homework exercises, consult the notes of the discussion sessions.
- Project solutions. Although you will not be asked to write
complete programs, some programming concepts
worked out there are very valuable.
The questions below all concern the same data structure
(for efficiency of this review), but the questions on the
exam will feature separate structures for each question.
Chapter 12: Abstract Data Types
- Define a C struct to represent items in a store.
An item is represent by its name (a string of <= 20 characters),
its price (a float), and the quantity in stock (an integer).
- Define a linked list to represent a list of items,
defined like above.
- Write a recursive/iterative implementation of a program
to print the list of items, to count the number of items,
to find the most/least expensive item in the list,
to find the item with largest/smallest stock, etc...
- Give the C implementation of a function to insert a new item
to the front of the list, to append a new item to the end of
list, to delete the first element, to delete the whole list.
- Write a C function to modify the price/stock of an item in the list,
given the name of an item and its new price/stock.
Chapter 13: Input/Output and Files
- Give the printf instruction to write an item it in
the format: name left adjusted in field of width 20;
price right adjusted, in field of width 8, precision 2;
stock in field of 10 wide.
- Give the scanf command to read an item it as given
in the format above.
- Write a graceful fopen for reading (retrial if file
does not exist) and for writing (ask user for permission to
overwrite if file already exists).
- Write a function to print the content on a file on screen.
- Write function to search for the name of an item, and to
change its price, after printing its current price.
Split this task into two separate functions.