0% found this document useful (0 votes)
33 views

CSCI 104: Mark Redekopp

This document provides an overview of CSCI 104. It discusses administrative issues like course preparation, syllabus, and expectations. It also provides helpful links and introduces an opening example about organizing a phonebook data structure. The document emphasizes that the best way to organize data depends on how it will be used and introduces common data structure operations and their time complexities. It discusses abstract data types and how object-oriented programming fits with the concept of ADTs. The overall goals of the course are to learn good programming practice with object-oriented design and techniques for implementing and analyzing data structures and their efficiency.

Uploaded by

Rui Veleiro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

CSCI 104: Mark Redekopp

This document provides an overview of CSCI 104. It discusses administrative issues like course preparation, syllabus, and expectations. It also provides helpful links and introduces an opening example about organizing a phonebook data structure. The document emphasizes that the best way to organize data depends on how it will be used and introduces common data structure operations and their time complexities. It discusses abstract data types and how object-oriented programming fits with the concept of ADTs. The overall goals of the course are to learn good programming practice with object-oriented design and techniques for implementing and analyzing data structures and their efficiency.

Uploaded by

Rui Veleiro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

1

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

More Helpful Links


• Remedial modules
– http://ee.usc.edu/~redekopp/csmodules.html
• Class website
– http://bytes.usc.edu/cs104 (not bits.usc.edu)
4

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

Opening Example (cont.)


• Would it ever be reasonable to have the phonebook in a
random or unsorted order?
– What if the phonebook was for the residence of a town with only a
few residents
– What if there was a phonebook for Mayflies (life expectancy of 1-24
hours)
• Might want to optimize for additions and removals
• Plus, a mayfly doesn't have fingers to dial their phones so why would they
even be trying to search the phonebook
• Main Point: The best way to organize data depends on how it
will be used.
– Frequent search
– Frequent addition/removals
– Addition/removal patterns (many at once or one at a time)
6

Why Data Structures Matter?


• Modern applications process vast amount of data
• Adding, removing, searching, and accessing are common operations
• Various data structures allow these operations to be completed with
different time and storage requirements

Data Structure Insert Search Get-Min


Unsorted List O(1) O(n) O(n)
Balanced Binary
O(lg n) O(lg n) O(lg n)
Search Tree
Heap O(lg n) O(n) O(1)

Recall O(n) indicates that the actual run-time is bounded by some


expression a*n for some n > n0 (where a and n0 are constants)
7

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

N O(1) O(log2n) O(n) O(n*log2n) O(n2) O(2n)

2 1 1 2 2 4 4

20 1 4.3 20 86.4 400 1,048,576

200 1 7.6 200 1,528.8 40,000 1.60694E+60

2000 1 11.0 2000 21,931.6 4,000,000 #NUM!


8

Abstract Data Types


• Beginning programmers tend to focus on the code and less on the data
and its organization
• More seasoned programmers focus first on
– What data they have
– How it should be organized
– How it will be accessed
• An abstract data type describes what data is stored and what operations
are to be performed
• A data structure is a specific way of storing the data implementing the
operations
• Example ADT: List
– Data: items of the same type in a particular order
– Operations: insert, remove, get item at location, set item at location, find
• Example data structures implementing a List:
– Linked list, array, etc.
9

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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy