SlideShare a Scribd company logo
Introduction to
Data Structures
Kalyani Neve
Asst.Prof.
GHRIBM,Jalgaon
 Data Concepts
 Data types, ADT (Abstract Data Type)
 Types of data structure
 Algorithm Analysis: Space complexity, Time complexity
 Asymptotic Notations (Big O, Omega, Theta), Linear
data structure
 Array as linear data structure
 Representation of array in memory, Strings, structure
and pointer in C/C++
Data Structure:
The logical or mathematical model of a particular organization
of data is called a data structure.
Data structure mainly specifies the following four things:
1. Organization of data
2. Accessing Methods
3. Degree of associativity
4. Processing alternatives for information
Types of Data Structure :
Data structure are normally divided into two categories
1. Primitive Data structure
2. Non-Primitive Data structure
Chart of Data structure is given on next slide.
Data Structure
Primitive DS Non-Primitive DS
int float pointer char Array Lists Files
Linear list
Non Linear
list
Stack Queues Graphs Trees
Data Structure Operations :
1. Traversing
2. Searching
3. Inserting
4. Deleting
5. Sorting
6. Merging
Algorithm Analysis:Algorithm Analysis:
Space complexitySpace complexity
Space complexity of a program is the amount of memory that it needs to run to
completion
Includes, Instruction space
Space for simple variables
Space for constants; etc.
Include, Dynamically created variables
Recursion stack space
Time complexityTime complexity
Time complexity of a program is the amount of computer time that it needs to
run to completion
 Dependent on
• Machine speed
• Compiler code generation
• Number of inputs
• Number of executed statements
 Count the number of operations the program perform
 Require to divide the program into distinct steps
Asymptotic Notation:Asymptotic Notation:
To choose the best algorithm, we need to check efficiency of
each
algorithm. The efficiency can be measured by computing time
complexity of each algorithm. Asymptotic notation is a shorthand
way to represent the time complexity.
There are three kinds of mathematical notation which are very
useful for this kind of analysis.
1. Big oh (O) Notation
2. Omega (Ω) Notation
3. Theta (Ө) Notation
Linear data structure :
Array as linear data structure
An array can be defined as an infinite collection of homogeneous
(similar type) elements.
Arrays are always stored in consecutive memory locations.
Datatype var_name [Expression];
E.g.. int num[10];
Algorithms for Insert, Delete and Display of elements in arrays
are given below :
INSERT(A, N, K, ITEM)
Here A is a array with N elements and k is a positive integer
such that k<=N. This algo. Inserts an elements ITEM into the
kth position in A.
1. [Initialize counter]
Set J := N
2. Repeat step 3 and 4 while J>=k
3. [Move Jth element downward]
Set A[j+1] := A[J]
2. [Decrease counter]
Set J := J-1
[End of step2 loop]
5. [Insert element]
Set A[k] := ITEM
6. [Reset N]
Set N := N+1
6. Exit
DELETE(A, N, k, ITEM)
Here A is a linear array with N elements and k is a positive
integer such that k<=N. This algorithm deleted the kth element
from A.
1. Set ITEM := A[k]
2. Repeat for J=k to N-1
[Move J + 1st
element upward]
Set A[J] := A[J+1]
[End of loop.]
3. [Reset the number N of elements in A]
Set N := N-1
4. Exit
DISPLAY(A, k, LB, UB)
Here A is a linear array with lower bound LB and upper
bound UB. This algorithm traverses A applying an operation
PROCESS to each element of A.
1. [Initialize counter]
Set k := LB
2. Repeat steps 3 and 4 while k<=UB
3. [Visit element]
Apply PROCESS to A[k]
4. [Increase counter]
Set k := k +1
[End of step2 loop]
5. Exit
Representation of array in memory:
Suppose name of linear array is arr and it has 5 elements. Then its
elements are represented as:
arr
0 1 2 3 4
arr[0] arr[1] arr[2] arr[3] arr[4].
Since array elements are stored in contiguous memory locations,
the computer needs to not to know the address of every element
but the address of only first element. The address of first element
is called base address of array.
Review of Strings
Definition of Strings
 Generally speaking, a string is a sequence of characters
 Examples: “hello”, “high school”, “H2O”.
 Typical desirable operations on strings are:
 Concatenation: “high”+“school”=“highschool”
 Comparisons: “high”<“school” // alphabetical
 Finding/retrieving/modifying/deleting/inserting substrings in a
given string
Declaration of strings
 The following instructions are all equivalent. They declare x
to be an object of type string, and assign the string “high
school” to it:
 string x(“high school”);
 string x= “high school”;
 string x; x=“high school”;
Operations on strings (Concatenation)
 Let x and y be two strings
 To concatenate x and y, write: x+y
string x= “high”;
string y= “school”;
string z;
z=x+y;
cout<<“z=“<<z<<endl;
z =z+“ was fun”;
cout<<“z=“<<z<<endl;
Output:
z=highschool
z= highschool was fun
Comparison Operators for string Objects
 We can compare two strings x and y using the following
operators: ==, !=, <, <=, >, >=
 The comparison is alphabetical
 The outcome of each comparison is: true or false
Correspondence between the C library and
the C++ string Class
C Library Functions C++ string operators/methods
strcpy = (the assignment operator)
strcat += (assign+concat operator)
strcmp = =, !=, <, >, <=, >=
strchr, strstr
strrchr
.find( ) method
.rfind( ) method
strlen .size( ) or .length( ) methods
Structures :
A structure is a collection of simple variables. The variables in a
structure can be different types: Some can be int, float and so on.
The data items in a structure are called the members of the
structure.
A structure is a collection of data, while class is a collection of
both data and functions.
Declaring the structure :
The structure declaration tells how the structure is organized. It
specifies what members the structure will have.
struct part
{
int no;
float cost;
};
The Structure declaration serves only as a blueprint for the
creation of variables of type part.
Consider, following statement,
part part1;
Defines a variable, called part1, of type structure part.
This definition reserves space in memory for part1. This
memory holds all the members of part1.
Once a structure variables has been defined, its members can be
asses using something called the dot operator.
part1. no = 2222;
Pointers :
A pointer is an entity that refers to the memory addresses. It
specifies the number that gives a location in a memory. Each
pointer variable can point to specific data type such as int, char,
float etc.
Pointers are used for…….
1. Accessing array elements.
2. Passing arguments to function by address when modification
of formal arguments are to be reflected on actual arguments.
3. Passing arrays and string to functions.
4. Creating data structure like Link List,Trees,Graphs etc.
5. Allocate a memory dynamically.
Pointer Defination
Syntax :
Datatype * ptrvar,………….
e.g
int * ptr;
char *msg=“Hello”;
Int marks;
Ptr=&marks;
Dereferencing of Pointers
Int * ptr;
Int I;
i=10;
Ptr=&I;
Cout<<*ptr<<endl;
Ad

More Related Content

What's hot (20)

Data Structure and Algorithms Binary Tree
Data Structure and Algorithms Binary TreeData Structure and Algorithms Binary Tree
Data Structure and Algorithms Binary Tree
ManishPrajapati78
 
Array ppt
Array pptArray ppt
Array ppt
Kaushal Mehta
 
Programming in c Arrays
Programming in c ArraysProgramming in c Arrays
Programming in c Arrays
janani thirupathi
 
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
 
sparse matrix in data structure
sparse matrix in data structuresparse matrix in data structure
sparse matrix in data structure
MAHALAKSHMI P
 
Unit 6. Arrays
Unit 6. ArraysUnit 6. Arrays
Unit 6. Arrays
Ashim Lamichhane
 
Character Array and String
Character Array and StringCharacter Array and String
Character Array and String
Tasnima Hamid
 
The Relational Database Model
The Relational Database ModelThe Relational Database Model
The Relational Database Model
Shishir Aryal
 
Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member Functions
MOHIT AGARWAL
 
Queue data structure
Queue data structureQueue data structure
Queue data structure
anooppjoseph
 
Abstract Data Types
Abstract Data TypesAbstract Data Types
Abstract Data Types
karthikeyanC40
 
Relational model
Relational modelRelational model
Relational model
Dabbal Singh Mahara
 
Graph traversals in Data Structures
Graph traversals in Data StructuresGraph traversals in Data Structures
Graph traversals in Data Structures
Anandhasilambarasan D
 
Arrays
ArraysArrays
Arrays
SARITHA REDDY
 
2- Dimensional Arrays
2- Dimensional Arrays2- Dimensional Arrays
2- Dimensional Arrays
Education Front
 
heap Sort Algorithm
heap  Sort Algorithmheap  Sort Algorithm
heap Sort Algorithm
Lemia Algmri
 
Aggregate functions
Aggregate functionsAggregate functions
Aggregate functions
sinhacp
 
Linked list
Linked listLinked list
Linked list
akshat360
 
Hashing
HashingHashing
Hashing
Amar Jukuntla
 
Data structures using c
Data structures using cData structures using c
Data structures using c
Prof. Dr. K. Adisesha
 
Data Structure and Algorithms Binary Tree
Data Structure and Algorithms Binary TreeData Structure and Algorithms Binary Tree
Data Structure and Algorithms Binary Tree
ManishPrajapati78
 
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
 
sparse matrix in data structure
sparse matrix in data structuresparse matrix in data structure
sparse matrix in data structure
MAHALAKSHMI P
 
Character Array and String
Character Array and StringCharacter Array and String
Character Array and String
Tasnima Hamid
 
The Relational Database Model
The Relational Database ModelThe Relational Database Model
The Relational Database Model
Shishir Aryal
 
Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member Functions
MOHIT AGARWAL
 
Queue data structure
Queue data structureQueue data structure
Queue data structure
anooppjoseph
 
heap Sort Algorithm
heap  Sort Algorithmheap  Sort Algorithm
heap Sort Algorithm
Lemia Algmri
 
Aggregate functions
Aggregate functionsAggregate functions
Aggregate functions
sinhacp
 

Similar to Unit 1 introduction to data structure (20)

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
Malikireddy Bramhananda Reddy
 
Datastructures using c++
Datastructures using c++Datastructures using c++
Datastructures using c++
Gopi Nath
 
Array and Pointers
Array and PointersArray and Pointers
Array and Pointers
Prof Ansari
 
cluod.pdf
cluod.pdfcluod.pdf
cluod.pdf
ssuser92d367
 
Cs341
Cs341Cs341
Cs341
Serghei Urban
 
M v bramhananda reddy dsa complete notes
M v bramhananda reddy dsa complete notesM v bramhananda reddy dsa complete notes
M v bramhananda reddy dsa complete notes
Malikireddy Bramhananda Reddy
 
Data structure using c module 1
Data structure using c module 1Data structure using c module 1
Data structure using c module 1
smruti sarangi
 
1st lecture.ppt
1st lecture.ppt1st lecture.ppt
1st lecture.ppt
ShujatAli47
 
8074.pdf
8074.pdf8074.pdf
8074.pdf
BAna36
 
Address, Pointers, Arrays, and Structures.pptx
Address, Pointers, Arrays, and Structures.pptxAddress, Pointers, Arrays, and Structures.pptx
Address, Pointers, Arrays, and Structures.pptx
Dr. Amna Mohamed
 
1st lecture of DSA computer science 2024.ppt
1st lecture of DSA computer science 2024.ppt1st lecture of DSA computer science 2024.ppt
1st lecture of DSA computer science 2024.ppt
aamirali1061a
 
data structure and algorithm Array.pptx btech 2nd year
data structure and algorithm  Array.pptx btech 2nd yeardata structure and algorithm  Array.pptx btech 2nd year
data structure and algorithm Array.pptx btech 2nd year
palhimanshi999
 
Basic of array and data structure, data structure basics, array, address calc...
Basic of array and data structure, data structure basics, array, address calc...Basic of array and data structure, data structure basics, array, address calc...
Basic of array and data structure, data structure basics, array, address calc...
nsitlokeshjain
 
Bsc cs ii dfs u-1 introduction to data structure
Bsc cs ii dfs u-1 introduction to data structureBsc cs ii dfs u-1 introduction to data structure
Bsc cs ii dfs u-1 introduction to data structure
Rai University
 
Bca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structureBca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structure
Rai University
 
Mca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structureMca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structure
Rai University
 
Data Structures Mastery: Sample Paper for Practice"
Data Structures Mastery: Sample Paper for Practice"Data Structures Mastery: Sample Paper for Practice"
Data Structures Mastery: Sample Paper for Practice"
SaniyaGijoni
 
data structure unit -1_170434dd7400.pptx
data structure unit -1_170434dd7400.pptxdata structure unit -1_170434dd7400.pptx
data structure unit -1_170434dd7400.pptx
coc7987515756
 
unit1Intro_final.pptx
unit1Intro_final.pptxunit1Intro_final.pptx
unit1Intro_final.pptx
DEEPAK948083
 
Unit ii data structure-converted
Unit  ii data structure-convertedUnit  ii data structure-converted
Unit ii data structure-converted
Shri Shankaracharya College, Bhilai,Junwani
 
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
Malikireddy Bramhananda Reddy
 
Datastructures using c++
Datastructures using c++Datastructures using c++
Datastructures using c++
Gopi Nath
 
Array and Pointers
Array and PointersArray and Pointers
Array and Pointers
Prof Ansari
 
Data structure using c module 1
Data structure using c module 1Data structure using c module 1
Data structure using c module 1
smruti sarangi
 
8074.pdf
8074.pdf8074.pdf
8074.pdf
BAna36
 
Address, Pointers, Arrays, and Structures.pptx
Address, Pointers, Arrays, and Structures.pptxAddress, Pointers, Arrays, and Structures.pptx
Address, Pointers, Arrays, and Structures.pptx
Dr. Amna Mohamed
 
1st lecture of DSA computer science 2024.ppt
1st lecture of DSA computer science 2024.ppt1st lecture of DSA computer science 2024.ppt
1st lecture of DSA computer science 2024.ppt
aamirali1061a
 
data structure and algorithm Array.pptx btech 2nd year
data structure and algorithm  Array.pptx btech 2nd yeardata structure and algorithm  Array.pptx btech 2nd year
data structure and algorithm Array.pptx btech 2nd year
palhimanshi999
 
Basic of array and data structure, data structure basics, array, address calc...
Basic of array and data structure, data structure basics, array, address calc...Basic of array and data structure, data structure basics, array, address calc...
Basic of array and data structure, data structure basics, array, address calc...
nsitlokeshjain
 
Bsc cs ii dfs u-1 introduction to data structure
Bsc cs ii dfs u-1 introduction to data structureBsc cs ii dfs u-1 introduction to data structure
Bsc cs ii dfs u-1 introduction to data structure
Rai University
 
Bca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structureBca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structure
Rai University
 
Mca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structureMca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structure
Rai University
 
Data Structures Mastery: Sample Paper for Practice"
Data Structures Mastery: Sample Paper for Practice"Data Structures Mastery: Sample Paper for Practice"
Data Structures Mastery: Sample Paper for Practice"
SaniyaGijoni
 
data structure unit -1_170434dd7400.pptx
data structure unit -1_170434dd7400.pptxdata structure unit -1_170434dd7400.pptx
data structure unit -1_170434dd7400.pptx
coc7987515756
 
unit1Intro_final.pptx
unit1Intro_final.pptxunit1Intro_final.pptx
unit1Intro_final.pptx
DEEPAK948083
 
Ad

More from kalyanineve (7)

Sorting and searching
Sorting and searchingSorting and searching
Sorting and searching
kalyanineve
 
Unit 7 sorting
Unit 7   sortingUnit 7   sorting
Unit 7 sorting
kalyanineve
 
Unit 5 graphs minimum spanning trees
Unit 5   graphs minimum spanning treesUnit 5   graphs minimum spanning trees
Unit 5 graphs minimum spanning trees
kalyanineve
 
Unit 4 tree
Unit 4   treeUnit 4   tree
Unit 4 tree
kalyanineve
 
Unit 3 stack
Unit 3   stackUnit 3   stack
Unit 3 stack
kalyanineve
 
Unit 2 linked list and queues
Unit 2   linked list and queuesUnit 2   linked list and queues
Unit 2 linked list and queues
kalyanineve
 
Linux command ppt
Linux command pptLinux command ppt
Linux command ppt
kalyanineve
 
Sorting and searching
Sorting and searchingSorting and searching
Sorting and searching
kalyanineve
 
Unit 5 graphs minimum spanning trees
Unit 5   graphs minimum spanning treesUnit 5   graphs minimum spanning trees
Unit 5 graphs minimum spanning trees
kalyanineve
 
Unit 2 linked list and queues
Unit 2   linked list and queuesUnit 2   linked list and queues
Unit 2 linked list and queues
kalyanineve
 
Linux command ppt
Linux command pptLinux command ppt
Linux command ppt
kalyanineve
 
Ad

Recently uploaded (20)

hypermedia_system_revisit_roy_fielding .
hypermedia_system_revisit_roy_fielding .hypermedia_system_revisit_roy_fielding .
hypermedia_system_revisit_roy_fielding .
NABLAS株式会社
 
22PCOAM16_MACHINE_LEARNING_UNIT_IV_NOTES_with_QB
22PCOAM16_MACHINE_LEARNING_UNIT_IV_NOTES_with_QB22PCOAM16_MACHINE_LEARNING_UNIT_IV_NOTES_with_QB
22PCOAM16_MACHINE_LEARNING_UNIT_IV_NOTES_with_QB
Guru Nanak Technical Institutions
 
Construction-Chemicals-For-Waterproofing.ppt
Construction-Chemicals-For-Waterproofing.pptConstruction-Chemicals-For-Waterproofing.ppt
Construction-Chemicals-For-Waterproofing.ppt
ssuser2ffcbc
 
Environment .................................
Environment .................................Environment .................................
Environment .................................
shadyozq9
 
22PCOAM16 ML Unit 3 Full notes PDF & QB.pdf
22PCOAM16 ML Unit 3 Full notes PDF & QB.pdf22PCOAM16 ML Unit 3 Full notes PDF & QB.pdf
22PCOAM16 ML Unit 3 Full notes PDF & QB.pdf
Guru Nanak Technical Institutions
 
acid base ppt and their specific application in food
acid base ppt and their specific application in foodacid base ppt and their specific application in food
acid base ppt and their specific application in food
Fatehatun Noor
 
ATAL 6 Days Online FDP Scheme Document 2025-26.pdf
ATAL 6 Days Online FDP Scheme Document 2025-26.pdfATAL 6 Days Online FDP Scheme Document 2025-26.pdf
ATAL 6 Days Online FDP Scheme Document 2025-26.pdf
ssuserda39791
 
OPTIMIZING DATA INTEROPERABILITY IN AGILE ORGANIZATIONS: INTEGRATING NONAKA’S...
OPTIMIZING DATA INTEROPERABILITY IN AGILE ORGANIZATIONS: INTEGRATING NONAKA’S...OPTIMIZING DATA INTEROPERABILITY IN AGILE ORGANIZATIONS: INTEGRATING NONAKA’S...
OPTIMIZING DATA INTEROPERABILITY IN AGILE ORGANIZATIONS: INTEGRATING NONAKA’S...
ijdmsjournal
 
Design Optimization of Reinforced Concrete Waffle Slab Using Genetic Algorithm
Design Optimization of Reinforced Concrete Waffle Slab Using Genetic AlgorithmDesign Optimization of Reinforced Concrete Waffle Slab Using Genetic Algorithm
Design Optimization of Reinforced Concrete Waffle Slab Using Genetic Algorithm
Journal of Soft Computing in Civil Engineering
 
Jacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia - Excels In Optimizing Software ApplicationsJacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia
 
Physical and Physic-Chemical Based Optimization Methods: A Review
Physical and Physic-Chemical Based Optimization Methods: A ReviewPhysical and Physic-Chemical Based Optimization Methods: A Review
Physical and Physic-Chemical Based Optimization Methods: A Review
Journal of Soft Computing in Civil Engineering
 
Water Industry Process Automation & Control Monthly May 2025
Water Industry Process Automation & Control Monthly May 2025Water Industry Process Automation & Control Monthly May 2025
Water Industry Process Automation & Control Monthly May 2025
Water Industry Process Automation & Control
 
Artificial intelligence and machine learning.pptx
Artificial intelligence and machine learning.pptxArtificial intelligence and machine learning.pptx
Artificial intelligence and machine learning.pptx
rakshanatarajan005
 
ML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdf
ML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdfML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdf
ML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdf
rameshwarchintamani
 
Working with USDOT UTCs: From Conception to Implementation
Working with USDOT UTCs: From Conception to ImplementationWorking with USDOT UTCs: From Conception to Implementation
Working with USDOT UTCs: From Conception to Implementation
Alabama Transportation Assistance Program
 
twin tower attack 2001 new york city
twin  tower  attack  2001 new  york citytwin  tower  attack  2001 new  york city
twin tower attack 2001 new york city
harishreemavs
 
introduction technology technology tec.pptx
introduction technology technology tec.pptxintroduction technology technology tec.pptx
introduction technology technology tec.pptx
Iftikhar70
 
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdfML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
rameshwarchintamani
 
Personal Protective Efsgfgsffquipment.ppt
Personal Protective Efsgfgsffquipment.pptPersonal Protective Efsgfgsffquipment.ppt
Personal Protective Efsgfgsffquipment.ppt
ganjangbegu579
 
Transport modelling at SBB, presentation at EPFL in 2025
Transport modelling at SBB, presentation at EPFL in 2025Transport modelling at SBB, presentation at EPFL in 2025
Transport modelling at SBB, presentation at EPFL in 2025
Antonin Danalet
 
hypermedia_system_revisit_roy_fielding .
hypermedia_system_revisit_roy_fielding .hypermedia_system_revisit_roy_fielding .
hypermedia_system_revisit_roy_fielding .
NABLAS株式会社
 
Construction-Chemicals-For-Waterproofing.ppt
Construction-Chemicals-For-Waterproofing.pptConstruction-Chemicals-For-Waterproofing.ppt
Construction-Chemicals-For-Waterproofing.ppt
ssuser2ffcbc
 
Environment .................................
Environment .................................Environment .................................
Environment .................................
shadyozq9
 
acid base ppt and their specific application in food
acid base ppt and their specific application in foodacid base ppt and their specific application in food
acid base ppt and their specific application in food
Fatehatun Noor
 
ATAL 6 Days Online FDP Scheme Document 2025-26.pdf
ATAL 6 Days Online FDP Scheme Document 2025-26.pdfATAL 6 Days Online FDP Scheme Document 2025-26.pdf
ATAL 6 Days Online FDP Scheme Document 2025-26.pdf
ssuserda39791
 
OPTIMIZING DATA INTEROPERABILITY IN AGILE ORGANIZATIONS: INTEGRATING NONAKA’S...
OPTIMIZING DATA INTEROPERABILITY IN AGILE ORGANIZATIONS: INTEGRATING NONAKA’S...OPTIMIZING DATA INTEROPERABILITY IN AGILE ORGANIZATIONS: INTEGRATING NONAKA’S...
OPTIMIZING DATA INTEROPERABILITY IN AGILE ORGANIZATIONS: INTEGRATING NONAKA’S...
ijdmsjournal
 
Jacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia - Excels In Optimizing Software ApplicationsJacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia
 
Artificial intelligence and machine learning.pptx
Artificial intelligence and machine learning.pptxArtificial intelligence and machine learning.pptx
Artificial intelligence and machine learning.pptx
rakshanatarajan005
 
ML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdf
ML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdfML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdf
ML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdf
rameshwarchintamani
 
twin tower attack 2001 new york city
twin  tower  attack  2001 new  york citytwin  tower  attack  2001 new  york city
twin tower attack 2001 new york city
harishreemavs
 
introduction technology technology tec.pptx
introduction technology technology tec.pptxintroduction technology technology tec.pptx
introduction technology technology tec.pptx
Iftikhar70
 
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdfML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
rameshwarchintamani
 
Personal Protective Efsgfgsffquipment.ppt
Personal Protective Efsgfgsffquipment.pptPersonal Protective Efsgfgsffquipment.ppt
Personal Protective Efsgfgsffquipment.ppt
ganjangbegu579
 
Transport modelling at SBB, presentation at EPFL in 2025
Transport modelling at SBB, presentation at EPFL in 2025Transport modelling at SBB, presentation at EPFL in 2025
Transport modelling at SBB, presentation at EPFL in 2025
Antonin Danalet
 

Unit 1 introduction to data structure

  • 1. Introduction to Data Structures Kalyani Neve Asst.Prof. GHRIBM,Jalgaon
  • 2.  Data Concepts  Data types, ADT (Abstract Data Type)  Types of data structure  Algorithm Analysis: Space complexity, Time complexity  Asymptotic Notations (Big O, Omega, Theta), Linear data structure  Array as linear data structure  Representation of array in memory, Strings, structure and pointer in C/C++
  • 3. Data Structure: The logical or mathematical model of a particular organization of data is called a data structure. Data structure mainly specifies the following four things: 1. Organization of data 2. Accessing Methods 3. Degree of associativity 4. Processing alternatives for information
  • 4. Types of Data Structure : Data structure are normally divided into two categories 1. Primitive Data structure 2. Non-Primitive Data structure Chart of Data structure is given on next slide.
  • 5. Data Structure Primitive DS Non-Primitive DS int float pointer char Array Lists Files Linear list Non Linear list Stack Queues Graphs Trees
  • 6. Data Structure Operations : 1. Traversing 2. Searching 3. Inserting 4. Deleting 5. Sorting 6. Merging
  • 7. Algorithm Analysis:Algorithm Analysis: Space complexitySpace complexity Space complexity of a program is the amount of memory that it needs to run to completion Includes, Instruction space Space for simple variables Space for constants; etc. Include, Dynamically created variables Recursion stack space
  • 8. Time complexityTime complexity Time complexity of a program is the amount of computer time that it needs to run to completion  Dependent on • Machine speed • Compiler code generation • Number of inputs • Number of executed statements  Count the number of operations the program perform  Require to divide the program into distinct steps
  • 9. Asymptotic Notation:Asymptotic Notation: To choose the best algorithm, we need to check efficiency of each algorithm. The efficiency can be measured by computing time complexity of each algorithm. Asymptotic notation is a shorthand way to represent the time complexity. There are three kinds of mathematical notation which are very useful for this kind of analysis. 1. Big oh (O) Notation 2. Omega (Ω) Notation 3. Theta (Ө) Notation
  • 10. Linear data structure : Array as linear data structure An array can be defined as an infinite collection of homogeneous (similar type) elements. Arrays are always stored in consecutive memory locations. Datatype var_name [Expression]; E.g.. int num[10]; Algorithms for Insert, Delete and Display of elements in arrays are given below :
  • 11. INSERT(A, N, K, ITEM) Here A is a array with N elements and k is a positive integer such that k<=N. This algo. Inserts an elements ITEM into the kth position in A. 1. [Initialize counter] Set J := N 2. Repeat step 3 and 4 while J>=k 3. [Move Jth element downward] Set A[j+1] := A[J] 2. [Decrease counter] Set J := J-1 [End of step2 loop] 5. [Insert element] Set A[k] := ITEM 6. [Reset N] Set N := N+1 6. Exit
  • 12. DELETE(A, N, k, ITEM) Here A is a linear array with N elements and k is a positive integer such that k<=N. This algorithm deleted the kth element from A. 1. Set ITEM := A[k] 2. Repeat for J=k to N-1 [Move J + 1st element upward] Set A[J] := A[J+1] [End of loop.] 3. [Reset the number N of elements in A] Set N := N-1 4. Exit
  • 13. DISPLAY(A, k, LB, UB) Here A is a linear array with lower bound LB and upper bound UB. This algorithm traverses A applying an operation PROCESS to each element of A. 1. [Initialize counter] Set k := LB 2. Repeat steps 3 and 4 while k<=UB 3. [Visit element] Apply PROCESS to A[k] 4. [Increase counter] Set k := k +1 [End of step2 loop] 5. Exit
  • 14. Representation of array in memory: Suppose name of linear array is arr and it has 5 elements. Then its elements are represented as: arr 0 1 2 3 4 arr[0] arr[1] arr[2] arr[3] arr[4]. Since array elements are stored in contiguous memory locations, the computer needs to not to know the address of every element but the address of only first element. The address of first element is called base address of array.
  • 15. Review of Strings Definition of Strings  Generally speaking, a string is a sequence of characters  Examples: “hello”, “high school”, “H2O”.  Typical desirable operations on strings are:  Concatenation: “high”+“school”=“highschool”  Comparisons: “high”<“school” // alphabetical  Finding/retrieving/modifying/deleting/inserting substrings in a given string
  • 16. Declaration of strings  The following instructions are all equivalent. They declare x to be an object of type string, and assign the string “high school” to it:  string x(“high school”);  string x= “high school”;  string x; x=“high school”;
  • 17. Operations on strings (Concatenation)  Let x and y be two strings  To concatenate x and y, write: x+y string x= “high”; string y= “school”; string z; z=x+y; cout<<“z=“<<z<<endl; z =z+“ was fun”; cout<<“z=“<<z<<endl; Output: z=highschool z= highschool was fun
  • 18. Comparison Operators for string Objects  We can compare two strings x and y using the following operators: ==, !=, <, <=, >, >=  The comparison is alphabetical  The outcome of each comparison is: true or false
  • 19. Correspondence between the C library and the C++ string Class C Library Functions C++ string operators/methods strcpy = (the assignment operator) strcat += (assign+concat operator) strcmp = =, !=, <, >, <=, >= strchr, strstr strrchr .find( ) method .rfind( ) method strlen .size( ) or .length( ) methods
  • 20. Structures : A structure is a collection of simple variables. The variables in a structure can be different types: Some can be int, float and so on. The data items in a structure are called the members of the structure. A structure is a collection of data, while class is a collection of both data and functions.
  • 21. Declaring the structure : The structure declaration tells how the structure is organized. It specifies what members the structure will have. struct part { int no; float cost; }; The Structure declaration serves only as a blueprint for the creation of variables of type part.
  • 22. Consider, following statement, part part1; Defines a variable, called part1, of type structure part. This definition reserves space in memory for part1. This memory holds all the members of part1. Once a structure variables has been defined, its members can be asses using something called the dot operator. part1. no = 2222;
  • 23. Pointers : A pointer is an entity that refers to the memory addresses. It specifies the number that gives a location in a memory. Each pointer variable can point to specific data type such as int, char, float etc. Pointers are used for……. 1. Accessing array elements. 2. Passing arguments to function by address when modification of formal arguments are to be reflected on actual arguments. 3. Passing arrays and string to functions. 4. Creating data structure like Link List,Trees,Graphs etc. 5. Allocate a memory dynamically.
  • 24. Pointer Defination Syntax : Datatype * ptrvar,…………. e.g int * ptr; char *msg=“Hello”; Int marks; Ptr=&marks; Dereferencing of Pointers Int * ptr; Int I; i=10; Ptr=&I; Cout<<*ptr<<endl;
  翻译: