SlideShare a Scribd company logo
Course: BCA-II
Subject: Data Structure
Unit-1
Introduction to Data Structure
Data Structure
 A Data Structure is an aggregation of atomic and
composite data into a set with defined relationships.
 Structure means a set of rules that holds the data together.
 Taking a combination of data and fit them into such a
structure that we can define its relating rules, we create a
data structure.
Data structure
 A data structure in computer science is a way of
storing data in a computer so that it can be used
efficiently.
– An organization of mathematical and logical
concepts of data
– Implementation using a programming language
– A proper data structure can make the algorithm or
solution more efficient in terms of time and space
Data Structures: Properties
 Most of the modern programming languages support
a number of data structures.
 In addition, modern programming languages allow
programmers to create new data structures for an
application.
 Data structures can be nested.
 A data structure may contain other data structures
(array of arrays, array of records, record of records,
record of arrays, etc.)
What is Data Structures?
 A data structure is defined by
 (1) the logical arrangement of data elements,
combined with
 (2) the set of operations we need to access the
elements.
What is Data Structures?
 Example:
 library is composed of elements (books)
 Accessing a particular book requires knowledge
of the arrangement of the books
 Users access books only through the librarian
Cont..
 An algorithm is a finite set of instructions that, if
followed, accomplishes a particular task.
 All the algorithms must satisfy the following criteria:
– Input
– Output
– Precision (Definiteness)
– Effectiveness
– Finiteness
TYPES OF DATA STRUCURE
 Primitive & Non Primitive Data Structures
 Primitive data Structure
 The integers, reals, logical data, character data,
pointer and reference are primitive data structures.
 Data structures that normally are directly operated
upon by machine-level instructions are known as
primitive data structures.
Non-primitive Data Structures
 These are more complex data structures. These data
structures are derived from the primitive data
structures.
 They stress on formation of sets of homogeneous and
heterogeneous data elements.
 The different operations that are to be carried out on
data are nothing but designing of data structures.
 CREATE
 DESTROY
 SELECT
 UPDATE
Data structures operations
The different operations that can be performed on data
structures are shown in Fig.
Performance Analysis
 There are problems and algorithms to solve them.
 Problems and problem instances.
 Example: Sorting data in ascending order.
 Problem: Sorting
 Problem Instance: e.g. sorting data (2 3 9 5 6 8)
 Algorithms: Bubble sort, Merge sort, Quick sort,
Selection sort, etc.
 Which is the best algorithm for the problem? How do
we judge?
Performance Analysis
 Two criteria are used to judge algorithms:
(i) time complexity (ii) space complexity.
 Space Complexity of an algorithm is the amount of
memory it needs to run to completion.
 Time Complexity of an algorithm is the amount of
CPU time it needs to run to completion.
Space Complexity: Example 1
1. Algorithm abc (a, b, c)
2. {
3. return a+b+b*c+(a+b-c)/(a+b)+4.0;
4. }
For every instance 3 computer words required to
store variables: a, b, and c.
Therefore Sp()= 3. S(P) = 3.
Time Complexity
 What is a program step?
 a+b+b*c+(a+b)/(a-b)  one step;
 comments  zero steps;
 while (<expr>) do  step count equal to the
number of times <expr> is executed.
 for i=<expr> to <expr1> do  step count equal to
number of times <expr1> is checked.
Performance Measurement
 Which is better?
 T(P1) = (n+1) or T(P2) = (n2 + 5).
 T(P1) = log (n2 + 1)/n! or T(P2) = nn(nlogn)/n2.
 Complex step count functions are difficult to compare.
 For comparing, ‘rate of growth’ of time and space
complexity functions is easy and sufficient.
Big O Notation
 Big O of a function gives us ‘rate of growth’ of the
step count function f(n), in terms of a simple function
g(n), which is easy to compare.
 Definition:
[Big O] The function f(n) = O(g(n)) (big ‘oh’ of g of
n) if
there exist positive constants c and n0 such that f(n) <=
c*g(n) for all n, n>=n0. See graph on next slide.
 Example: f(n) = 3n+2 is O(n) because 3n+2 <= 4n for
all n >= 2. c = 4, n0 = 2. Here g(n) = n.
Big O Notation[1]
= n0
Big O Notation
 Example: f(n) = 10n2+4n+2 is O(n2)
because 10n2+4n+2 <= 11n2 for all n >=5.
 Example: f(n) = 6*2n+n2 is O(2n)
because 6*2n+n2 <=7*2n for all n>=4.
 Algorithms can be:
 O(1)  constant; O(log n)  logrithmic; O(nlogn);
O(n) linear; O(n2)  quadratic; O(n3)  cubic; O(2n)
 exponential.
Big O Notation
 Now it is easy to compare time or space complexities
of algorithms.
 Which algorithm complexity is better?
 T(P1) = O(n) or T(P2) = O(n2)
 T(P1) = O(1) or T(P2) = O(log n)
 T(P1) = O(2n) or T(P2) = O(n10)
Linear & Non Linear Data Structures
 Linear data structures:- in which insertion and deletion
is possible in linear fashion .
 example:- arrays, linked lists.
 Non linear data structures:-in which it is not possible.
example:- trees ,stacks
LINEAR DATA STRUCTURE Array
 Array is linear, homogeneous data structures whose
elements are stored in contiguous memory locations.
Arrays
 Array: a set of pairs, <index, value>
 Data structure
 For each index, there is a value associated with
that index.
 Representation (possible)
 Implemented by using consecutive memory.
 In mathematical terms, we call this a
correspondence or a mapping.
Initializing Arrays
 Using a loop:
 for (int i = 0; i < myList.length; i++)
 myList[i] = i;
 Declaring, creating, initializing in one step:
 double[] myList = {1.9, 2.9, 3.4, 3.5};
 This shorthand syntax must be in one statement.
Declaring and Creating in One Step
 datatype[] arrayname = new
 datatype[arraySize];
 double[] myList = new double[10];
 datatype arrayname[] = new
datatype[arraySize];
 double myList[] = new double[10];
Sparse Matrix[2]
 A sparse matrix is a matrix that has many zero entries.






















0002800
0000091
000000
006000
0003110
150220015
• This is a __×__ matrix.
• There are _____ entries.
• There are _____ nonzero entries.
• There are _____ zero entries.
Consider we use a 2D array to represent a n×n sparse matrix. How many entries
are required? _____ entries. The space complexity is O( ).
Sparse Matrix
 If n is large, say n = 5000, we need 25 million elements to store
the matrix.
 25 million units of time for operation such as addition and
transposition.
 Using a representation that stores only the nonzero entries can
reduce the space and time requirements considerably.
Sparse Matrix Representation
 The information we need to know
 The number of rows
 The number of columns
 The number of nonzero entries
 All the nonzero entries are stored in an array. Therefore, we
also have to know
 The capacity of the array
 Each element contains a triple <row, col, value> to store.
 The triples are ordered by rows and within rows by
columns.
Sparse Matrix Representation
class SparseMatrix;
class MatrixEntry {
friend class SparseMatrix;
private:
int row, col, value;
};
class SparseMatrix {
private:
int rows, cols, terms, capacity;
MatrixEntry *smArray;
};
The array as an ADT
 When considering an ADT we are more concerned
with the operations that can be performed on an array.
 Aside from creating a new array, most languages
provide only two standard operations for arrays,
one that retrieves a value, and a second that stores
a value.
 The advantage of this ADT definition is that it
clearly points out the fact that the array is a more
general structure than “a consecutive set of
memory locations.”
Exercise : Bubble Sort
int[] myList = {2, 9, 5, 4, 8, 1, 6}; // Unsorted
Pass 1: 2, 5, 4, 8, 1, 6, 9
Pass 2: 2, 4, 5, 1, 6, 8, 9
Pass 3: 2, 4, 1, 5, 6, 8, 9
Pass 4: 2, 1, 4, 5, 6, 8, 9
Pass 5: 1, 2, 4, 5, 6, 8, 9
Pass 6: 1, 2, 4, 5, 6, 8, 9
Tower of Hanoi[3]
 The Objective is to transfer the entire tower to one of
the other pegs.
 However you can only move one disk at a time and
you can never stack a larger disk onto a smaller disk.
Try to solve it in fewest possible moves.
Tower of Hanoi[4]
References
1) An introduction to Datastructure with application by jean Trembley and
sorrenson
2) Data structures by schaums and series –seymour lipschutz
3) http://en.wikipedia.org/wiki/Book:Data_structures
4) http://www.amazon.com/Data-Structures-Algorithms
5) http://www.amazon.in/Data-Structures-Algorithms-Made-
Easy/dp/0615459811/
6) http://www.amazon.in/Data-Structures-SIE-Seymour-Lipschutz/dp
List of Images
1. Data structures by schaums and series –seymour lipschutz
2. http://en.wikipedia.org/wiki/Book:Data_structures
3. http://en.wikipedia.org/wiki/tower of hanoi
4. http://en.wikipedia.org/wiki/tower of hanoi

More Related Content

What's hot

Data Structures & Algorithm design using C
Data Structures & Algorithm design using C Data Structures & Algorithm design using C
Data Structures & Algorithm design using C
Emertxe Information Technologies Pvt Ltd
 
Array Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional arrayArray Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional array
imtiazalijoono
 
Object oriented programming c++
Object oriented programming c++Object oriented programming c++
Object oriented programming c++
Ankur Pandey
 
Unit 1 chapter 1 Design and Analysis of Algorithms
Unit 1   chapter 1 Design and Analysis of AlgorithmsUnit 1   chapter 1 Design and Analysis of Algorithms
Unit 1 chapter 1 Design and Analysis of Algorithms
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
Basic c programming and explanation PPT1
Basic c programming and explanation PPT1Basic c programming and explanation PPT1
Basic c programming and explanation PPT1
Rumman Ansari
 
Introduction to Array ppt
Introduction to Array pptIntroduction to Array ppt
Introduction to Array ppt
sandhya yadav
 
Problem solving methodology
Problem solving methodologyProblem solving methodology
Problem solving methodology
Prof. Dr. K. Adisesha
 
Two dimensional array
Two dimensional arrayTwo dimensional array
Two dimensional array
Rajendran
 
Data Structure in C Programming Language
Data Structure in C Programming LanguageData Structure in C Programming Language
Data Structure in C Programming Language
Arkadeep Dey
 
Data structures
Data structuresData structures
Data structures
Naresh Babu Merugu
 
UNIT I LINEAR DATA STRUCTURES – LIST
UNIT I 	LINEAR DATA STRUCTURES – LIST 	UNIT I 	LINEAR DATA STRUCTURES – LIST
UNIT I LINEAR DATA STRUCTURES – LIST
Kathirvel Ayyaswamy
 
Data structure - Graph
Data structure - GraphData structure - Graph
Data structure - Graph
Madhu Bala
 
Program for hamming code using c
Program for hamming code using cProgram for hamming code using c
Program for hamming code using csnsanth
 
C++ oop
C++ oopC++ oop
C++ oop
Sunil OS
 
Escape sequences
Escape sequencesEscape sequences
Escape sequences
Way2itech
 
Chapter 12 ds
Chapter 12 dsChapter 12 ds
Chapter 12 ds
Hanif Durad
 
Learn C
Learn CLearn C
Learn C
kantila
 
The Stack And Recursion
The Stack And RecursionThe Stack And Recursion
The Stack And Recursion
Ashim Lamichhane
 
UNIT II LINEAR DATA STRUCTURES – STACKS, QUEUES
UNIT II 	LINEAR DATA STRUCTURES – STACKS, QUEUES	UNIT II 	LINEAR DATA STRUCTURES – STACKS, QUEUES
UNIT II LINEAR DATA STRUCTURES – STACKS, QUEUES
Kathirvel Ayyaswamy
 

What's hot (20)

Data Structures & Algorithm design using C
Data Structures & Algorithm design using C Data Structures & Algorithm design using C
Data Structures & Algorithm design using C
 
Array Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional arrayArray Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional array
 
Object oriented programming c++
Object oriented programming c++Object oriented programming c++
Object oriented programming c++
 
Unit 1 chapter 1 Design and Analysis of Algorithms
Unit 1   chapter 1 Design and Analysis of AlgorithmsUnit 1   chapter 1 Design and Analysis of Algorithms
Unit 1 chapter 1 Design and Analysis of Algorithms
 
Basic c programming and explanation PPT1
Basic c programming and explanation PPT1Basic c programming and explanation PPT1
Basic c programming and explanation PPT1
 
Introduction to Array ppt
Introduction to Array pptIntroduction to Array ppt
Introduction to Array ppt
 
Problem solving methodology
Problem solving methodologyProblem solving methodology
Problem solving methodology
 
Two dimensional array
Two dimensional arrayTwo dimensional array
Two dimensional array
 
Data Structure in C Programming Language
Data Structure in C Programming LanguageData Structure in C Programming Language
Data Structure in C Programming Language
 
Data structures
Data structuresData structures
Data structures
 
UNIT I LINEAR DATA STRUCTURES – LIST
UNIT I 	LINEAR DATA STRUCTURES – LIST 	UNIT I 	LINEAR DATA STRUCTURES – LIST
UNIT I LINEAR DATA STRUCTURES – LIST
 
Data structure - Graph
Data structure - GraphData structure - Graph
Data structure - Graph
 
Program for hamming code using c
Program for hamming code using cProgram for hamming code using c
Program for hamming code using c
 
C++ oop
C++ oopC++ oop
C++ oop
 
Escape sequences
Escape sequencesEscape sequences
Escape sequences
 
Chapter 12 ds
Chapter 12 dsChapter 12 ds
Chapter 12 ds
 
Learn C
Learn CLearn C
Learn C
 
The Stack And Recursion
The Stack And RecursionThe Stack And Recursion
The Stack And Recursion
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
UNIT II LINEAR DATA STRUCTURES – STACKS, QUEUES
UNIT II 	LINEAR DATA STRUCTURES – STACKS, QUEUES	UNIT II 	LINEAR DATA STRUCTURES – STACKS, QUEUES
UNIT II LINEAR DATA STRUCTURES – STACKS, QUEUES
 

Similar to Bca ii dfs u-1 introduction to data structure

DATA STRUCTURES unit 1.pptx
DATA STRUCTURES unit 1.pptxDATA STRUCTURES unit 1.pptx
DATA STRUCTURES unit 1.pptx
ShivamKrPathak
 
Data Structures unit I Introduction - data types
Data Structures unit I Introduction - data typesData Structures unit I Introduction - data types
Data Structures unit I Introduction - data types
AmirthaVarshini80
 
Data structures in c#
Data structures in c#Data structures in c#
Data structures in c#
SivaSankar Gorantla
 
VCE Unit 01 (2).pptx
VCE Unit 01 (2).pptxVCE Unit 01 (2).pptx
VCE Unit 01 (2).pptx
skilljiolms
 
Introduction to Data structure and algorithm.pptx
Introduction to Data structure and algorithm.pptxIntroduction to Data structure and algorithm.pptx
Introduction to Data structure and algorithm.pptx
line24arts
 
Data structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pdData structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pd
Nimmi Weeraddana
 
DS Complete notes for Computer science and Engineering
DS Complete notes for Computer science and EngineeringDS Complete notes for Computer science and Engineering
DS Complete notes for Computer science and Engineering
RAJASEKHARV8
 
Chapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdfChapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdf
Axmedcarb
 
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada ReddyDatastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada ReddyMalikireddy Bramhananda Reddy
 
Data structures "1" (Lectures 2015-2016)
Data structures "1" (Lectures 2015-2016) Data structures "1" (Lectures 2015-2016)
Data structures "1" (Lectures 2015-2016)
Ameer B. Alaasam
 
Lec 1 Ds
Lec 1 DsLec 1 Ds
Lec 1 DsQundeel
 
Data Structure
Data StructureData Structure
Data Structuresheraz1
 
Lec 1 Ds
Lec 1 DsLec 1 Ds
Lec 1 DsQundeel
 
UNIT 1.pptx
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptx
JohnStuart83
 
Chapter 1 - Introduction to Data Structure.ppt
Chapter 1 - Introduction to Data Structure.pptChapter 1 - Introduction to Data Structure.ppt
Chapter 1 - Introduction to Data Structure.ppt
NORSHADILAAHMADBADEL
 
Data structure.pptx
Data structure.pptxData structure.pptx
Data structure.pptx
SajalFayyaz
 
Ds
DsDs
CE344L-200365-Lab2.pdf
CE344L-200365-Lab2.pdfCE344L-200365-Lab2.pdf
CE344L-200365-Lab2.pdf
UmarMustafa13
 
unit1Intro_final.pptx
unit1Intro_final.pptxunit1Intro_final.pptx
unit1Intro_final.pptx
DEEPAK948083
 
Data structures - Introduction
Data structures - IntroductionData structures - Introduction
Data structures - Introduction
DeepaThirumurugan
 

Similar to Bca ii dfs u-1 introduction to data structure (20)

DATA STRUCTURES unit 1.pptx
DATA STRUCTURES unit 1.pptxDATA STRUCTURES unit 1.pptx
DATA STRUCTURES unit 1.pptx
 
Data Structures unit I Introduction - data types
Data Structures unit I Introduction - data typesData Structures unit I Introduction - data types
Data Structures unit I Introduction - data types
 
Data structures in c#
Data structures in c#Data structures in c#
Data structures in c#
 
VCE Unit 01 (2).pptx
VCE Unit 01 (2).pptxVCE Unit 01 (2).pptx
VCE Unit 01 (2).pptx
 
Introduction to Data structure and algorithm.pptx
Introduction to Data structure and algorithm.pptxIntroduction to Data structure and algorithm.pptx
Introduction to Data structure and algorithm.pptx
 
Data structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pdData structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pd
 
DS Complete notes for Computer science and Engineering
DS Complete notes for Computer science and EngineeringDS Complete notes for Computer science and Engineering
DS Complete notes for Computer science and Engineering
 
Chapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdfChapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdf
 
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada ReddyDatastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
 
Data structures "1" (Lectures 2015-2016)
Data structures "1" (Lectures 2015-2016) Data structures "1" (Lectures 2015-2016)
Data structures "1" (Lectures 2015-2016)
 
Lec 1 Ds
Lec 1 DsLec 1 Ds
Lec 1 Ds
 
Data Structure
Data StructureData Structure
Data Structure
 
Lec 1 Ds
Lec 1 DsLec 1 Ds
Lec 1 Ds
 
UNIT 1.pptx
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptx
 
Chapter 1 - Introduction to Data Structure.ppt
Chapter 1 - Introduction to Data Structure.pptChapter 1 - Introduction to Data Structure.ppt
Chapter 1 - Introduction to Data Structure.ppt
 
Data structure.pptx
Data structure.pptxData structure.pptx
Data structure.pptx
 
Ds
DsDs
Ds
 
CE344L-200365-Lab2.pdf
CE344L-200365-Lab2.pdfCE344L-200365-Lab2.pdf
CE344L-200365-Lab2.pdf
 
unit1Intro_final.pptx
unit1Intro_final.pptxunit1Intro_final.pptx
unit1Intro_final.pptx
 
Data structures - Introduction
Data structures - IntroductionData structures - Introduction
Data structures - Introduction
 

More from Rai University

Brochure Rai University
Brochure Rai University Brochure Rai University
Brochure Rai University
Rai University
 
Mm unit 4point2
Mm unit 4point2Mm unit 4point2
Mm unit 4point2
Rai University
 
Mm unit 4point1
Mm unit 4point1Mm unit 4point1
Mm unit 4point1
Rai University
 
Mm unit 4point3
Mm unit 4point3Mm unit 4point3
Mm unit 4point3
Rai University
 
Mm unit 3point2
Mm unit 3point2Mm unit 3point2
Mm unit 3point2
Rai University
 
Mm unit 3point1
Mm unit 3point1Mm unit 3point1
Mm unit 3point1
Rai University
 
Mm unit 2point2
Mm unit 2point2Mm unit 2point2
Mm unit 2point2
Rai University
 
Mm unit 2 point 1
Mm unit 2 point 1Mm unit 2 point 1
Mm unit 2 point 1
Rai University
 
Mm unit 1point3
Mm unit 1point3Mm unit 1point3
Mm unit 1point3
Rai University
 
Mm unit 1point2
Mm unit 1point2Mm unit 1point2
Mm unit 1point2
Rai University
 
Mm unit 1point1
Mm unit 1point1Mm unit 1point1
Mm unit 1point1
Rai University
 
Bdft ii, tmt, unit-iii, dyeing & types of dyeing,
Bdft ii, tmt, unit-iii,  dyeing & types of dyeing,Bdft ii, tmt, unit-iii,  dyeing & types of dyeing,
Bdft ii, tmt, unit-iii, dyeing & types of dyeing,
Rai University
 
Bsc agri 2 pae u-4.4 publicrevenue-presentation-130208082149-phpapp02
Bsc agri  2 pae  u-4.4 publicrevenue-presentation-130208082149-phpapp02Bsc agri  2 pae  u-4.4 publicrevenue-presentation-130208082149-phpapp02
Bsc agri 2 pae u-4.4 publicrevenue-presentation-130208082149-phpapp02
Rai University
 
Bsc agri 2 pae u-4.3 public expenditure
Bsc agri  2 pae  u-4.3 public expenditureBsc agri  2 pae  u-4.3 public expenditure
Bsc agri 2 pae u-4.3 public expenditure
Rai University
 
Bsc agri 2 pae u-4.2 public finance
Bsc agri  2 pae  u-4.2 public financeBsc agri  2 pae  u-4.2 public finance
Bsc agri 2 pae u-4.2 public finance
Rai University
 
Bsc agri 2 pae u-4.1 introduction
Bsc agri  2 pae  u-4.1 introductionBsc agri  2 pae  u-4.1 introduction
Bsc agri 2 pae u-4.1 introduction
Rai University
 
Bsc agri 2 pae u-3.3 inflation
Bsc agri  2 pae  u-3.3  inflationBsc agri  2 pae  u-3.3  inflation
Bsc agri 2 pae u-3.3 inflation
Rai University
 
Bsc agri 2 pae u-3.2 introduction to macro economics
Bsc agri  2 pae  u-3.2 introduction to macro economicsBsc agri  2 pae  u-3.2 introduction to macro economics
Bsc agri 2 pae u-3.2 introduction to macro economics
Rai University
 
Bsc agri 2 pae u-3.1 marketstructure
Bsc agri  2 pae  u-3.1 marketstructureBsc agri  2 pae  u-3.1 marketstructure
Bsc agri 2 pae u-3.1 marketstructure
Rai University
 
Bsc agri 2 pae u-3 perfect-competition
Bsc agri  2 pae  u-3 perfect-competitionBsc agri  2 pae  u-3 perfect-competition
Bsc agri 2 pae u-3 perfect-competition
Rai University
 

More from Rai University (20)

Brochure Rai University
Brochure Rai University Brochure Rai University
Brochure Rai University
 
Mm unit 4point2
Mm unit 4point2Mm unit 4point2
Mm unit 4point2
 
Mm unit 4point1
Mm unit 4point1Mm unit 4point1
Mm unit 4point1
 
Mm unit 4point3
Mm unit 4point3Mm unit 4point3
Mm unit 4point3
 
Mm unit 3point2
Mm unit 3point2Mm unit 3point2
Mm unit 3point2
 
Mm unit 3point1
Mm unit 3point1Mm unit 3point1
Mm unit 3point1
 
Mm unit 2point2
Mm unit 2point2Mm unit 2point2
Mm unit 2point2
 
Mm unit 2 point 1
Mm unit 2 point 1Mm unit 2 point 1
Mm unit 2 point 1
 
Mm unit 1point3
Mm unit 1point3Mm unit 1point3
Mm unit 1point3
 
Mm unit 1point2
Mm unit 1point2Mm unit 1point2
Mm unit 1point2
 
Mm unit 1point1
Mm unit 1point1Mm unit 1point1
Mm unit 1point1
 
Bdft ii, tmt, unit-iii, dyeing & types of dyeing,
Bdft ii, tmt, unit-iii,  dyeing & types of dyeing,Bdft ii, tmt, unit-iii,  dyeing & types of dyeing,
Bdft ii, tmt, unit-iii, dyeing & types of dyeing,
 
Bsc agri 2 pae u-4.4 publicrevenue-presentation-130208082149-phpapp02
Bsc agri  2 pae  u-4.4 publicrevenue-presentation-130208082149-phpapp02Bsc agri  2 pae  u-4.4 publicrevenue-presentation-130208082149-phpapp02
Bsc agri 2 pae u-4.4 publicrevenue-presentation-130208082149-phpapp02
 
Bsc agri 2 pae u-4.3 public expenditure
Bsc agri  2 pae  u-4.3 public expenditureBsc agri  2 pae  u-4.3 public expenditure
Bsc agri 2 pae u-4.3 public expenditure
 
Bsc agri 2 pae u-4.2 public finance
Bsc agri  2 pae  u-4.2 public financeBsc agri  2 pae  u-4.2 public finance
Bsc agri 2 pae u-4.2 public finance
 
Bsc agri 2 pae u-4.1 introduction
Bsc agri  2 pae  u-4.1 introductionBsc agri  2 pae  u-4.1 introduction
Bsc agri 2 pae u-4.1 introduction
 
Bsc agri 2 pae u-3.3 inflation
Bsc agri  2 pae  u-3.3  inflationBsc agri  2 pae  u-3.3  inflation
Bsc agri 2 pae u-3.3 inflation
 
Bsc agri 2 pae u-3.2 introduction to macro economics
Bsc agri  2 pae  u-3.2 introduction to macro economicsBsc agri  2 pae  u-3.2 introduction to macro economics
Bsc agri 2 pae u-3.2 introduction to macro economics
 
Bsc agri 2 pae u-3.1 marketstructure
Bsc agri  2 pae  u-3.1 marketstructureBsc agri  2 pae  u-3.1 marketstructure
Bsc agri 2 pae u-3.1 marketstructure
 
Bsc agri 2 pae u-3 perfect-competition
Bsc agri  2 pae  u-3 perfect-competitionBsc agri  2 pae  u-3 perfect-competition
Bsc agri 2 pae u-3 perfect-competition
 

Recently uploaded

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
Steve Thomason
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
Celine George
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
Vivekanand Anglo Vedic Academy
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 

Recently uploaded (20)

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 

Bca ii dfs u-1 introduction to data structure

  • 1. Course: BCA-II Subject: Data Structure Unit-1 Introduction to Data Structure
  • 2. Data Structure  A Data Structure is an aggregation of atomic and composite data into a set with defined relationships.  Structure means a set of rules that holds the data together.  Taking a combination of data and fit them into such a structure that we can define its relating rules, we create a data structure.
  • 3. Data structure  A data structure in computer science is a way of storing data in a computer so that it can be used efficiently. – An organization of mathematical and logical concepts of data – Implementation using a programming language – A proper data structure can make the algorithm or solution more efficient in terms of time and space
  • 4. Data Structures: Properties  Most of the modern programming languages support a number of data structures.  In addition, modern programming languages allow programmers to create new data structures for an application.  Data structures can be nested.  A data structure may contain other data structures (array of arrays, array of records, record of records, record of arrays, etc.)
  • 5. What is Data Structures?  A data structure is defined by  (1) the logical arrangement of data elements, combined with  (2) the set of operations we need to access the elements.
  • 6. What is Data Structures?  Example:  library is composed of elements (books)  Accessing a particular book requires knowledge of the arrangement of the books  Users access books only through the librarian
  • 7. Cont..  An algorithm is a finite set of instructions that, if followed, accomplishes a particular task.  All the algorithms must satisfy the following criteria: – Input – Output – Precision (Definiteness) – Effectiveness – Finiteness
  • 8. TYPES OF DATA STRUCURE  Primitive & Non Primitive Data Structures  Primitive data Structure  The integers, reals, logical data, character data, pointer and reference are primitive data structures.  Data structures that normally are directly operated upon by machine-level instructions are known as primitive data structures.
  • 9. Non-primitive Data Structures  These are more complex data structures. These data structures are derived from the primitive data structures.  They stress on formation of sets of homogeneous and heterogeneous data elements.  The different operations that are to be carried out on data are nothing but designing of data structures.  CREATE  DESTROY  SELECT  UPDATE
  • 10. Data structures operations The different operations that can be performed on data structures are shown in Fig.
  • 11. Performance Analysis  There are problems and algorithms to solve them.  Problems and problem instances.  Example: Sorting data in ascending order.  Problem: Sorting  Problem Instance: e.g. sorting data (2 3 9 5 6 8)  Algorithms: Bubble sort, Merge sort, Quick sort, Selection sort, etc.  Which is the best algorithm for the problem? How do we judge?
  • 12. Performance Analysis  Two criteria are used to judge algorithms: (i) time complexity (ii) space complexity.  Space Complexity of an algorithm is the amount of memory it needs to run to completion.  Time Complexity of an algorithm is the amount of CPU time it needs to run to completion.
  • 13. Space Complexity: Example 1 1. Algorithm abc (a, b, c) 2. { 3. return a+b+b*c+(a+b-c)/(a+b)+4.0; 4. } For every instance 3 computer words required to store variables: a, b, and c. Therefore Sp()= 3. S(P) = 3.
  • 14. Time Complexity  What is a program step?  a+b+b*c+(a+b)/(a-b)  one step;  comments  zero steps;  while (<expr>) do  step count equal to the number of times <expr> is executed.  for i=<expr> to <expr1> do  step count equal to number of times <expr1> is checked.
  • 15. Performance Measurement  Which is better?  T(P1) = (n+1) or T(P2) = (n2 + 5).  T(P1) = log (n2 + 1)/n! or T(P2) = nn(nlogn)/n2.  Complex step count functions are difficult to compare.  For comparing, ‘rate of growth’ of time and space complexity functions is easy and sufficient.
  • 16. Big O Notation  Big O of a function gives us ‘rate of growth’ of the step count function f(n), in terms of a simple function g(n), which is easy to compare.  Definition: [Big O] The function f(n) = O(g(n)) (big ‘oh’ of g of n) if there exist positive constants c and n0 such that f(n) <= c*g(n) for all n, n>=n0. See graph on next slide.  Example: f(n) = 3n+2 is O(n) because 3n+2 <= 4n for all n >= 2. c = 4, n0 = 2. Here g(n) = n.
  • 18. Big O Notation  Example: f(n) = 10n2+4n+2 is O(n2) because 10n2+4n+2 <= 11n2 for all n >=5.  Example: f(n) = 6*2n+n2 is O(2n) because 6*2n+n2 <=7*2n for all n>=4.  Algorithms can be:  O(1)  constant; O(log n)  logrithmic; O(nlogn); O(n) linear; O(n2)  quadratic; O(n3)  cubic; O(2n)  exponential.
  • 19. Big O Notation  Now it is easy to compare time or space complexities of algorithms.  Which algorithm complexity is better?  T(P1) = O(n) or T(P2) = O(n2)  T(P1) = O(1) or T(P2) = O(log n)  T(P1) = O(2n) or T(P2) = O(n10)
  • 20. Linear & Non Linear Data Structures  Linear data structures:- in which insertion and deletion is possible in linear fashion .  example:- arrays, linked lists.  Non linear data structures:-in which it is not possible. example:- trees ,stacks
  • 21. LINEAR DATA STRUCTURE Array  Array is linear, homogeneous data structures whose elements are stored in contiguous memory locations.
  • 22. Arrays  Array: a set of pairs, <index, value>  Data structure  For each index, there is a value associated with that index.  Representation (possible)  Implemented by using consecutive memory.  In mathematical terms, we call this a correspondence or a mapping.
  • 23. Initializing Arrays  Using a loop:  for (int i = 0; i < myList.length; i++)  myList[i] = i;  Declaring, creating, initializing in one step:  double[] myList = {1.9, 2.9, 3.4, 3.5};  This shorthand syntax must be in one statement.
  • 24. Declaring and Creating in One Step  datatype[] arrayname = new  datatype[arraySize];  double[] myList = new double[10];  datatype arrayname[] = new datatype[arraySize];  double myList[] = new double[10];
  • 25. Sparse Matrix[2]  A sparse matrix is a matrix that has many zero entries.                       0002800 0000091 000000 006000 0003110 150220015 • This is a __×__ matrix. • There are _____ entries. • There are _____ nonzero entries. • There are _____ zero entries. Consider we use a 2D array to represent a n×n sparse matrix. How many entries are required? _____ entries. The space complexity is O( ).
  • 26. Sparse Matrix  If n is large, say n = 5000, we need 25 million elements to store the matrix.  25 million units of time for operation such as addition and transposition.  Using a representation that stores only the nonzero entries can reduce the space and time requirements considerably.
  • 27. Sparse Matrix Representation  The information we need to know  The number of rows  The number of columns  The number of nonzero entries  All the nonzero entries are stored in an array. Therefore, we also have to know  The capacity of the array  Each element contains a triple <row, col, value> to store.  The triples are ordered by rows and within rows by columns.
  • 28. Sparse Matrix Representation class SparseMatrix; class MatrixEntry { friend class SparseMatrix; private: int row, col, value; }; class SparseMatrix { private: int rows, cols, terms, capacity; MatrixEntry *smArray; };
  • 29. The array as an ADT  When considering an ADT we are more concerned with the operations that can be performed on an array.  Aside from creating a new array, most languages provide only two standard operations for arrays, one that retrieves a value, and a second that stores a value.  The advantage of this ADT definition is that it clearly points out the fact that the array is a more general structure than “a consecutive set of memory locations.”
  • 30. Exercise : Bubble Sort int[] myList = {2, 9, 5, 4, 8, 1, 6}; // Unsorted Pass 1: 2, 5, 4, 8, 1, 6, 9 Pass 2: 2, 4, 5, 1, 6, 8, 9 Pass 3: 2, 4, 1, 5, 6, 8, 9 Pass 4: 2, 1, 4, 5, 6, 8, 9 Pass 5: 1, 2, 4, 5, 6, 8, 9 Pass 6: 1, 2, 4, 5, 6, 8, 9
  • 31. Tower of Hanoi[3]  The Objective is to transfer the entire tower to one of the other pegs.  However you can only move one disk at a time and you can never stack a larger disk onto a smaller disk. Try to solve it in fewest possible moves.
  • 33. References 1) An introduction to Datastructure with application by jean Trembley and sorrenson 2) Data structures by schaums and series –seymour lipschutz 3) http://en.wikipedia.org/wiki/Book:Data_structures 4) http://www.amazon.com/Data-Structures-Algorithms 5) http://www.amazon.in/Data-Structures-Algorithms-Made- Easy/dp/0615459811/ 6) http://www.amazon.in/Data-Structures-SIE-Seymour-Lipschutz/dp List of Images 1. Data structures by schaums and series –seymour lipschutz 2. http://en.wikipedia.org/wiki/Book:Data_structures 3. http://en.wikipedia.org/wiki/tower of hanoi 4. http://en.wikipedia.org/wiki/tower of hanoi