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

MCS021 Data and File Structure

The document discusses algorithms and data structures. It covers topics like analysis of algorithms, asymptotic analysis, complexity classes, arrays, lists, stacks, queues, trees, and graph algorithms. Specific topics within these areas that are discussed include calculation of time and storage complexity, sparse matrices, different representations of arrays, linked lists, binary trees, and tree traversals.

Uploaded by

aditya alok
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

MCS021 Data and File Structure

The document discusses algorithms and data structures. It covers topics like analysis of algorithms, asymptotic analysis, complexity classes, arrays, lists, stacks, queues, trees, and graph algorithms. Specific topics within these areas that are discussed include calculation of time and storage complexity, sparse matrices, different representations of arrays, linked lists, binary trees, and tree traversals.

Uploaded by

aditya alok
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 88

MCS-021(Data and File Structure)

Block 1 INTRODUCTION TO
ALGORITHMS AND DATA STRUCTURES
UNIT 1 Analysis of Algorithms
UNIT 1 Analysis of Algorithms
1. Mathematical Background
2. Process of Analysis
3. Calculation of Storage
Complexity
4. Calculation of Time Complexity
Mathematical background
Definition of algorithm

Complexity classes

Asymptotic Analysis
Asymptotic notation
Asymptotic notation
Question :- f(n) = 3n3 + 2n 2 + 4n + 3
Like
Share
Comment
Subscribe
Process of Analysis
Process of Analysis
Calculation of storage complexity
Calculation of storage complexity
Calculation of storage complexity
Like
Share
Comment
Subscribe
Calculation of Time complexity
Calculation of Time complexity
The complexity Ladder:
1. T(n) = O(1). This is called constant growth.
2. T(n) = O(log2 (n)). This is called logarithmic growth.
3. T(n) = O(n). This is called linear growth.
4. T(n) = O(n log (n). This is called nlogn growth.
5. T(n) = O(nk ). This is called polynomial growth.
6. T(n) = O(2n ) This is called exponential growth
Calculation of Time complexity
The growth patterns above have been listed in order
of increasing size :-
O(1) < O(log(n)) < O(n log(n)) < O(n2
) < O(n3 ), ... , O(2n ).
Comparison of various algorithms and their complexities
Comparison of typical running time of algorithms of different
orders
MCS-021(Data and File Structure)
Block 1 INTRODUCTION TO
ALGORITHMS AND DATA STRUCTURES
UNIT 2 Arrays
UNIT 2 Arrays
1. Arrays and Pointers
2. Sparse Matrices
3. Polynomials
4. Representation of Arrays
5. Applications
Arrays and pointers
• HOMOGENEOUS TYPE OF ELEMENT

• ARRAY NAME STORES ADDRESS OF


FIRST ELEMENT

• CONTIGUOUS ELEMENT
Character arrays
Arrays and Address
1- D arrays
2- D arrays
Like
Share
Comment
Subscribe
Sparse matrices
Matrices with good number of zero entries are called sparse matrices.
Sparse matrices
Sparse matrices
Sparse matrices
Sparse matrices
Like
Share
Comment
Subscribe
Polynomials
REPRESENTATION OF ARRAYS
REPRESENTATION OF ARRAYS
1. Row Major Representation
2. Column Major
Representation
Row major Representation
Column major Representation
Application of array
MCS-021(Data and File Structure)
Block 1 INTRODUCTION TO
ALGORITHMS AND DATA STRUCTURES
UNIT 3 LISTS
UNIT 3 Lists
1. Abstract Data Type-List
2. Array Implementation of Lists
3. Linked Lists-Implementation
4. Doubly Linked Lists-Implementation
5. Circularly Linked Lists-Implementation
Abstract Data Type – List
• Abstract Data Type (ADT) is a useful tool for
specifying the logical properties of data type.
Abstract Data Type – List
Like
Share
Comment
Subscribe
Array implementation of lists
Insertion
• If we want to add element ‘35’ after element ‘33’. We have to shift 77
to 8th position, 66 to 7th position, so on, 44 to 5th position.
Deletion
If we want to delete an element ‘44’ from list. We have to shift 55 to 4th
position, 66 to 5th position, 77 to 6th position.
Like
Share
Comment
Subscribe
Linked Lists – implementation
The Linked list is a chain of structures in which each structure consists of
data as well as pointer, which stores the address (link) of the next logical
structure in the list.
Linked Lists – implementation
Insertion in Linked Lists
Insertion in Linked Lists
A node can be added in three ways
• At the front of the linked list
• After a given node.
• At the end of the linked list.
Deletion in Linked Lists
Like
Share
Comment
Subscribe
Doubly Linked Lists –implementation

Each element consisting of three fields:


• pointer to left element,
• data field,
• pointer to right element.
Like
Share
Comment
Subscribe
Circularly Linked Lists –implementation
Operations on a circular linked list are:
1. Insertion,
2. Deletion,
3. Traversing
Like
Share
Comment
Subscribe
MCS-021(Data and File Structure)
Block 2 STACKS, QUEUES AND TREES
UNIT 4 Stacks
UNIT 4 Stacks
1. Abstract Data Type-Stack
2. Implementation of Stack
3. Algorithmic Implementation of
Multiple Stacks
4. Applications
A stack is a linear structure in which items
may be inserted or removed only at
one end called the top of the stack.

Therefore, stacks are also called LIFO (Last In


First Out) or FILO (First In Last Out) lists.
Two operations are associated with the stacks named
1. Push :- is an operation used to insert an
element at the top.
2. Pop :- is an operation used to delete an
element from the top .
Push operation
Pop Operation
Abstract Data Type- Stack
A data type can be considered abstract
when it is defined in terms of operations
on it, and its implementation is hidden (so
that we can always replace one
implementation with another for, e.g.,
efficiency reasons, and this will not
interfere with anything in the program).
Implementation of stack
1. Implementation of Stack Using Arrays
2. Implementation of Stack Using Linked
Lists
Like
Share
Comment
Subscribe
Algorithmic implementation of multiple stacks
Application
MCS-021(Data and File Structure)
Block 2 STACKS, QUEUES AND TREES
UNIT 5 Queues
UNIT 5 Queues
1. Abstract Data Type-Queue
2. Implementation of Queue
3. Implementation of Multiple Queues
4. Implementation of Circular Queues
5. Implementation of DEQUEUE
Abstract Data Type-Queue
Like
Share
Comment
Subscribe
MCS-021(Data and File Structure)
Block 2 STACKS, QUEUES AND TREES
UNIT 6 TREES
UNIT 6 TREES
1. Abstract Data Type-Tree
2. Implementation of Tree
3. Tree Traversals
4. Binary Trees
5. Implementation of a Binary Tree
6. Binary Tree Traversals
Like
Share
Comment
Subscribe
MCS-021(Data and File Structure)
Block 3 GRAPH ALGORITHMS AND
SEARCHING TECHNIQUES
UNIT 7Advanced TREES
UNIT 6 TREES
1. Abstract Data Type-Tree
2. Implementation of Tree
3. Tree Traversals
4. Binary Trees
5. Implementation of a Binary Tree
6. Binary Tree Traversals
• Data Structure :
The logical and mathematical model of a particular
organization of data and the relationship among
its numbers is called a data structure.
❖It is organized collection of data which perform a
particular operation.
⮚Need of data structure:
To solve complex mathematical operations
Classification of Data Structure
Compound Data Structure
• Linear : In this data structure the elements are
organized in a sequence such as array.
• For example: array, stack , link list, queue.

• Non-Linear : In this data structure data is


organized without any sequence.
• For example : tree, graph, files.
Linear Data Structure
• Array:
1. Calculation of memory required in array.
2. Sparse matrices
3. 3- tuple representation
4. Polynomials
5. Row major representation
6. Column major representation
Calculation of memory required in
Array
• One- D Array
• Memory required (in bytes)= sizeof (datatype)* size of
array
• For example:
• Int a[10]
• Then , size of (datatype)=sizeof(int)=4bytes
• Size of array=10
• So, memory required = 4*10=40 bytes.
Two – D Array
• Memory required (in bytes)= sizeof 1st index * size
of 2nd index *sizeof (datatype)
• Int a [2][3]
• Then,
• Size of 1st index=2
• Size of 2nd index=3
• Sizeof (datatype)=sizeof(int)=4
• So, memory required = 2*3*4=24 bytes.

You might also like