Data Structures and Algorithm Analysis: E-Mail
Data Structures and Algorithm Analysis: E-Mail
Algorithm Analysis
Yuhao Yi
E-mail: [email protected]
2
Course Introduction
311116030: Data Structures and
Algorithm Analysis
course page:
https://yhyi15.github.io/teaching/DSA
3-credit course
weeks 1-16, 12 lectures, 3 lab classes
Prerequisite courses:
Program design methodology (C)
Object-oriented programming (C++)
Discrete mathematics
Wechat
Textbook:
Data Structures and
Algorithm Analysis
in C++ Third Edition
Clifford A. Shaffer
You can buy the print
version online
The electronic pdf
version is at:
http://people.cs.vt.edu/~
shaffer/Book/ 5
There are some errors in the textbook,
which were fixed at
http://people.cs.vt.edu/~shaffer/Book/erra
ta.html
Other useful references
Introduction to Algorithms. 3rd edition, T. H.
Cormen, C. E. Leiserson, R. L. Rivest, and
C. Stein, 2009.
Algorithms. S. Dasgupta, C. H.
Papadimitriou, U. Vazirani , 2006.
Useful online course videos from Florida
University:
http://www.cise.ufl.edu/academics/courses/
preview/cop3530sahni/
Grade Policy-1
Part1 Preliminaries
Chap 1. Data structures and algorithms 2h
Chap 2. mathematical preliminaries 1h
Chap 3. Algorithm Analysis 3h
Course Outline-2
25
The Need for Data Structures
26
Organizing Data
27
Efficiency
A solution is said to be efficient if it solves the
problem within its resource constraints.
Space
Time
The cost of a solution is the amount of resources
that the solution consumes.
e.g.
Graphic rendering
Digital Video Analyzing
Server App
Communication Applications 28
Selecting a Data Structure
30
Data Structure Philosophy
31
Data Structure Philosophy (cont.)
32
Goals of this Course
1. Reinforce the concept that costs and
benefits exist for every data structure.
2. Learn the commonly used data structures.
These form a programmer's basic data
structure "toolkit".
3. Understand how to measure the cost of a
data structure or program.
These techniques also allow you to judge the
merits of new data structures that you or
others might invent.
33
Abstract Data Types
36
Logical vs. Physical Form
37
Data Type
ADT:
Data Items:
Type
Logical Form
Operations
38
Example 1.8
40
Problems (cont)
42
Algorithm Properties
An algorithm possesses the following five
properties:
It must be correct.
It must be composed of a series of concrete steps.
There can be no ambiguity as to which step will be
performed next.
It must be composed of a finite number of steps.
It must terminate.
45
Set
1) Enumeration:S={2,4,6,8,10}
2) Description:S={x | x is an even integer
number and 0≤x≤10}
S={x | x is an even positive number }
The cardinality of S ?
Three characteristics of a set
Example:
1. Compute n!
2. Hanoi puzzle
An example: the factorial function
1 n=0
fact(n) =
n*fact(n-1) n>0
int Fact ( int n )
{
int m;
if (n= =0) return(1);
else
{
m=n*Fact(n-1);
return(m);
} 52
}
Recursion-cont.
fact(n) = n * fact(n-1)
Recursive function may be difficult to
understand, the key is as follows:
Do not think how function fact(n-1) executes
Just assume that fact(n-1) returns the correct
results.
The ideas of abstract and divide and conquer
is very very useful in not only algorithm design
but also solving many problems in our lives
Mathematical Proof
58
Estimation Example
Estimate:
Pages/inch
Feet/shelf
Shelves/bookcase
59
Conclusion
The three goals of this course
The concepts of different data structures and
their costs and benefits
Adopt and design appropriate data structures
and algorithms for applications
Analyze the complexity of an algorithm/program
The definition of abstract data type
Grasp the idea of abstract
Hidden implementation details
Mathematical backgrounds
Set, logarithm, summation, recursion, three 60
proof techniques
Homework 1
Exercises
1.2, 1.14
2.17, 2.20, 2.29, 2.33, 2.34, 2.47
Deadline: TBA