You are on page 1of 15

Lecture 34 – Practice for Final Exam

Last Lecture
 Designed and implemented a linked list-based Queue data collection class
 Created class documentation for our class
 Now we can differentiate between a List, a Stack and a Queue

Copyright © Anne Lavergne, School of Computing Science, Simon Fraser University 2


Today’s Menu
 Let’s have a look at Participation Activity 10
 Last thing to be said about our Queue data collection class
 A few practice exercises for our final exam
 Participation Activity 11
 Participation Activity 12
 Information about Final Exam
 Office Hours during Final Exam period
 Quiz 3 grades will be imported into CourSys by Monday August 8.
 Then, make sure all your grades posted on CourSys are as you are expecting
them to be. If not, please, email by Friday August 12 23:59:59.

Copyright © Anne Lavergne, School of Computing Science, Simon Fraser University 3


Exercise 1 - Designing &
implementing data
Step 1 - Problem Statement and Requirements
 Imagine you are asked to write a program that is to keep a record of each of the
students registered in CMPT 125.
 Design and implement the data you will need to model in order to solve this
problem …
 In C
 In C++

Copyright © Anne Lavergne, School of Computing Science, Simon Fraser University 4


Exercise 2 - Designing &
implementing data
Step 1 - Problem Statement and Requirements
 Imagine you are asked to write a program that is to keep a record of each of the
activities of CMPT 125.
 Design and implement the data you will need to model in order to solve this
problem …
 In C
 In C++

Copyright © Anne Lavergne, School of Computing Science, Simon Fraser University 5


Exercise 3 – Recursion - 1
Step 1 - Problem Statement and Requirements
Write a recursive C function which must prints a pattern of stars on the computer
monitor screen as illustrated in the Sample Interfaces on the following slides.

Copyright © Anne Lavergne, School of Computing Science, Simon Fraser University 6


Exercise 3 – Recursion - 2
Sample interface 1: 1
6

Copyright © Anne Lavergne, School of Computing Science, Simon Fraser University 7


Exercise 3 – Recursion - 3
Sample interface 2: 0
5

Copyright © Anne Lavergne, School of Computing Science, Simon Fraser University 8


Exercise 3 – Recursion - 3
Sample interface 3: 3
10

Copyright © Anne Lavergne, School of Computing Science, Simon Fraser University 9


Exercise 4 – s/w Development
Step 1. Problem Statement and Requirements
Write a C program that reads in 15 decimal digits in an array.
 A decimal digit is an integer from 0 to 9.

 Your program must then output a 2-column list where the first column, called
Digit, is a list of each distinct decimal digit appearing in the array, and the
second column, called Frequency, is the number of occurrences of each
decimal digit in the array.
 On the next few slides, you will find sample inputs and sample outputs.
 Your C program is expected to have functions and to have been implemented
following our Good Programming Style (GPS).

Copyright © Anne Lavergne, School of Computing Science, Simon Fraser University 10


Exercise 4 - Test Case #1
Sample input:

Sample output:

Copyright © Anne Lavergne, School of Computing Science, Simon Fraser University 11


Exercise 4 - Test Case #2
Sample input:

Sample output:

Note the way the Digits column is displayed. Your program must follow this layout.
Copyright © Anne Lavergne, School of Computing Science, Simon Fraser University 12
Exercise 5 – s/w Development
Step 1. Problem Statement and Requirements
Solve the problem of Exercise 4 by writing a C++ program.
 Your program must satisfy the same requirements as the requirements listed
in Exercise 4.
 Your program must use a data collection class.

Copyright © Anne Lavergne, School of Computing Science, Simon Fraser University 13


Exercise 6 – Queue data collection class
Step 1. Problem Statement and Requirements
Implement the Queue data collection class using the Queue.h file posted under
Lecture 34. Note: this header file is different from the Queue.h posted under
lecture 33.
 If you need a Node class, use the one given in Quiz 4 and amend it if need be.
 Make sure you implement a complete test driver to test your Queue data
collection class.
 If you need a makefile, use the one given in Quiz 4 and amend it.

Copyright © Anne Lavergne, School of Computing Science, Simon Fraser University 14


No More Lectures!
 Good luck and see you during office hours!

Copyright © Anne Lavergne, School of Computing Science, Simon Fraser University 15

You might also like