✓
Looping
Outline
What is Data?
#3130702 (DS) ⬥ Unit 1 – Introduction to Data Structures
2
When your data become Information ?
#3130702 (DS) ⬥ Unit 1 – Introduction to Data Structures
3
What is Data Structure?
#3130702 (DS) ⬥ Unit 1 – Introduction to Data Structures
4
What is Data Structure? Cont..
Algorithm
Data Structure
Program
#3130702 (DS) ⬥ Unit 1 – Introduction to Data Structures
5
Classification of Data Structure
Data Structure
Primitive Data Structure
Non-Primitive Data Structure
Integer
Floating
Point
Characters
Pointers
Linear List
Non-linear List
Stack
Queue
Graphs
Trees
Arrays
Lists
Files
#3130702 (DS) ⬥ Unit 1 – Introduction to Data Structures
6
Primitive / Non-primitive data structures
#3130702 (DS) ⬥ Unit 1 – Introduction to Data Structures
7
Non primitive Data Structure
Array
List
File
#3130702 (DS) ⬥ Unit 1 – Introduction to Data Structures
8
Linear / Non-Linear data structure
Stack
Queue
Tree
Graph
#3130702 (DS) ⬥ Unit 1 – Introduction to Data Structures
9
Examples of Data Structure
Array
Facebook uses Graph Data Structure for showing connection between friends.
#3130702 (DS) ⬥ Unit 1 – Introduction to Data Structures
10
Example of Data Structure
#3130702 (DS) ⬥ Unit 1 – Introduction to Data Structures
11
Operations of Data Structure
#3130702 (DS) ⬥ Unit 1 – Introduction to Data Structures
12
Time and space analysis of algorithms
#3130702 (DS) ⬥ Unit 1 – Introduction to Data Structures
13
Calculate Time Complexity of Algorithm
#3130702 (DS) ⬥ Unit 1 – Introduction to Data Structures
14
Calculating Time Complexity
SumOfList(A,n)
{
Line 1 total = 0
Line 2 for i = 0 to n-1
Line 3 total = total + A[i]
Line 4 return total
}
A is array, n is no of elements in array
TSumOfList = 1 + 2 (n+1) + 2n + 1
= 4n + 4
= n
We can neglate constant 4
Time complexity of given algorithm is n unit time
Cost
No of Times
1
1
Line
1
2
n + 1
2
2
n
3
1
1
4
#3130702 (DS) ⬥ Unit 1 – Introduction to Data Structures
15