Académique Documents
Professionnel Documents
Culture Documents
Course Name
Course Teacher :
Class Schedule :
Tuesday
Thursday
: 11:45 am - 1:00 pm
: 1:00 pm 2.15 pm
- (10% +10%)
Midterm
- 30%
Final
- 30%
--------------------------------Total
2
- 100%
Course Outline
1. Concepts and examples
2. Elementary data objects
3. Elementary data structures
4. Arrays
5. Lists
6. Stacks
7. Queues
8. Graphs
9. Trees
10.Sorting and searching
11.Hash techniques
3
Books
1. Theory
Data Structures
Data Structures
The logical or mathematical model of a particular organization of data is called a data
structure.
Types of Data Structure
1. Linear Data Structure
Example: Arrays, Linked Lists, Stacks, Queues
2. Nonlinear Data Structure
Example: Trees, Graphs
A
Array
E F
Tree
B
D
C
E
It must be rich enough in structure to mirror the actual relationships of data in the
real world.
2.
The structure should be simple enough that one can effectively process data when
necessary.
10
20
30
40
50
60
70
80
Figure 2: Array with 8 items
7
10
20
40
30
50
60
70
Algorithms
It is a well-defined set of instructions used to solve a particular problem.
Example:
Write an algorithm for finding the location of the largest element of an array Data.
Largest-Item (Data, N, Loc)
1. set k:=1, Loc:=1 and Max:=Data[1]
2. while k<=N repeat steps 3, 4
3.
4.
Set k:=k+1
exit
Complexity of Algorithms
O-notation
- A function f(n)=O(g(n)) if there are positive constants c and n 0 such that
f(n)<=c.g(n) for all n>= n0.
- When f(n)=O(g(n)), it is guaranteed that f(n) grows at a rate no faster than g(n).
So g(n) is an upper bound on f(n).
Example:
(a) f(n) = 3n+2
Here f(n) <= 5n for n>=1
So, f(n) = O(n).
(b) f(n) = 3n2-2
Here f(n) < 3n2 for n>=1
So, f(n) = O(n2).
11
Rule-2
If f(n) is a polynomial of degree k, then f(n) = (nk).
Rule-3
Logkn = O(n) for any constant.
12
Name
Constant
logn
Logarithmic
log2n
Log-squared
Linear
nlogn
n2
Quadratic
n3
Cubic
2n
Exponential
13