Name: _ USC loginid (e.g., ttrojan) :_
Final Exam CS 102, Spring 2009 [Bono]
May 12, 2009
There are 10 problems on the exam, with 93 points total available. There are 12 pages to the exam, including t
Separate compilation
why how to use separately linked code what goes in header files Example: separately compiled Fraction class how to compile and link Using #ifndef
Separate compilation [Bono]
1
Se
Trees
examples
definition and terminology
binary trees
computer representations
traversing binary trees
Trees [Bono]
1
Examples
Trees are hierarchies:
USC School Department structure
Unix directory
STL Algorithms
STL sort revisited
sorting in decreasing order
Function objects (a.k.a. functors)
Ex: sort on another field
for_each
copy algorithm
Categories of iterators
STL Algorithms [Bono]
Stacks
Stack abstract data type (ADT)
applications
interface for a Stack class
ex use: reverse a string
representing stacks
stack class implementations as an example to learn
about C+ features
S
Sorting
O(n2) sorts
examples:
insertion sort
selection sort
O(nlogn) sorts
example: quicksort
Comparison of sorts
Sorting in STL
Sorting [Bono]
1
Insertion sort
What we do when we build an or
Name: _ USC loginid (e.g., ttrojan):_
CS 102 Midterm Exam 2 Spring 2009 [Bono]
April 2, 2009
There are 8 problems on the exam, with 84 points total available. There are 8 pages to the exam, including
CSCI 102 [S09 Bono]
Code Handout to accompany final exam
Review of function object syntax: A function object must overload the function call operator; returnType and paramList, below, depend on how fu
Recursion
Idea
A few examples
wishful thinking method
Recursion with linked lists. Ex: printList
Recursion in classes
Ex: palindromes
Helper functions
Computational complexity of recursive functions
R
XKCD #208
Courtesy of
Randall Munroe
@
http:/xkcd.com
QT
What is QT?
Pronounced cute
A cross-platform application development
framework built by Nokia
A toolkit for building Graphical User
Interfaces
CSCI 102: Data Strctures
Exam Review
September 27, 2012
Exam Review
What is the purpose of namespaces in C+
+?
Explain what each of the the keywords
public, private and protected mean
inside a class d
CSCI 102: Data Structures
September 25, 2012
Announcements
Class schedule
Pointers today (Chapter 12)
Exam review on Thursday
Midterm exam next Tuesday
Previous years' exams are posted on BlackBoard
E
CSCI 102: Data Structures
September 18 and 20, 2012
Announcements 9/18
Office hours also available by appointment
I can help you with an idea for a game
Suggestions and feedback are welcome
C+ Prog
CSCI 102: Data Structures
September 13, 2012
Today
Classes
private, protected, and public members
Constructors and destructors
Abstract data types (ADTs)
Information hiding
static members
C+ Programmi
CSCI 102: Data Structures
September 11, 2012
Announcements
Guest lecturer on Thursday
Introduction to C+ classes
No office hours for George on Thursday
Course schedule updated with homework
dates
Assi
CSCI 102: Data Structures
September 6, 2012
Announcements
TA office hours
Kaveh: Th 1-3 pm
Mahdi: Mon 1-3pm
Jeff: Fr 9-11 am
When labs are due
You should finish each lab during the lab period
If you h
CSCI 102: Data Structures
September 4, 2012
Announcements
Course schedule with reading assignments on
BlackBoard
Today: Control Structures
Checking input
switch statements
while loops
for loops
functi
STL map and set
STL map container
idea
representation and complexity
iterator
concordance example
STL set container
STL multiset and multimap
hash_map (extension to STL)
STL maps and sets [Bon
Make utility
dependencies
Makefile
rules
using gmake
variables
built-in rules
bigger example
naming the Makefile, and more
Make [Bono]
1
What is it?
make (and gmake)
remembers long compile commands
Documenting classes
Example: Fraction class
Idea
Using
Definition
Documenting Fraction class
as a whole
member functions
implementation
Preconditions, Postconditions, Invariants and assert
Do
Binary search trees 2
Inserting
Removing
Big-O of BST
Other search tree data structures
Table ADT
and compare big-O again
Binary search trees 2 [Bono]
1
Binary search tree
A binary search tree (BST
Binary search and more algorithm
analysis
Binary search
logn time
2n time
Compare ordered vector vs. ordered list
Algorithm analysis revisited [Bono]
1
Binary search
Binary search is an algorithm for
Intro to Algorithm Analysis
Algorithm analysis
worst case
big-O
O(n), O(1), O(n2)
Compare complexity of some operations on
vectors
Intro to Algorithm Analysis [Bono]
1
Algorithm analysis idea
Co
Stacks
Readings: Ch. 5 (shown for next week) Stack abstract data type (ADT) applications interface for a Stack class ex use: reverse a string representing stacks stack class implementations as an exa
Dynamic data and pointers
definitions motivation new NULL dangling pointers / address-of memory leaks delete pointers and class aliasing
Dynamic data and pointers [Bono]
1
Definitions
An address is
Constructors
Role of constructors Constructors for contained objects Member initializer list Rationale for initializing Order of initialization Code in body of constructor Constructing objects contai
Review of classes
Review of procedural abstraction
Discovering classes
Example class definition
Information hiding (encapsulation)
Member function definitions
* Product and Time examples and code are