Lecture # 0 Data - Structures - and - Algorithm
Lecture # 0 Data - Structures - and - Algorithm
Lecture # 0 Data - Structures - and - Algorithm
Contact Information
2
Interface
Each data structure has an interface. Interface
represents the set of operations that a data structure
supports. An interface only provides the list of
supported operations, type of parameters they can
accept and return type of these operations.
Implementation
Implementation provides the internal representation
of a data structure. It also provides the definition of
algorithms used in the operation of data structure.
thanks to www.tutorialspoint.com
Characteristics of Data Structure
11
Correctness
Data structure implementation should implement
its interface correctly.
Time Complexity
Running time or the execution time of operations
of data structure must be as small as possible.
Space Complexity
Memory usage of a data structure operation
should be as little as possible.
thanks to www.tutorialspoint.com
Selecting a Data Structure
Select a data structure as follows:
1. Analyze the problem to determine the resource
constraints a solution must meet.
2. Determine the basic operations that must be supported.
Quantify the resource constraints for each operation.
3. Select the data structure that best meets these
requirements.
Data Structure Philosophy
Each data structure has costs and benefits.
Rarely is one data structure better than another in all
situations.
A data structure requires:
space for each data item it stores,
programming effort.
14 Introduction to Algorithms
A precise rule (or set of rules) specifying
how to solve some problem.
Algorithms
15
thanks to www.tutorialspoint.com
Characteristics of an Algorithm
16
Problem
Algorithm
Proving correctness
Empirical analysis
Optimality
Algorithm Efficiency
23
thanks to www.tutorialspoint.com
Fundamental Data Structures
27
Linked list
queue
tree stack
Linear Data Structures
29
a[0] a[1] a[2] a[3] a[4] a[5] a[6] a[7] a[8] a[9]
1 2 3 4 5 6 7 8 9 10
Front 20 30 10 60 57 29 Back
37 Non-Linear Data Structures
Graphs
Trees
Hash Tables
Graphs
38