0% found this document useful (0 votes)
105 views

Data Structure Module 1 Notes For Calicut University Sem 3 2024

data structure Module 1 notes for calicut university sem 3 2024 have everything you need to know
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
105 views

Data Structure Module 1 Notes For Calicut University Sem 3 2024

data structure Module 1 notes for calicut university sem 3 2024 have everything you need to know
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Module 1, Data structure

Data structure is the representation of the logical relationship existing between individual elements
of data.

In other words, a data structure is a way of organizing all data items that considers not only the
elements stored but also their relationship to each other.

Introduction

Data structure effects the design of both structural and functional aspect of a program.

You know that an algorithm is a step-by-step procedure to solve a particular function.

i.e., algorithm is a set of instructions written to Carrie out certain tasks and the data structure is the
way of organizing the data with their logical relationship retained.

To develop a program of an algorithm, we should select an appropriate data structure for that
algorithm.

Therefore, algorithm and its associated data structures is from a program.

Classification of data structures

Data structures are normally divided into 2 broad categories: Primitive data structures and non-
primitive data structures.

Primitive data structures

There are basic data structures and they are directly operated up on by the machine instructions.

In general, there are different representations of different computers.

Integers, floating point numbers, character constants, string constants, pointers, etc. fall in this
category

non primitive data structures

there are more sophisticated data structures.

These are derived from the primitive data structures.

The non primitive data structures emphasize on the structuring of a group of homogenies (same
type) or heterogenous data items.

List, stack, queue, tree, graph, are examples of non-primitive data structures.

The design of an efficient data structure must take operations to be performed on the data structure.

The most commonly used operation on data structures is broadly categorized into the following
types:

Create

Selection

Updating

Searching
Sorting

Merging

Destroy or delete

Difference between them

A primitive data structure is generally a basic structure that is usually built into the language, such as
indigen, or a float

A non-primitive data structure is built out of primitive data structures linked together in meaningful
ways.

Such as a linked list, binary search trees, AVL trees, graph, etc.

Description of various data structures

array

An array is defined as set of finite number of homogenous or same data items.

It means an array can contain 1 type of data only, either all integers, or float point, number of all
characters.

Simply, declaration of array is as follows

Int array [10];

Where, int specifies the datatype or type or elements array stores. “array” is the name of array and
the number specified inside the square bracket is the number elements an array can store (the
length of an array).

The individual element of an array can be accessed by specifying the name of the array, followed by
index or subscript inside the square brackets.

The first element of an array has index 0 and the last element of the array have index 9. Represented
by array [0], array [9] respectively.

The number of elements that can be stored in an array (in the consecutive memory locations) is
given by (upper bond – lower bond) + 1

List

A list can be defined as a collection of variable number of data items.

It is the most common non primitive data structure.

An element of list must contain 2 fields: 1 for storing data and other for storing the address of next
element.

Stack

A stack is an ordered collection of elements.

Like arrays, but it has special feature that deletion and insertion of elements can be done only from
one end called the top of stack (TOS).
Due to this property, it is also called as last in first out (lifo) type of data structure.

Insertion of element into stack is called push and deletion of element from stack is called pop.

The stack can be implemented in 2 ways: using arrays (static implementation), using pointer
(dynamic implementation)

Queue

Queue are the first in first out (fifo) type of data structures.

In a queue new elements are added to the queue from one end called rear-end and the elements are
always removed from another end called the front-end

The queue can be implemented by 2 methods: using arrays (static implementation), using pointer
(dynamic implementation).

Trees

A tree can be defined as data item (nodes)

Tree is a non-Lenier type of data structure. In which, data items are arranged or stored in a sorted
sequence

Tree represents the hierarchical relationship between data item

In trees there is a special data item at the top of hierarchy call the root of the tree

The remaining data items are partitioned into number of mutually exclusive subject, each of which is
itself, a tree which is called the subtree

The tree always gros in length towards bottom in ds

Graph

A graph is a mathematical non-Lenier data structure capable of representing many kind of physical
structure.

It has found application in geography, chemistry, and engineering science.

Definition

A graph g (v, e) is a set of vertices (v) and set of edges (e)

An edge connects a pair of vertices and many have wait such as length, cost and another measuring
instrument for recording to the graph.

Vertices on the graph are shown as point or circles and edges are drawn as arcs or line segments.

Types of graph

Directed graph

Undirected graph

Simple graph

Waited graph
Connected graph

Non-connected graph

Complexity of algorithm

To analyze an algorithm for calculating the amount of resources (time and storage) needed to
execute.

The complexity of an algorithm is a measure of time and or space required by the algorithm for an
input of a given size n

There are 2 types of complexity in which efficiency of an algorithm is measured: Space complexity
and time complexity

Space complexity

Space complexity is the amount of computer memory required during the program execution.

It depends on fixed part (input is of array, structure, etc.), variable part (input like linked list, stack,
queue, etc.)

Time complexity

Time complexity of an algorithm is the running time of the program as a function of input.

It depends on the number of machine instruction in which a program executes.

Note, based on the complexity, we have 3 cases:

best case – minimum number of steps, minimum number of time, and minimum number of storage.

Verst case – maximum number of steps, maximum number of time, and maximum number of
storage.

Average case – optimum number of steps, optimum number of time, and optimum number of
storage.

You might also like