CSCI 104: Mark Redekopp
CSCI 104: Mark Redekopp
CSCI 104
Overview
Mark Redekopp
2
Administrative Issues
• Preparation
– Basic if, while, for constructs
– Arrays, linked-lists
– Structs, classes
– Dynamic memory allocation and pointers
– Recursion
• Syllabus
– http://bytes.usc.edu/cs104 (Not bits.usc.edu)
• Expectations
– I'll give you my best, you give me yours…
• Attendance, participation, asking questions, academic integrity, take an
interest
– Treat CS104 right!
– Let's make this fun
3
An Opening Example
• Consider a paper phonebook
– Stores names of people and their phone numbers
• What operations do we perform with this data
– You: Lookup/search
– Phone Company: Add, Remove
• How is the data stored and ordered and why?
– Sorted by name to make lookup faster…
– How fast? That's for you to figure out…
• What if it was sorted by phone number or just random? What
is the worst case number of records you'd have to look at to
find a particular persons phone number?
5
50
Importance of Complexity 400
N
45
350 N2
40 N*log2(N)
300
35
30 250
Run-time
Run-time
25 200
20
150
15
100
10
5 50
0 0
0 5 10 15 20 25 30 35 40 45 50 0 2 4 6 8 10 12 14 16 18 20
N N
2 1 1 2 2 4 4
Transition to Object-Oriented
• Object-oriented paradigm fits nicely with idea of ADTs
– Just as ADTs focus on data and operations performed on it so objects
combine data + functions
• Objects (C++ Classes) allows for more legible, modular,
maintainable code units
• Suppose you and a friend are doing an electronic dictionary
app. Your friend codes the dictionary internals and you code
the user-interface.
– You don't care how they implement it just that it supports the desired
operations and is fast enough
– Abstraction: Provides a simplified interface allowing you to reason
about the higher level logic and not the low level dictionary ops.
– Encapsulation: Shields inside from outside so that internals can be
changed w/o affecting code using the object
10
Course Goals
• Learn about good programming practice with object-
oriented design
– Learn good style and more advanced C++ topics such as
templates, inheritance, polymorphism, etc.
• Learn basic and advanced techniques for
implementing data structures and analyzing their
efficiency
– May require strong fundamentals including mathematical
analysis
– This is why we couple CS 104 and CS 170