s03 Introduction To Data Structure
s03 Introduction To Data Structure
1
Learning Outcomes
2
Outline
3
Data Type
4
Abstract Data Type
5
Structure
6
Structure Declaration
structure name
struct tdata {
int age;
char name[100]; structure member
float score;
};
7
Structure Declaration
struct tdata {
int age;
char name[100];
float score;
};
8
Structure Declaration
struct tdata {
struct tdata { int age;
int age; char name[100];
char name[100]; float score;
float score; };
} a, b;
tdata a;
tdata b;
9
Structure Assignments
tdata x;
x.age = 17;
strcpy(x.name, “andi”);
x.score = 82.5;
10
Nested Structure
11
Array of Structure
12
Data Structure
13
Types of Data Structure
• Arrays
– A collection of similar data elements
– Data elements have the same data type
14
Types of Data Structure
• Linked Lists
– A very dynamic data structure in which the elements
can be added to or deleted from anywhere at will
– Each element is called a node
15
Types of Data Structure
• Queue
– The element that was inserted first is the first one
to be taken out
– The elements in a queue are added at one end
called the rear and removed from the other end
called the front
16
Types of Data Structure
• Stacks
– Stacks can be represented as a linear array
– Every stack has a variable TOP associated with it
– LIFO (Last In First Out) / FILO (First In Last Out)
17
Types of Data Structure
• Binary Trees
– A data structure which is defined as a collection of
elements called the nodes
– Every node contains a left pointer, a right pointer,
and a data element
18
References
• S. Sridhar. 2015. Design and Analysis of Algorithms. Oxford
University Press. New Delhi. ISBN: 9780198093695. Chapter 5
• Reema Thareja. 2014. Data structures using C. Oxford University
Press. New Delhi. ISBN:9780198099307. Chapter 2 & 5
• Structures In C, http://www.asic-
world.com/scripting/structs_c.html
19