Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
48 views

Introduction To Data Structures

The document discusses key concepts related to data structures and algorithms including different types of data structures like arrays, linked lists, stacks, queues, trees and graphs. It also covers operations on data structures, mathematical notations used in algorithms, analyzing algorithmic complexity in terms of best, average and worst cases, and using Big O notation to describe the time complexity of algorithms.
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views

Introduction To Data Structures

The document discusses key concepts related to data structures and algorithms including different types of data structures like arrays, linked lists, stacks, queues, trees and graphs. It also covers operations on data structures, mathematical notations used in algorithms, analyzing algorithmic complexity in terms of best, average and worst cases, and using Big O notation to describe the time complexity of algorithms.
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 27

Points to be Discussed

Basic Concepts and Notations


Data Structures and operations on Data
Structures
Types of Data Structures
Mathematical Notations and Functions
Algorithmic Complexity with Best,
Average and Worst Cases
Big O Notation
Basic concepts and notations
Basic Concepts & Notations
Data: Data can be defined as representation
of facts, concepts or instructions in some
manner.
Data Item(Field): A set of characters which
are used together to represent a specific data
item.
Record: It is a collection of related data
items.
File: It is a collection of related records.
Entity: It is a person, place, thing or concept
about which information is recorded.
DATA sTRUCTURES
Data Structures
Data + Structure = Data Structure
The logical or mathematical model of particular
organization of data is known as Data
Structure. It is the organized collection of data.
The data structure is a process of how the data
items are organized in computer memory for
the processing.
Data Structures
The choice of a particular data model
depends on two considerations:
It must be rich enough in structure to
mirror the actual relationships of the data
in the real world.
The structure should be simple enough
that one can effectively process the data
when necessary.
Types of data
structures
Types of Data Structures
Data Structures

Linear Non-Linear
Elements form Sequence Elements do not form Sequence

Arrays
Linked- Lists Trees
Stacks Graphs
Queues
Types of Data Structures
Arrays:
The simplest type of Data Structures is a
linear array. By linear array we mean a list of
finite number n of similar data elements,
usually 1,2,3,4,…….,n
Linked Lists:
Linked List is a collection of nodes. Each
node is divided into two parts. First part
contains the info of the data item and the
second part contains the pointer to the next
node
Types of Data Structures
Stacks:
A Stack, also called Last-In-First-Out(LIFO)
system, is a linear list in which insertions and
deletions can take place only at one end
“top”
Queues:
A Queue, also called First-In-First-
Out(FIFO) system, is a linear list in which
deletions can take place only at one end
“front” and insertions can take place at the
other end “rear”
Types of Data Structures
Trees:
Trees are non-linear data structure used to
represent the data containing a hierarchical
relationship between elements, e.g., records,
family trees, and tables of contents
Graphs:
A Graph is a non-linear data structure having
a set V of elements called nodes and set E of
edges such that each edge e is identified with
a unique pair [u,v] of nodes in V, denoted by
e=[u,v]
Operations on data structures
Operations on Data Structures
The Data appearing in our Data Structures
are processed by means of certain operations
Traversing:
Accessing each record exactly once so that
certain items in the record may be processed
Inserting:
Adding a new record to the Structure
Deleting:
Removing a record from the Structure
Operations on Data Structures
Sorting:
Arranging the records in some logical order
Searching:
Finding the location of the record with a
given key value, or finding the locations of
all records which satisfy one or more
conditions
Merging:
Combining the records in two different
sorted files into a single sorted file
Mathematical notations
and functions
Mathematical Notations &
Functions
 Floor and Ceiling Functions:
Let x be any real number. Then x lies b/w two integers called
the floor and ceiling of x.
 Remainder Function:

Let k be any integer and let M be a positive integer. Then


k(mod M) will denote the integer remainder when k is divided
by M.
 Integer and Absolute Functions:

Let x be any real number. The integer value of x, written


INT(x), converts x into an integer by deleting the fractional
part of the number.
Mathematical Notations &
Functions
 Factorial Function:
The product of the positive integers from 1 to n, inclusive is
denoted by n!. That is:
n!=1.2.3.4.5.6…..(n-2)(n-1)n
 Permutations:

A permutation of a set of n elements is an arrangement of the


elements in a given order. Example – Arranging the elements abc
 Exponents and Algorithms:

The value of log depends on the base of algorithm. Commonly


used bases are 10, 2, and e.
Algorithmic complexity
Algorithmic Complexity
An algorithm is a sequence of steps that gives
method of solving a problem. It creates the logic
of program. Efficiency of program depends on
two major criteria, first one is run time of that
algorithm and second is the space.
Runtime of algorithm means the time
taken by the program for execution. We
implement different data structures, some data
structures take more space but improves the
runtime and some takes less space but it effects
runtime of algorithm.
Algorithmic Complexity
The complexity of an algorithm M is the
function f(n) which gives the running time
and/or storage space requirement of the
algorithm in terms of the size n of the
input data. Frequently, the storage space
required by an algorithm is simply a
multiple of the data size n.
Algorithmic Complexity
1.Best Case: In this case, algorithm searches
the element in first time itself. Ex-
Searching with linear search.
2.Average Case: In average case we take the
probability with list of data. Average case of
algorithm should be the average number of
steps but since data can be at any place, so
finding exact behavior of algorithm is
difficult.
3.Worst Case: In this case we find the element
at the end or when searching of element fails.
Algorithmic Complexity

5 ms worst-case
4 ms

3 ms
}
average-case?
best-case
2 ms

1 ms

A B C D E F G
Input
Big o notation
BIG O NOTATION
Definition:-
Suppose functions f(n) and g(n) are
functions defined on positive integer
number n, then function f(n) = O(g(n)), read
as “ f of n is big O of g of n” , or as “f(n) is
of the order of g(n)”, if there exists positive
constants c and no, such that f(n) <= c* g(n)
for all values of n>=no
Big O Notation
 Big O Notation is used to measure the performance of
any algorithm. Performance of any algorithm depends
on input of any data. It is proportional to the input
data. For a particular input size n we know how a
particular algorithm behaves but when n increases and
it becomes larger, then the same algorithm behaves
differently. So O notation defines the order of
growth of any algorithm which is useful to
measure the performance of algorithm.
Suppose M is an algorithm, and suppose n is
the size of the input data. Clearly the complexity f(n)
of M increases as n increases. It is usually the rate of
increase of f(n) that we want
Big O Notation
to examine. This is usually done by comparing
f(n) with some standard function such as
log2n, n, n log2n, n², n3, 2n
The rates of growth of these functions are as:
log2n n n log 2n n² n3 2n
5 3 5 15 25 125 32

10 4 10 40 100 103 103

100 7 100 700 104 106 1030

1000 10 103 104 106 109 10300


Big O Notation
 O(1): When we get data in first time itself. ( Constant
Computing time)
 O(n): When all the elements of list will be traversed( Execute
in Linear time)
 O(n²): When the full list be traversed for each element
(Quadratic time)
 O(log2n): When we divide list half each time and traverse the
middle element
 O(n log2n): When we divide list half each time and traverse
that half portion
 O(n3): it increments every element in an n.n.n 3d array of
integers (Cubic time)
 O(2n)- This time increase very dramatically in relation to the
size of n.(Exponential time)

You might also like