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
Separate compilation
What it is?
put different parts of
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
Recursive functions with multiple calls
Recursion [Bono]
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 this one; make sure you have all of them. If you need ad
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 function will be called):
class FunObj cfw_ public: retur
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 this one; make sure you have all of them. Note: There i
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 ordered vector
from scratch.
Insertion sort in place in
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
Stacks [Bono]
1
Stacks
a collection of things (like a v
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]
1
Sorting in STL (review)
Pass in iterators for start
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 structure
family tree
expression tree
Trees [Bono]
2
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
functions
parameter passing
identifier scope
default paramete
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 have been present and working during the
entire lab peri
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
Assigned Monday mornings
Due Sunday nights at 11:59 pm
Home
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+ Programming:
2
Classes
Object-oriented design (OOD): a problem
H
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+ Programming: Program Design
Including Data Structures, Sixt
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
Extra review session on Friday (4 6 pm?)
Homework 2 assi
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 declaration.
What is the purpose of the C+ keywords
new
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 [Bono]
1
map idea
Stores a collection of key-value pairs
Ke
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
keeps track of dependencies between source files
auto
Constructors
Role of constructors Constructors for contained objects Member initializer list Rationale for initializing Order of initialization Code in body of constructor Constructing objects contained in a vector
Product and Time examples are from Big
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 a location in memory. All data in programs have address
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 example to learn about C+ features
Stacks [Bono]
1
Produce
Name: _
USC Username: _
CSCI 102
Fall 2010 Exam #1
Problems
Problem #1 (14 points) _
Problem #2 (15 points) _
Problem #3 (20 points) _
Problem #4 (16 points) _
Problem #5 (35 points) _
Total (100 points)
_
Problem 1 Short Answer (14 points)
Give a brief a
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
Compare one algorithm / data structure to another
before
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 searching in an
ordered array or vector.
Example of d
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) is a binary tree such that
we store data (key+option
Documenting classes
Example: Fraction class
Idea
Using
Definition
Documenting Fraction class
as a whole
member functions
implementation
Preconditions, Postconditions, Invariants and assert
Documenting classes [Bono]
1
Fraction class
extend numer
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 from Big C+, by
Cay Horsmann and Timothy Budd; Wiley 20