SlideShare a Scribd company logo
Data Structures
Introduction
Evaluation of Algorithms
Arrays
Sparse Matrix
Dr. R. Khanchana
Assistant Professor
Department of Computer Science
Sri Ramakrishna College of Arts and Science for Women
Syllabus
• UNIT I Introduction: Introduction of Algorithms, Analysing Algorithms. Arrays: Sparse Matrices -
Representation of Arrays. Stacks and Queues. Fundamentals - Evaluation of Expression Infix to
Postfix Conversion - Multiple Stacks and Queues
• UNIT II Linked List: Singly Linked List - Linked Stacks and Queues - Polynomial Addition - More on
Linked Lists - Sparse Matrices - Doubly Linked List and Dynamic - Storage Management - Garbage
Collection and Compaction.
• UNIT III Trees: Basic Terminology - Binary Trees - Binary Tree Representations - Binary Trees -
Traversal - More on Binary Trees - Threaded Binary Trees - Binary Tree Representation of Trees -
Counting Binary Trees. Graphs: Terminology and Representations - Traversals, Connected
Components and Spanning Trees, Shortest Paths and Transitive Closure
• UNIT IV External Sorting: Storage Devices -Sorting with Disks: K-Way Merging - Sorting with Tapes
Symbol Tables: Static Tree Tables - Dynamic Tree Tables - Hash Tables: Hashing Functions - Overflow
Handling.
• UNIT V Internal Sorting: Insertion Sort - Quick Sort - 2 Way Merge Sort - Heap Sort - Shell Sort -
Sorting on Several Keys. Files: Files, Queries and Sequential organizations - Index Techniques -File
Organizations.
Text Books
TEXT BOOKS
• 1. Ellis Horowitz, Sartaj Shani, Data Structures,
Galgotia Publication.
• 2. Ellis Horowitz, Sartaj Shani, Sanguthevar
Rajasekaran, Computer Algorithms, Galgotia
Publication.
• E-book -
http://icodeguru.com/vc/10book/books/book
1/chap01.htm
What is a Data structure?
• Data are just a collection of facts and figures
• Data Structure is not a Programming Language
• Data structure is a set of Algorithms that we
are implementing by using any programming
language to solve some Problems.
Chapter 1 - Introduction
• Data Structure - Store and organize data
• Data Structure means to structure the information while
storing
• Data deals two things
– Data Storing
– Data Processing
• Data structure deal with storage of the information, how
effectively to store information or data.
• To structure the data n number of Algorithms are proposed.
• Algorithm - all these Algorithms are called Abstract Data
Types(ADT)
• Abstract data types are set of rules.
Data Structure Types
Linear Data Structure
Array Stack Queue
Linked List
Non- Linear Data Structure
Graph
Algorithms - Overview
• An algorithm is a procedure having well
defined steps for solving a particular problem.
• Definition: Algorithm is finite set of logic or
instructions, written in order for accomplish
the certain predefined task.
• It is not the complete program or code, it is
just a solution (logic) of a problem
– Can be represented either as a Flowchart or
Pseudo code.
Study of Algorithms
(i) machines for executing algorithms
– From the smallest pocket calculator to the largest general
purpose digital computer.
(ii) languages for describing algorithms
– language design and translation.
(iii) foundations of algorithms
– Particular task accomplishable by a computing device
– What is the minimum number of operations necessary for
any algorithm which performs a certain function?
(iv) analysis of algorithms
Performance is measured in terms of the computing time
and space that are consumed while the algorithm is processing
Characteristics of an Algorithm
• Input
– There are zero or more quantities which are externally supplied
• Output
– At least one quantity is produced
• Definiteness
– Each instruction must be clear and unambiguous
• Finiteness
– If trace out the instructions of an algorithm, then for all cases
the algorithm will terminate after a finite number of steps
• Effectiveness
– Time & Space
– Every instruction must be sufficiently basic and also be feasible.
Flowchart
• Raw data is input and algorithms are used to
transform it into refined data. So, instead of
saying that computer science is the study of
algorithms, alternatively, it is the study of data:
• (i) machines that hold data;
• (ii) languages for describing data manipulation;
• (iii) foundations which describe what kinds of
refined data can be produced from raw data;
• (iv) structures for representing data.
Example: Flowchart for obtaining a
Coca-Cola
Data Type & Data Object
• A data type is a term which refers to the kinds
of data that variables may "hold" in a
programming language.
• Data object is a term referring to a set of
elements, say D.
– Data object integers refers to D = {0, 1, 2, ...}. The
data object alphabetic character strings of length
less than thirty one implies D = {",'A','B', ...,'Z','AA',
...}. Thus, D may be finite or infinite
Natural Number Procedure
Data Structure Definition
Assignment
• Real Time Examples for Non Primitive (User
Defined ) Data Structure
Mind Map
Quiz
• https://quizizz.com/admin/quiz/5f01950c48b
149001bbb2f83
Feedback
• https://docs.google.com/forms/d/1xGRGWBX
QSfsXuJrzEIpIXDSd_54iOKnFA9TgsA0cUNc/edit
How to Analyze
Programs/Algorithms?
There are many criteria upon which judge a
program, for instance:
• (i) Does it do what we want it to do?
• (ii) Does it work correctly according to the
original specifications of the task?
• (iii) Is there documentation which describes how
to use it and how it works?
• (iv) Are subroutines created in such a way that
they perform logical sub-functions?
• (v) Is the code readable?
Priori and Posteriori Difference
Performance evaluation
• Performance evaluation can be divided into 2
major phases:
– (a) a priori estimates and
– (b) a posteriori testing. Both of these are equally
important.
• First consider a priori estimation. Suppose
that somewhere in one of your programs is
the statement
• x = x + 1
Performance evaluation
Time Complexity
– first is the amount of time a single execution will
take
– second is the number of times it is executed.
• The product of these numbers will be the total
time taken by this statement.
• The second statistic is called the frequency
count, and this may vary from data set to data
set.
Posteriori Testing
• It is impossible to determine exactly how
much time it takes to execute any command
unless we have the following information:
• (i) the machine we are executing on:
• (ii) its machine language instruction set;
• (iii) the time required by each machine
instruction;
• (iv) the translation a compiler will make from
the source to the machine language.
Posteriori Testing
Frequency Count
Fibonacci Series - Example
• To clarify some of these ideas, let us
look at a simple program for
computing the n-th Fibonacci
number. The Fibonacci sequence
starts as
• 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, ...
• Each new term is obtained by taking
the sum of the two previous terms.
If we call the first term of the
sequence F0 then F0 = 0, F1 = 1 and in
general
• Fn = Fn-1 + Fn-2, n 2.
• The program on the following page
takes any non-negative
integer n and prints the value Fn.
Frequency counts for the first three
cases
Execution Count
• A complete set
would include four
cases: n < 0, n =
0, n = 1 and n > 1.
Below is a table
which summarizes
the frequency
counts for the first
three cases.
Time Computation
• For example n might be the number of inputs
or the number of outputs or their sum or the
magnitude of one of them. For the Fibonacci
program n represents the magnitude of the
input and the time for this program is written
as T(FIBONACCI) = O(n).
Quiz
• https://quizizz.com/admin/quiz/5f03267c0f96
04001b9fa3f3
Assignment
• Differentiate Priori and Posteriori estimation
Feedback
• https://docs.google.com/forms/d/1eutZ8m1e
qJ3DeHBFVX8c7p8CvNOwb_tGE2CZxgIhYuY/e
dit
Chapter 2 - Arrays
AXIOMATIZATION
• Array is a consecutive set of
memory locations.
• Element − Each item stored in an
array is called an element.
• Index − Each location of an
element in an array has a
numerical index, which is used to
identify the element.
• Dimensions
Array
Array Dimensions
– One dimensional Array
– Two dimensional Array
– Three dimensional Array
– Multi Dimensional Array
1-D
2-D
Definition of Row & Column Major
• In row-major order, the consecutive elements
of a row reside next to each other, whereas
the same holds true for consecutive elements
of a column in column-major order.
Row & Column Major
• Row-major order
• Column-major order
Logical View of 3 × 5 Matrix
Array Length
If an array is declared A(l1 :u1,l2:u2, ...,ln:un), then it is easy to see that the
number of elements is
Example :
If we have the declaration A(4:5, 2:4, 1:2, 3:4) then we have a total of
2 * 3 * 2 * 2 = 24 elements.
Array Length -Example
• 1-D A[5..12]
• Formula - Ui-li+1
• Elements are
• U,B,F,D,A,E,C
• 7-0+1
• 6
• 2-D A[0..2]B[0..3]
• Formula - (U1-l1+1) * (U2-l2+1)
• Array Size
• =(2-0+1)*(3-0+1) = 3 *4 = 12
SIZE
Array Memory Allocation
2-D array
b[i][j]
1-D array
a[10]
Array Representation
• The 2-D array A(1:u1,1:u2) may be interpreted as u1 rows:
row 1,row 2, ...,row u1, each row consisting of u2 elements. In a
row major representation, these rows would be represented
in memory as in figure 2.4.
If is the address of A(1), then the
address of an arbitrary element A(i) is
just + (i - 1).
array element: A(l), A(2), A(3), ..., A(i), ..., A(u1)
address: , + 1, + 2, ..., + i - 1, ..., + u1 - 1
total number of elements = u1
Array Representation
Each 2-dimensional array is represented as in
Figure 2.4.
REPRESENTATION OF ARRAYS
• Multidimensional arrays are provided as a
standard data object in which they are
represented in memory. Recall that memory
may be regarded as one dimensional with
words numbered from 1 to m.
– One dimensional array - A(i1,i2, ...,in),
– Two dimensional array A(l1 :u1,l2:u2, ...,ln: un)
– The number of elements is
Quiz
• https://quizizz.com/admin/quiz/5f044375e95
a63001d065401
Assignment
• Write the given array in row Major and
Column Major Order
• 3 * 4 matrix
Feedback
• https://docs.google.com/forms/d/1Mrqtcwuo
glKWBQauXWMA5ztpv6a-
Mfq5C8IG6mokuuU/edit
Array Assignment Results
• Write the given array in row Major and Column Major Order 3 * 4 matrix
SPARSE MATRICES
• A matrix is a mathematical object which arises in
many physical problems.
• A general matrix consists of m rows and n columns of
numbers as in figure 2.1.
• Sparse Matrix has many zero entries.
Sparse Matrix Representation
• To store a matrix in a 2-D
array, say A(1:m, 1:n)
• Each element of a matrix is
uniquely characterized by its
row and column position,
say i , j. S
• Store a matrix as a list of 3-
tuples of the form (i,j,value)
• 3-tuples of any row be
stored so that the columns
are increasing.
• Store the second matrix of
figure 2.1 in the
array A(0:t,1:3) where t = 8
is the number of nonzero
terms.
Matrix Transpose
Matrix -Transpose
Matrix -Transpose
Transpose -Algorithm
Example :
The difficulty is in not knowing where to put the
element (j,i,val) until all other elements which
precede it have been processed.
– (1,1,15) which becomes (1,1,15)
– (1,4,22) which becomes (4,1,22)
– (1,6, - 15) which becomes (6,1, - 15)
Procedure - Transpose
The algorithm for this takes the form:
Quiz
• https://quizizz.com/admin/quiz/5f01c97dd77
0b3001b1867ab
Feedback
• https://docs.google.com/forms/d/1HClhSDE7
REndsxs-huVIZk9exetX1RX2LK8RSVlwwII/edit
Ad

Recommended

Unit I - Evaluation of expression
Unit I - Evaluation of expression
DrkhanchanaR
 
Unit I-Data Structures_Intoduction.pptx
Unit I-Data Structures_Intoduction.pptx
DrkhanchanaR
 
Data structure ppt
Data structure ppt
Prof. Dr. K. Adisesha
 
Constructor in java
Constructor in java
Pavith Gunasekara
 
Classes, objects in JAVA
Classes, objects in JAVA
Abhilash Nair
 
Toward an Epistemology of Engineering (slides)
Toward an Epistemology of Engineering (slides)
Antonio Dias de Figueiredo
 
Writing Research Paper
Writing Research Paper
Nishu Kanwar
 
Data Structure and Algorithms
Data Structure and Algorithms
iqbalphy1
 
Unit 2 linked list
Unit 2 linked list
DrkhanchanaR
 
Unit I-Data structures stack & Queue
Unit I-Data structures stack & Queue
DrkhanchanaR
 
Unit 5 internal sorting &amp; files
Unit 5 internal sorting &amp; files
DrkhanchanaR
 
3.9 external sorting
3.9 external sorting
Krish_ver2
 
Unit 3 Tree chapter 5
Unit 3 Tree chapter 5
DrkhanchanaR
 
Unit 4 external sorting
Unit 4 external sorting
DrkhanchanaR
 
Data Structure and Algorithms Hashing
Data Structure and Algorithms Hashing
ManishPrajapati78
 
Unit 3 graph chapter6
Unit 3 graph chapter6
DrkhanchanaR
 
Queue - Data Structure - Notes
Queue - Data Structure - Notes
Omprakash Chauhan
 
Bca data structures linked list mrs.sowmya jyothi
Bca data structures linked list mrs.sowmya jyothi
Sowmya Jyothi
 
stack & queue
stack & queue
manju rani
 
Linked lists
Linked lists
SARITHA REDDY
 
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
Sowmya Jyothi
 
Queue in Data Structure
Queue in Data Structure
Janki Shah
 
linked lists in data structures
linked lists in data structures
DurgaDeviCbit
 
Binary Tree in Data Structure
Binary Tree in Data Structure
Meghaj Mallick
 
Unit I Database concepts - RDBMS & ORACLE
Unit I Database concepts - RDBMS & ORACLE
DrkhanchanaR
 
List Data Structure
List Data Structure
Zidny Nafan
 
Data Structures : hashing (1)
Data Structures : hashing (1)
Home
 
Queue as data_structure
Queue as data_structure
eShikshak
 
lecture 01.1.ppt
lecture 01.1.ppt
NathanielAdika
 
Data Structures - Lecture 1 - Unit 1.pptx
Data Structures - Lecture 1 - Unit 1.pptx
DanielNesaKumarC
 

More Related Content

What's hot (20)

Unit 2 linked list
Unit 2 linked list
DrkhanchanaR
 
Unit I-Data structures stack & Queue
Unit I-Data structures stack & Queue
DrkhanchanaR
 
Unit 5 internal sorting &amp; files
Unit 5 internal sorting &amp; files
DrkhanchanaR
 
3.9 external sorting
3.9 external sorting
Krish_ver2
 
Unit 3 Tree chapter 5
Unit 3 Tree chapter 5
DrkhanchanaR
 
Unit 4 external sorting
Unit 4 external sorting
DrkhanchanaR
 
Data Structure and Algorithms Hashing
Data Structure and Algorithms Hashing
ManishPrajapati78
 
Unit 3 graph chapter6
Unit 3 graph chapter6
DrkhanchanaR
 
Queue - Data Structure - Notes
Queue - Data Structure - Notes
Omprakash Chauhan
 
Bca data structures linked list mrs.sowmya jyothi
Bca data structures linked list mrs.sowmya jyothi
Sowmya Jyothi
 
stack & queue
stack & queue
manju rani
 
Linked lists
Linked lists
SARITHA REDDY
 
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
Sowmya Jyothi
 
Queue in Data Structure
Queue in Data Structure
Janki Shah
 
linked lists in data structures
linked lists in data structures
DurgaDeviCbit
 
Binary Tree in Data Structure
Binary Tree in Data Structure
Meghaj Mallick
 
Unit I Database concepts - RDBMS & ORACLE
Unit I Database concepts - RDBMS & ORACLE
DrkhanchanaR
 
List Data Structure
List Data Structure
Zidny Nafan
 
Data Structures : hashing (1)
Data Structures : hashing (1)
Home
 
Queue as data_structure
Queue as data_structure
eShikshak
 
Unit 2 linked list
Unit 2 linked list
DrkhanchanaR
 
Unit I-Data structures stack & Queue
Unit I-Data structures stack & Queue
DrkhanchanaR
 
Unit 5 internal sorting &amp; files
Unit 5 internal sorting &amp; files
DrkhanchanaR
 
3.9 external sorting
3.9 external sorting
Krish_ver2
 
Unit 3 Tree chapter 5
Unit 3 Tree chapter 5
DrkhanchanaR
 
Unit 4 external sorting
Unit 4 external sorting
DrkhanchanaR
 
Data Structure and Algorithms Hashing
Data Structure and Algorithms Hashing
ManishPrajapati78
 
Unit 3 graph chapter6
Unit 3 graph chapter6
DrkhanchanaR
 
Queue - Data Structure - Notes
Queue - Data Structure - Notes
Omprakash Chauhan
 
Bca data structures linked list mrs.sowmya jyothi
Bca data structures linked list mrs.sowmya jyothi
Sowmya Jyothi
 
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
Sowmya Jyothi
 
Queue in Data Structure
Queue in Data Structure
Janki Shah
 
linked lists in data structures
linked lists in data structures
DurgaDeviCbit
 
Binary Tree in Data Structure
Binary Tree in Data Structure
Meghaj Mallick
 
Unit I Database concepts - RDBMS & ORACLE
Unit I Database concepts - RDBMS & ORACLE
DrkhanchanaR
 
List Data Structure
List Data Structure
Zidny Nafan
 
Data Structures : hashing (1)
Data Structures : hashing (1)
Home
 
Queue as data_structure
Queue as data_structure
eShikshak
 

Similar to Unit I- Data structures Introduction, Evaluation of Algorithms, Arrays, Sparse Matrix (20)

lecture 01.1.ppt
lecture 01.1.ppt
NathanielAdika
 
Data Structures - Lecture 1 - Unit 1.pptx
Data Structures - Lecture 1 - Unit 1.pptx
DanielNesaKumarC
 
Introduction to Data Structures Sorting and searching
Introduction to Data Structures Sorting and searching
Mvenkatarao
 
Lecture 1 (bce-7)
Lecture 1 (bce-7)
farazahmad005
 
jn;lm;lkm';m';;lmppt of data structure.pdf
jn;lm;lkm';m';;lmppt of data structure.pdf
VinayNassa3
 
Iare ds ppt_3
Iare ds ppt_3
AlugatiRajitha
 
in computer data structures and algorithms
in computer data structures and algorithms
FIONACHATOLA
 
b,Sc it data structure.pptx
b,Sc it data structure.pptx
classall
 
b,Sc it data structure.ppt
b,Sc it data structure.ppt
classall
 
b,Sc it data structure.pptx
b,Sc it data structure.pptx
classall
 
a581a6a2cb5778045788f0b1d7da1c0236f.pptx
a581a6a2cb5778045788f0b1d7da1c0236f.pptx
christinamary2620
 
assignment character education assignment
assignment character education assignment
tsegayeblen57
 
Algorithms & Complexity Calculation
Algorithms & Complexity Calculation
Akhil Kaushik
 
Intro_2.ppt
Intro_2.ppt
MumitAhmed1
 
Intro.ppt
Intro.ppt
SharabiNaif
 
Intro.ppt
Intro.ppt
Anonymous9etQKwW
 
Unit 1, ADA.pptx
Unit 1, ADA.pptx
jinkhatima
 
AoA Lec Design of algorithm spresentation
AoA Lec Design of algorithm spresentation
HamzaSadaat
 
Algorithm and Data Structures - Basic of IT Problem Solving
Algorithm and Data Structures - Basic of IT Problem Solving
coolpie
 
Data structure and algorithm.
Data structure and algorithm.
Abdul salam
 
Data Structures - Lecture 1 - Unit 1.pptx
Data Structures - Lecture 1 - Unit 1.pptx
DanielNesaKumarC
 
Introduction to Data Structures Sorting and searching
Introduction to Data Structures Sorting and searching
Mvenkatarao
 
jn;lm;lkm';m';;lmppt of data structure.pdf
jn;lm;lkm';m';;lmppt of data structure.pdf
VinayNassa3
 
in computer data structures and algorithms
in computer data structures and algorithms
FIONACHATOLA
 
b,Sc it data structure.pptx
b,Sc it data structure.pptx
classall
 
b,Sc it data structure.ppt
b,Sc it data structure.ppt
classall
 
b,Sc it data structure.pptx
b,Sc it data structure.pptx
classall
 
a581a6a2cb5778045788f0b1d7da1c0236f.pptx
a581a6a2cb5778045788f0b1d7da1c0236f.pptx
christinamary2620
 
assignment character education assignment
assignment character education assignment
tsegayeblen57
 
Algorithms & Complexity Calculation
Algorithms & Complexity Calculation
Akhil Kaushik
 
Unit 1, ADA.pptx
Unit 1, ADA.pptx
jinkhatima
 
AoA Lec Design of algorithm spresentation
AoA Lec Design of algorithm spresentation
HamzaSadaat
 
Algorithm and Data Structures - Basic of IT Problem Solving
Algorithm and Data Structures - Basic of IT Problem Solving
coolpie
 
Data structure and algorithm.
Data structure and algorithm.
Abdul salam
 
Ad

Recently uploaded (20)

Aprendendo Arquitetura Framework Salesforce - Dia 02
Aprendendo Arquitetura Framework Salesforce - Dia 02
Mauricio Alexandre Silva
 
June 2025 Progress Update With Board Call_In process.pptx
June 2025 Progress Update With Board Call_In process.pptx
International Society of Service Innovation Professionals
 
Peer Teaching Observations During School Internship
Peer Teaching Observations During School Internship
AjayaMohanty7
 
How payment terms are configured in Odoo 18
How payment terms are configured in Odoo 18
Celine George
 
Photo chemistry Power Point Presentation
Photo chemistry Power Point Presentation
mprpgcwa2024
 
How to Manage Different Customer Addresses in Odoo 18 Accounting
How to Manage Different Customer Addresses in Odoo 18 Accounting
Celine George
 
LDMMIA Yoga S10 Free Workshop Grad Level
LDMMIA Yoga S10 Free Workshop Grad Level
LDM & Mia eStudios
 
Intellectual Property Right (Jurisprudence).pptx
Intellectual Property Right (Jurisprudence).pptx
Vishal Chanalia
 
Vitamin and Nutritional Deficiencies.pptx
Vitamin and Nutritional Deficiencies.pptx
Vishal Chanalia
 
GREAT QUIZ EXCHANGE 2025 - GENERAL QUIZ.pptx
GREAT QUIZ EXCHANGE 2025 - GENERAL QUIZ.pptx
Ronisha Das
 
Hurricane Helene Application Documents Checklists
Hurricane Helene Application Documents Checklists
Mebane Rash
 
VCE Literature Section A Exam Response Guide
VCE Literature Section A Exam Response Guide
jpinnuck
 
LDMMIA Shop & Student News Summer Solstice 25
LDMMIA Shop & Student News Summer Solstice 25
LDM & Mia eStudios
 
How to Customize Quotation Layouts in Odoo 18
How to Customize Quotation Layouts in Odoo 18
Celine George
 
THE PSYCHOANALYTIC OF THE BLACK CAT BY EDGAR ALLAN POE (1).pdf
THE PSYCHOANALYTIC OF THE BLACK CAT BY EDGAR ALLAN POE (1).pdf
nabilahk908
 
Chalukyas of Gujrat, Solanki Dynasty NEP.pptx
Chalukyas of Gujrat, Solanki Dynasty NEP.pptx
Dr. Ravi Shankar Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
Tanja Vujicic - PISA for Schools contact Info
Tanja Vujicic - PISA for Schools contact Info
EduSkills OECD
 
NSUMD_M1 Library Orientation_June 11, 2025.pptx
NSUMD_M1 Library Orientation_June 11, 2025.pptx
Julie Sarpy
 
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Rajdeep Bavaliya
 
Plate Tectonic Boundaries and Continental Drift Theory
Plate Tectonic Boundaries and Continental Drift Theory
Marie
 
Aprendendo Arquitetura Framework Salesforce - Dia 02
Aprendendo Arquitetura Framework Salesforce - Dia 02
Mauricio Alexandre Silva
 
Peer Teaching Observations During School Internship
Peer Teaching Observations During School Internship
AjayaMohanty7
 
How payment terms are configured in Odoo 18
How payment terms are configured in Odoo 18
Celine George
 
Photo chemistry Power Point Presentation
Photo chemistry Power Point Presentation
mprpgcwa2024
 
How to Manage Different Customer Addresses in Odoo 18 Accounting
How to Manage Different Customer Addresses in Odoo 18 Accounting
Celine George
 
LDMMIA Yoga S10 Free Workshop Grad Level
LDMMIA Yoga S10 Free Workshop Grad Level
LDM & Mia eStudios
 
Intellectual Property Right (Jurisprudence).pptx
Intellectual Property Right (Jurisprudence).pptx
Vishal Chanalia
 
Vitamin and Nutritional Deficiencies.pptx
Vitamin and Nutritional Deficiencies.pptx
Vishal Chanalia
 
GREAT QUIZ EXCHANGE 2025 - GENERAL QUIZ.pptx
GREAT QUIZ EXCHANGE 2025 - GENERAL QUIZ.pptx
Ronisha Das
 
Hurricane Helene Application Documents Checklists
Hurricane Helene Application Documents Checklists
Mebane Rash
 
VCE Literature Section A Exam Response Guide
VCE Literature Section A Exam Response Guide
jpinnuck
 
LDMMIA Shop & Student News Summer Solstice 25
LDMMIA Shop & Student News Summer Solstice 25
LDM & Mia eStudios
 
How to Customize Quotation Layouts in Odoo 18
How to Customize Quotation Layouts in Odoo 18
Celine George
 
THE PSYCHOANALYTIC OF THE BLACK CAT BY EDGAR ALLAN POE (1).pdf
THE PSYCHOANALYTIC OF THE BLACK CAT BY EDGAR ALLAN POE (1).pdf
nabilahk908
 
Tanja Vujicic - PISA for Schools contact Info
Tanja Vujicic - PISA for Schools contact Info
EduSkills OECD
 
NSUMD_M1 Library Orientation_June 11, 2025.pptx
NSUMD_M1 Library Orientation_June 11, 2025.pptx
Julie Sarpy
 
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Rajdeep Bavaliya
 
Plate Tectonic Boundaries and Continental Drift Theory
Plate Tectonic Boundaries and Continental Drift Theory
Marie
 
Ad

Unit I- Data structures Introduction, Evaluation of Algorithms, Arrays, Sparse Matrix

  • 1. Data Structures Introduction Evaluation of Algorithms Arrays Sparse Matrix Dr. R. Khanchana Assistant Professor Department of Computer Science Sri Ramakrishna College of Arts and Science for Women
  • 2. Syllabus • UNIT I Introduction: Introduction of Algorithms, Analysing Algorithms. Arrays: Sparse Matrices - Representation of Arrays. Stacks and Queues. Fundamentals - Evaluation of Expression Infix to Postfix Conversion - Multiple Stacks and Queues • UNIT II Linked List: Singly Linked List - Linked Stacks and Queues - Polynomial Addition - More on Linked Lists - Sparse Matrices - Doubly Linked List and Dynamic - Storage Management - Garbage Collection and Compaction. • UNIT III Trees: Basic Terminology - Binary Trees - Binary Tree Representations - Binary Trees - Traversal - More on Binary Trees - Threaded Binary Trees - Binary Tree Representation of Trees - Counting Binary Trees. Graphs: Terminology and Representations - Traversals, Connected Components and Spanning Trees, Shortest Paths and Transitive Closure • UNIT IV External Sorting: Storage Devices -Sorting with Disks: K-Way Merging - Sorting with Tapes Symbol Tables: Static Tree Tables - Dynamic Tree Tables - Hash Tables: Hashing Functions - Overflow Handling. • UNIT V Internal Sorting: Insertion Sort - Quick Sort - 2 Way Merge Sort - Heap Sort - Shell Sort - Sorting on Several Keys. Files: Files, Queries and Sequential organizations - Index Techniques -File Organizations.
  • 3. Text Books TEXT BOOKS • 1. Ellis Horowitz, Sartaj Shani, Data Structures, Galgotia Publication. • 2. Ellis Horowitz, Sartaj Shani, Sanguthevar Rajasekaran, Computer Algorithms, Galgotia Publication. • E-book - http://icodeguru.com/vc/10book/books/book 1/chap01.htm
  • 4. What is a Data structure? • Data are just a collection of facts and figures • Data Structure is not a Programming Language • Data structure is a set of Algorithms that we are implementing by using any programming language to solve some Problems.
  • 5. Chapter 1 - Introduction • Data Structure - Store and organize data • Data Structure means to structure the information while storing • Data deals two things – Data Storing – Data Processing • Data structure deal with storage of the information, how effectively to store information or data. • To structure the data n number of Algorithms are proposed. • Algorithm - all these Algorithms are called Abstract Data Types(ADT) • Abstract data types are set of rules.
  • 7. Linear Data Structure Array Stack Queue Linked List
  • 8. Non- Linear Data Structure Graph
  • 9. Algorithms - Overview • An algorithm is a procedure having well defined steps for solving a particular problem. • Definition: Algorithm is finite set of logic or instructions, written in order for accomplish the certain predefined task. • It is not the complete program or code, it is just a solution (logic) of a problem – Can be represented either as a Flowchart or Pseudo code.
  • 10. Study of Algorithms (i) machines for executing algorithms – From the smallest pocket calculator to the largest general purpose digital computer. (ii) languages for describing algorithms – language design and translation. (iii) foundations of algorithms – Particular task accomplishable by a computing device – What is the minimum number of operations necessary for any algorithm which performs a certain function? (iv) analysis of algorithms Performance is measured in terms of the computing time and space that are consumed while the algorithm is processing
  • 11. Characteristics of an Algorithm • Input – There are zero or more quantities which are externally supplied • Output – At least one quantity is produced • Definiteness – Each instruction must be clear and unambiguous • Finiteness – If trace out the instructions of an algorithm, then for all cases the algorithm will terminate after a finite number of steps • Effectiveness – Time & Space – Every instruction must be sufficiently basic and also be feasible.
  • 12. Flowchart • Raw data is input and algorithms are used to transform it into refined data. So, instead of saying that computer science is the study of algorithms, alternatively, it is the study of data: • (i) machines that hold data; • (ii) languages for describing data manipulation; • (iii) foundations which describe what kinds of refined data can be produced from raw data; • (iv) structures for representing data.
  • 13. Example: Flowchart for obtaining a Coca-Cola
  • 14. Data Type & Data Object • A data type is a term which refers to the kinds of data that variables may "hold" in a programming language. • Data object is a term referring to a set of elements, say D. – Data object integers refers to D = {0, 1, 2, ...}. The data object alphabetic character strings of length less than thirty one implies D = {",'A','B', ...,'Z','AA', ...}. Thus, D may be finite or infinite
  • 17. Assignment • Real Time Examples for Non Primitive (User Defined ) Data Structure
  • 21. How to Analyze Programs/Algorithms? There are many criteria upon which judge a program, for instance: • (i) Does it do what we want it to do? • (ii) Does it work correctly according to the original specifications of the task? • (iii) Is there documentation which describes how to use it and how it works? • (iv) Are subroutines created in such a way that they perform logical sub-functions? • (v) Is the code readable?
  • 22. Priori and Posteriori Difference
  • 23. Performance evaluation • Performance evaluation can be divided into 2 major phases: – (a) a priori estimates and – (b) a posteriori testing. Both of these are equally important. • First consider a priori estimation. Suppose that somewhere in one of your programs is the statement • x = x + 1
  • 24. Performance evaluation Time Complexity – first is the amount of time a single execution will take – second is the number of times it is executed. • The product of these numbers will be the total time taken by this statement. • The second statistic is called the frequency count, and this may vary from data set to data set.
  • 25. Posteriori Testing • It is impossible to determine exactly how much time it takes to execute any command unless we have the following information: • (i) the machine we are executing on: • (ii) its machine language instruction set; • (iii) the time required by each machine instruction; • (iv) the translation a compiler will make from the source to the machine language.
  • 28. Fibonacci Series - Example • To clarify some of these ideas, let us look at a simple program for computing the n-th Fibonacci number. The Fibonacci sequence starts as • 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, ... • Each new term is obtained by taking the sum of the two previous terms. If we call the first term of the sequence F0 then F0 = 0, F1 = 1 and in general • Fn = Fn-1 + Fn-2, n 2. • The program on the following page takes any non-negative integer n and prints the value Fn.
  • 29. Frequency counts for the first three cases
  • 30. Execution Count • A complete set would include four cases: n < 0, n = 0, n = 1 and n > 1. Below is a table which summarizes the frequency counts for the first three cases.
  • 31. Time Computation • For example n might be the number of inputs or the number of outputs or their sum or the magnitude of one of them. For the Fibonacci program n represents the magnitude of the input and the time for this program is written as T(FIBONACCI) = O(n).
  • 33. Assignment • Differentiate Priori and Posteriori estimation
  • 35. Chapter 2 - Arrays AXIOMATIZATION • Array is a consecutive set of memory locations. • Element − Each item stored in an array is called an element. • Index − Each location of an element in an array has a numerical index, which is used to identify the element. • Dimensions
  • 36. Array
  • 37. Array Dimensions – One dimensional Array – Two dimensional Array – Three dimensional Array – Multi Dimensional Array 1-D 2-D
  • 38. Definition of Row & Column Major • In row-major order, the consecutive elements of a row reside next to each other, whereas the same holds true for consecutive elements of a column in column-major order.
  • 39. Row & Column Major • Row-major order • Column-major order
  • 40. Logical View of 3 × 5 Matrix
  • 41. Array Length If an array is declared A(l1 :u1,l2:u2, ...,ln:un), then it is easy to see that the number of elements is Example : If we have the declaration A(4:5, 2:4, 1:2, 3:4) then we have a total of 2 * 3 * 2 * 2 = 24 elements.
  • 42. Array Length -Example • 1-D A[5..12] • Formula - Ui-li+1 • Elements are • U,B,F,D,A,E,C • 7-0+1 • 6 • 2-D A[0..2]B[0..3] • Formula - (U1-l1+1) * (U2-l2+1) • Array Size • =(2-0+1)*(3-0+1) = 3 *4 = 12 SIZE
  • 43. Array Memory Allocation 2-D array b[i][j] 1-D array a[10]
  • 44. Array Representation • The 2-D array A(1:u1,1:u2) may be interpreted as u1 rows: row 1,row 2, ...,row u1, each row consisting of u2 elements. In a row major representation, these rows would be represented in memory as in figure 2.4. If is the address of A(1), then the address of an arbitrary element A(i) is just + (i - 1). array element: A(l), A(2), A(3), ..., A(i), ..., A(u1) address: , + 1, + 2, ..., + i - 1, ..., + u1 - 1 total number of elements = u1
  • 45. Array Representation Each 2-dimensional array is represented as in Figure 2.4.
  • 46. REPRESENTATION OF ARRAYS • Multidimensional arrays are provided as a standard data object in which they are represented in memory. Recall that memory may be regarded as one dimensional with words numbered from 1 to m. – One dimensional array - A(i1,i2, ...,in), – Two dimensional array A(l1 :u1,l2:u2, ...,ln: un) – The number of elements is
  • 48. Assignment • Write the given array in row Major and Column Major Order • 3 * 4 matrix
  • 50. Array Assignment Results • Write the given array in row Major and Column Major Order 3 * 4 matrix
  • 51. SPARSE MATRICES • A matrix is a mathematical object which arises in many physical problems. • A general matrix consists of m rows and n columns of numbers as in figure 2.1. • Sparse Matrix has many zero entries.
  • 52. Sparse Matrix Representation • To store a matrix in a 2-D array, say A(1:m, 1:n) • Each element of a matrix is uniquely characterized by its row and column position, say i , j. S • Store a matrix as a list of 3- tuples of the form (i,j,value) • 3-tuples of any row be stored so that the columns are increasing. • Store the second matrix of figure 2.1 in the array A(0:t,1:3) where t = 8 is the number of nonzero terms.
  • 56. Transpose -Algorithm Example : The difficulty is in not knowing where to put the element (j,i,val) until all other elements which precede it have been processed. – (1,1,15) which becomes (1,1,15) – (1,4,22) which becomes (4,1,22) – (1,6, - 15) which becomes (6,1, - 15)
  • 57. Procedure - Transpose The algorithm for this takes the form: