You are on page 1of 3

UNIT 1 Data Structures Using C 1

Data Structure
The organized collection of data in a mathematical or logical way is called Data Structure.
OR
A way of storing and organizing data in a computer is called data structure.
Classification of Data Structure:

Data
Structure

Primitive Data Non-Primitive Data


Structure Structure

Linear Data Non-linear Data


int Structure Structure

char Array Trees

float Graphs
Linked List
Double
Stack

Queue

Primitive Data Structure: A data structure can be manipulated by machine level instructions
is called primitive data structure. Example: int, float, char, double, long etc.
Non-Primitive Data Structure: A data structure which cannot be manipulated directly by
machine level instructions is called non-primitive data structure. They are two types:
1. Linear Data Structure
2. Non-linear Data Structure
Linear Data Structure: A Data Structure which stores all the elements sequentially in memory
is called linear Data Structure. Example: Array, Linked List, Stack and Queue.
Array: It is a definite collection of homogenous elements that can be stored sequentially.
Example: int A[3];
Memory representation of an array
101 102 103 104 105 106 107 108

A[0] A[1] A[2] A[3]


Array may be 1D, 2D and Multi-dimensional.
Linked List: A list is a linear data structure, it is a collection of data items named as nodes
each node is divided into two fields that is data and link field. Example

SINDHI COLLEGE BANGALORE - 24


UNIT 1 Data Structures Using C 2

50 60 70 80 NULL
The types of linked list are:
1. Singly List
2. Doubly List
3. Circular List
Stack: It is a linear data structure, the data can be inserted and deleted at one end is known
TOP. Stack works in the fashion of LIFO.

C top
B
A
Queue: Queue is a linear data structure which has two ends. One end is used to insert the
element named as REAR and the other end is used to delete the element named as FRONT.
FRONT REAR

A B C D E F G
Non-Linear Data Structure
Data structures where data elements are not arranged sequentially or linearly are called non-
lineardata structures. Example: Tree, Graph.
Tree: It is a finite set of nodes or vertices each tree has a root node and remaining nodes are
considered as leaf nodes or sub trees.

B C

D E

SINDHI COLLEGE BANGALORE - 24


UNIT 1 Data Structures Using C 3

Here, A is root node, C,D,E is leaf node, B is a internal node.


Graph: Graph is a finite set of ordered pair G=(V,E) where V is the vertices and E is the edges.
It is a collection of adjacent vertices.

B C

Operations on Data Structures:


The data structure can be classified as
• Insertion
• Deletion
• Traverse
• Searching
• Sorting
• Merging
Insertion: Adding a new element to the existing data structure.
Deletion: Deleting an element from Data Structure.
Traverse: Accessing each element exactly once.
Searching: Search a particular element in the list of elements present in the Data Structure.
Sorting: Arranging the elements in ascending or descending order.
Merging: Combining two sorted Data Structure into a single sorted Data Structure.

Algorithm: An algorithm is a step by step procedure to perform a specific task in a finite


amount of time.

Algorithm complexity: It is a measure of amount of time and space required by an algorithm


for an input of a given size ‘N’.
Time Complexity: Time complexity describes the amount of time an algorithm takes in terms
of the amount of input to the algorithm.
Space Complexity: Space complexity describes the amount of memory space an algorithm
takes in terms of the amount of input to the algorithm.

Mathematical notations and functions


1. Floor & Ciel function
Floor function provides the greatest integer that is not greater than the given value. The
symbol for floor function is ⌊ ⌋
Example x=4.678
⌊𝒙⌋ =4

SINDHI COLLEGE BANGALORE - 24

You might also like