SlideShare uma empresa Scribd logo
1 de 24
Baixar para ler offline
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;

Mais conteúdo relacionado

Mais procurados

Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm KristinaBorooah
 
linked lists in data structures
linked lists in data structureslinked lists in data structures
linked lists in data structuresDurgaDeviCbit
 
Transaction states and properties
Transaction states and propertiesTransaction states and properties
Transaction states and propertiesChetan Mahawar
 
Searching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data StructureSearching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data StructureBalwant Gorad
 
Queue data structure
Queue data structureQueue data structure
Queue data structureanooppjoseph
 
Data Structures Notes 2021
Data Structures Notes 2021Data Structures Notes 2021
Data Structures Notes 2021Sreedhar Chowdam
 
Graph in data structure
Graph in data structureGraph in data structure
Graph in data structureAbrish06
 
queue & its applications
queue & its applicationsqueue & its applications
queue & its applicationssomendra kumar
 
TYPES DATA STRUCTURES( LINEAR AND NON LINEAR)....
TYPES DATA STRUCTURES( LINEAR AND NON LINEAR)....TYPES DATA STRUCTURES( LINEAR AND NON LINEAR)....
TYPES DATA STRUCTURES( LINEAR AND NON LINEAR)....Shail Nakum
 
sparse matrix in data structure
sparse matrix in data structuresparse matrix in data structure
sparse matrix in data structureMAHALAKSHMI P
 
1.1 binary tree
1.1 binary tree1.1 binary tree
1.1 binary treeKrish_ver2
 
Data Structure and Algorithms.pptx
Data Structure and Algorithms.pptxData Structure and Algorithms.pptx
Data Structure and Algorithms.pptxSyed Zaid Irshad
 
Object Oriented Programming Lecture Notes
Object Oriented Programming Lecture NotesObject Oriented Programming Lecture Notes
Object Oriented Programming Lecture NotesFellowBuddy.com
 
Abstract data types (adt) intro to data structure part 2
Abstract data types (adt)   intro to data structure part 2Abstract data types (adt)   intro to data structure part 2
Abstract data types (adt) intro to data structure part 2Self-Employed
 
Data structure using c module 1
Data structure using c module 1Data structure using c module 1
Data structure using c module 1smruti sarangi
 

Mais procurados (20)

Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm
 
Array in c
Array in cArray in c
Array in c
 
linked lists in data structures
linked lists in data structureslinked lists in data structures
linked lists in data structures
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
 
Sets in python
Sets in pythonSets in python
Sets in python
 
Transaction states and properties
Transaction states and propertiesTransaction states and properties
Transaction states and properties
 
Searching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data StructureSearching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data Structure
 
Queue data structure
Queue data structureQueue data structure
Queue data structure
 
Data Structures Notes 2021
Data Structures Notes 2021Data Structures Notes 2021
Data Structures Notes 2021
 
Abstract Data Types
Abstract Data TypesAbstract Data Types
Abstract Data Types
 
Graph in data structure
Graph in data structureGraph in data structure
Graph in data structure
 
queue & its applications
queue & its applicationsqueue & its applications
queue & its applications
 
TYPES DATA STRUCTURES( LINEAR AND NON LINEAR)....
TYPES DATA STRUCTURES( LINEAR AND NON LINEAR)....TYPES DATA STRUCTURES( LINEAR AND NON LINEAR)....
TYPES DATA STRUCTURES( LINEAR AND NON LINEAR)....
 
sparse matrix in data structure
sparse matrix in data structuresparse matrix in data structure
sparse matrix in data structure
 
1.1 binary tree
1.1 binary tree1.1 binary tree
1.1 binary tree
 
Data Structure and Algorithms.pptx
Data Structure and Algorithms.pptxData Structure and Algorithms.pptx
Data Structure and Algorithms.pptx
 
Linear Search Presentation
Linear Search PresentationLinear Search Presentation
Linear Search Presentation
 
Object Oriented Programming Lecture Notes
Object Oriented Programming Lecture NotesObject Oriented Programming Lecture Notes
Object Oriented Programming Lecture Notes
 
Abstract data types (adt) intro to data structure part 2
Abstract data types (adt)   intro to data structure part 2Abstract data types (adt)   intro to data structure part 2
Abstract data types (adt) intro to data structure part 2
 
Data structure using c module 1
Data structure using c module 1Data structure using c module 1
Data structure using c module 1
 

Semelhante a Unit 1 introduction to data structure

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
 
Datastructures using c++
Datastructures using c++Datastructures using c++
Datastructures using c++Gopi Nath
 
Array and Pointers
Array and PointersArray and Pointers
Array and PointersProf Ansari
 
8074.pdf
8074.pdf8074.pdf
8074.pdfBAna36
 
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 yearpalhimanshi999
 
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 structureRai 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 structureRai 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 structureRai University
 
data structure unit -1_170434dd7400.pptx
data structure unit -1_170434dd7400.pptxdata structure unit -1_170434dd7400.pptx
data structure unit -1_170434dd7400.pptxcoc7987515756
 
unit1Intro_final.pptx
unit1Intro_final.pptxunit1Intro_final.pptx
unit1Intro_final.pptxDEEPAK948083
 
Data structure lecture 1
Data structure lecture 1Data structure lecture 1
Data structure lecture 1Kumar
 
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
 
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.pptNORSHADILAAHMADBADEL
 

Semelhante a 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
 
Datastructures using c++
Datastructures using c++Datastructures using c++
Datastructures using c++
 
Array and Pointers
Array and PointersArray and Pointers
Array and Pointers
 
cluod.pdf
cluod.pdfcluod.pdf
cluod.pdf
 
Cs341
Cs341Cs341
Cs341
 
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
 
1st lecture.ppt
1st lecture.ppt1st lecture.ppt
1st lecture.ppt
 
8074.pdf
8074.pdf8074.pdf
8074.pdf
 
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
 
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...
 
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
 
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
 
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
 
data structure unit -1_170434dd7400.pptx
data structure unit -1_170434dd7400.pptxdata structure unit -1_170434dd7400.pptx
data structure unit -1_170434dd7400.pptx
 
unit1Intro_final.pptx
unit1Intro_final.pptxunit1Intro_final.pptx
unit1Intro_final.pptx
 
Unit ii data structure-converted
Unit  ii data structure-convertedUnit  ii data structure-converted
Unit ii data structure-converted
 
DATASTRUCTURES UNIT-1
DATASTRUCTURES UNIT-1DATASTRUCTURES UNIT-1
DATASTRUCTURES UNIT-1
 
Data structure lecture 1
Data structure lecture 1Data structure lecture 1
Data structure lecture 1
 
Data structures "1" (Lectures 2015-2016)
Data structures "1" (Lectures 2015-2016) Data structures "1" (Lectures 2015-2016)
Data structures "1" (Lectures 2015-2016)
 
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
 

Mais de kalyanineve

Sorting and searching
Sorting and searchingSorting and searching
Sorting and searchingkalyanineve
 
Unit 5 graphs minimum spanning trees
Unit 5   graphs minimum spanning treesUnit 5   graphs minimum spanning trees
Unit 5 graphs minimum spanning treeskalyanineve
 
Unit 2 linked list and queues
Unit 2   linked list and queuesUnit 2   linked list and queues
Unit 2 linked list and queueskalyanineve
 
Linux command ppt
Linux command pptLinux command ppt
Linux command pptkalyanineve
 

Mais de kalyanineve (7)

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

Último

tourism-management-srs_compress-software-engineering.pdf
tourism-management-srs_compress-software-engineering.pdftourism-management-srs_compress-software-engineering.pdf
tourism-management-srs_compress-software-engineering.pdfchess188chess188
 
70 POWER PLANT IAE V2500 technical training
70 POWER PLANT IAE V2500 technical training70 POWER PLANT IAE V2500 technical training
70 POWER PLANT IAE V2500 technical trainingGladiatorsKasper
 
"Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ..."Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ...Erbil Polytechnic University
 
Prach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism CommunityPrach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism Communityprachaibot
 
Module-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdfModule-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdfManish Kumar
 
Katarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School CourseKatarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School Coursebim.edu.pl
 
TEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACHTEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACHSneha Padhiar
 
Triangulation survey (Basic Mine Surveying)_MI10412MI.pptx
Triangulation survey (Basic Mine Surveying)_MI10412MI.pptxTriangulation survey (Basic Mine Surveying)_MI10412MI.pptx
Triangulation survey (Basic Mine Surveying)_MI10412MI.pptxRomil Mishra
 
22CYT12 & Chemistry for Computer Systems_Unit-II-Corrosion & its Control Meth...
22CYT12 & Chemistry for Computer Systems_Unit-II-Corrosion & its Control Meth...22CYT12 & Chemistry for Computer Systems_Unit-II-Corrosion & its Control Meth...
22CYT12 & Chemistry for Computer Systems_Unit-II-Corrosion & its Control Meth...KrishnaveniKrishnara1
 
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENTFUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENTSneha Padhiar
 
SOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATIONSOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATIONSneha Padhiar
 
Guardians of E-Commerce: Harnessing NLP and Machine Learning Approaches for A...
Guardians of E-Commerce: Harnessing NLP and Machine Learning Approaches for A...Guardians of E-Commerce: Harnessing NLP and Machine Learning Approaches for A...
Guardians of E-Commerce: Harnessing NLP and Machine Learning Approaches for A...IJAEMSJORNAL
 
Python Programming for basic beginners.pptx
Python Programming for basic beginners.pptxPython Programming for basic beginners.pptx
Python Programming for basic beginners.pptxmohitesoham12
 
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.elesangwon
 
Uk-NO1 Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Exp...
Uk-NO1 Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Exp...Uk-NO1 Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Exp...
Uk-NO1 Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Exp...Amil baba
 
Module-1-Building Acoustics(Introduction)(Unit-1).pdf
Module-1-Building Acoustics(Introduction)(Unit-1).pdfModule-1-Building Acoustics(Introduction)(Unit-1).pdf
Module-1-Building Acoustics(Introduction)(Unit-1).pdfManish Kumar
 
March 2024 - Top 10 Read Articles in Artificial Intelligence and Applications...
March 2024 - Top 10 Read Articles in Artificial Intelligence and Applications...March 2024 - Top 10 Read Articles in Artificial Intelligence and Applications...
March 2024 - Top 10 Read Articles in Artificial Intelligence and Applications...gerogepatton
 
Turn leadership mistakes into a better future.pptx
Turn leadership mistakes into a better future.pptxTurn leadership mistakes into a better future.pptx
Turn leadership mistakes into a better future.pptxStephen Sitton
 

Último (20)

tourism-management-srs_compress-software-engineering.pdf
tourism-management-srs_compress-software-engineering.pdftourism-management-srs_compress-software-engineering.pdf
tourism-management-srs_compress-software-engineering.pdf
 
70 POWER PLANT IAE V2500 technical training
70 POWER PLANT IAE V2500 technical training70 POWER PLANT IAE V2500 technical training
70 POWER PLANT IAE V2500 technical training
 
"Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ..."Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ...
 
Prach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism CommunityPrach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism Community
 
ASME-B31.4-2019-estandar para diseño de ductos
ASME-B31.4-2019-estandar para diseño de ductosASME-B31.4-2019-estandar para diseño de ductos
ASME-B31.4-2019-estandar para diseño de ductos
 
Module-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdfModule-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdf
 
Katarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School CourseKatarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School Course
 
Versatile Engineering Construction Firms
Versatile Engineering Construction FirmsVersatile Engineering Construction Firms
Versatile Engineering Construction Firms
 
TEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACHTEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACH
 
Triangulation survey (Basic Mine Surveying)_MI10412MI.pptx
Triangulation survey (Basic Mine Surveying)_MI10412MI.pptxTriangulation survey (Basic Mine Surveying)_MI10412MI.pptx
Triangulation survey (Basic Mine Surveying)_MI10412MI.pptx
 
22CYT12 & Chemistry for Computer Systems_Unit-II-Corrosion & its Control Meth...
22CYT12 & Chemistry for Computer Systems_Unit-II-Corrosion & its Control Meth...22CYT12 & Chemistry for Computer Systems_Unit-II-Corrosion & its Control Meth...
22CYT12 & Chemistry for Computer Systems_Unit-II-Corrosion & its Control Meth...
 
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENTFUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
 
SOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATIONSOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATION
 
Guardians of E-Commerce: Harnessing NLP and Machine Learning Approaches for A...
Guardians of E-Commerce: Harnessing NLP and Machine Learning Approaches for A...Guardians of E-Commerce: Harnessing NLP and Machine Learning Approaches for A...
Guardians of E-Commerce: Harnessing NLP and Machine Learning Approaches for A...
 
Python Programming for basic beginners.pptx
Python Programming for basic beginners.pptxPython Programming for basic beginners.pptx
Python Programming for basic beginners.pptx
 
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
 
Uk-NO1 Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Exp...
Uk-NO1 Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Exp...Uk-NO1 Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Exp...
Uk-NO1 Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Exp...
 
Module-1-Building Acoustics(Introduction)(Unit-1).pdf
Module-1-Building Acoustics(Introduction)(Unit-1).pdfModule-1-Building Acoustics(Introduction)(Unit-1).pdf
Module-1-Building Acoustics(Introduction)(Unit-1).pdf
 
March 2024 - Top 10 Read Articles in Artificial Intelligence and Applications...
March 2024 - Top 10 Read Articles in Artificial Intelligence and Applications...March 2024 - Top 10 Read Articles in Artificial Intelligence and Applications...
March 2024 - Top 10 Read Articles in Artificial Intelligence and Applications...
 
Turn leadership mistakes into a better future.pptx
Turn leadership mistakes into a better future.pptxTurn leadership mistakes into a better future.pptx
Turn leadership mistakes into a better future.pptx
 

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;