SlideShare a Scribd company logo
1 of 16
Elementary representation of data can be in forms of raw data, data item, data
structures.
(i) Raw Data:-
Raw data are raw facts. These are simply values or set of values.
(ii) Data item:-
Data item represents single unit of values of certain type.
Data Type:-
A Data Type refers to a named group of data which share similar
properties or characteristics and which have common behavior among them. For
instance: name can contain only alphabets, its data type is alphabetic & age only
have digits, its data type is numeric.
Data Structure:-
A Data Structure is a named grouped of data of different data types which
can be processed as a single unit.
The data structure can contain any of these data types:-
Primitive:-
These are those data types, which are not composed of other data types.
C++ names primitive data types as standard or fundamental data types. Ex:
Integer, Real, Character (i.e., int, float, double, and char).
Non-Primitive:-
These are those data types which are composed of primitive data types.
Sometimes these are called user-define data types because these are defined by
users. Ex: array, structure, class, enumeration, union etc.
Pointers:-
A special data type pointer data types has been introduced by some
programming languages. These are of great used in some popular and efficient
data structures like linked lists, stacks, queues and trees etc.
Data structures are very important in a computer system, as these not only
allow the user to combine various data types in a group but also allow processing
of the group as a single unit thereby making things much simpler and easier. The
data structures can be classified into following two types:
1. Simple data Structure:-
The data structures are normally built from primitive data types like integers,
reals, characters, boolean. Ex: array, structure.
2. Compound Data Structures:-
Simple data structures canbe combined in various ways to form more complex
structures called compound data structures. It is classified into two types:
(i) Linear data structures- A data structure is said to be linearif its elements
form a sequence. Ex. Stack, queue, linked list.
(ii) Non-Linear data structures- theseare multilevel data structures. Example of
non-linear data structure is Tree.
Following figure shows all the data structures.
Arrays refer to a named list of a finite number n of similar data elements.
Each of the data elements can be referenced respectively by a set of consecutive
numbers, usually 0, 1, 2, 3,…n. If the name of an array of 10 elements is ARY, then
its elements will be referenced as shown below:
ARY[0], ARY[1], ARY[2], ARY[3], …….. ARY[9]
Arrays can be one dimensional, two dimensional or multi dimensional.
Structure refers to a named collection of variables of different data types. A
structure gathers together different atoms of information that form a given entity.
The elements of a structure are referenced using the dot operator.
Stack data structures refer tro the lists stored and accessed in a special way,
where LIFO (last in first out) technique is followed.
(a) Stack
of plates
(b) Queue of people waiting
for their turn
Queues data structures are FIFO lists where insertions take place at the
“rear” and of the queues and deletion take place at the “front” and of the queues.
Linked lists are special lists of some data elements linked to one another.
The logical ordering is represented by having each elements pointing to the next
element.
start
start
INFO
INFO
INFO
INFO
INFO
INFO
In singly linked lists, nodes have one pointer (next) pointing to the next
node, whereas nodes of doubly linked lists have two pointers (prev and next). Prev
points to the previous node and next points to the node in the lists.
Tress are multilevel data structures having a hierarchical relationship
among its elements called nodes. Topmost node is called the root of the tree and
bottom most nodes are called leaves of the tree.
A
B
E
K
F
L M N
C
A
B
D
C
H I
K
F
L
J
E
G
D
G H
J
I
(a) General tree (b) Binary tree
The basic operations that are performed on data structure are as follows:-
1. Insertion: It means addition of a new data element in a data structure.
2. Deletion: It means removal of a data element from a data structure. The data
element is searched for before its removal.
3. Searching: It involves searching for the specific data element in a data structure.
4. Traversal: Traversal of a data structure means processing all the data elements of
it.
5. Sorting: Arranging data elements of a data structure in a specified order is called
sorting.
6. Merging: Combining elements of two similar data structures to form a new data
structure of same type, is called merging.
When elements of linear structures are represented in memory by means of
sequential memory location, these linear structures are called arrays. For instance,
If an array has elements numbered as -7,-6,-5,…0,1,2,…,15, then its UB is 15 and LB is -7
and array length is = 15 – (-7) + 1
= 15 + 7 + 1 = 23
(UB= Upper Bound, LB= Lower Bound)
There are different types of arrays:
(i) One-Dimensional Array
(ii) Two-Dimensional Array
The simplest form of array is one-dimensional array. The array itself is given
a name and its elements are referred to by their subscript. The notation of an array
can be given as follows:
Array name [lower bound L, upper bound U]
Which indicates the array name’s subscript value ranges from L through U.
In C++, an array is denoted as follows:
Array name [size]
Where size specifies the no. of elements in the array and the subscript value ranges
from 0 through size – 1.
Ex.: #include<iostream.h>
void main()
{ int A[10],i;
for(i=0;i<10;i++)
{ cout<<“Enter a number: “;
cin>>A[i];
}
cout<<“n Array Contentsn”;
for(i=0;i<10;i++)
{ cout<<A[i]<<“ “;
}
}
Linear Search: In linear search, each element of array is compared with the given
Item to be searched for, one by one. This method, which traverses the array
sequentially to locate the given Item, is called linear search or sequential search.
Binary Search: This popular search technique searches the given ITEM in minimum
possible comparisons. The binary search requires the array, to be scanned, must be
sorted in any order. For instance, say ascending order.
Insertion of new element in array can be done in two ways:
(i) If the array is unordered, the new element is inserted at the end of the array,
(ii) If the array is sorted then new element is added at appropriate position without
altering the order and to achieve this, rest of the elements are shifted.
The element to be deleted is first searched for in the array using one of the
search techniques i.e., either linear search or binary search.
Traversal in one-dimensional arrays involves processing of all elements one
by one. For instance, traversal of array would process in the following order:
X[0], X[1], X[2], X[3], ……., X[10],
Sorting of an array means arranging the array elements in a specified order
i.e., either ascending or descending order. These are several sorting techniques
available e.g., shell sort, shuttle sort, bubble sort, selection sort, quick sort, heap sort
etc.
(a) Selection Sort:
One family of internal sorting algorithms is the group of selection sorts. The
basic idea of a selection sort is to repeatedly select the smallest key in the remaining
unsorted array.
(b) Bubble Sort:
The basic idea of bubble sort is to compare two adjoining values and
exchange them if they are not in proper order. For instance, following unsorted array
is to be sorted in ascending order using bubble sort.
Merging means combining elements of two arrays to form a new array.
Simplest way of merging two arrays is that first copy all the elements of one array
into new array and then copy all the elements of other array into new array.

More Related Content

Similar to C++ Data Structure PPT.pptx

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 EngineeringRAJASEKHARV8
 
DATA STRUCTURE AND ALGORITJM POWERPOINT.ppt
DATA STRUCTURE AND ALGORITJM POWERPOINT.pptDATA STRUCTURE AND ALGORITJM POWERPOINT.ppt
DATA STRUCTURE AND ALGORITJM POWERPOINT.pptyarotos643
 
data structure programing language in c.ppt
data structure programing language in c.pptdata structure programing language in c.ppt
data structure programing language in c.pptLavkushGupta12
 
Data structure &amp; algorithms introduction
Data structure &amp; algorithms introductionData structure &amp; algorithms introduction
Data structure &amp; algorithms introductionSugandh Wafai
 
Introduction to Data Structure
Introduction to Data StructureIntroduction to Data Structure
Introduction to Data StructureJazz Jinia Bhowmik
 
data structure details of types and .ppt
data structure details of types and .pptdata structure details of types and .ppt
data structure details of types and .pptpoonamsngr
 
Data Structure using c language for beginners
Data Structure using c language for beginners Data Structure using c language for beginners
Data Structure using c language for beginners Vinayak SofTech
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptxSaralaT3
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptxsarala9
 
Data Structures and algoithms Unit - 1.pptx
Data Structures and algoithms Unit - 1.pptxData Structures and algoithms Unit - 1.pptx
Data Structures and algoithms Unit - 1.pptxmexiuro901
 

Similar to C++ Data Structure PPT.pptx (20)

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
 
DS_PPT.ppt
DS_PPT.pptDS_PPT.ppt
DS_PPT.ppt
 
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
 
DATA STRUCTURE AND ALGORITJM POWERPOINT.ppt
DATA STRUCTURE AND ALGORITJM POWERPOINT.pptDATA STRUCTURE AND ALGORITJM POWERPOINT.ppt
DATA STRUCTURE AND ALGORITJM POWERPOINT.ppt
 
Dsa unit 1
Dsa unit 1Dsa unit 1
Dsa unit 1
 
DSA - Copy.pptx
DSA - Copy.pptxDSA - Copy.pptx
DSA - Copy.pptx
 
data structure programing language in c.ppt
data structure programing language in c.pptdata structure programing language in c.ppt
data structure programing language in c.ppt
 
UNITIII LDS.pdf
UNITIII LDS.pdfUNITIII LDS.pdf
UNITIII LDS.pdf
 
DSA Unit II array.pptx
DSA Unit II array.pptxDSA Unit II array.pptx
DSA Unit II array.pptx
 
Data structure &amp; algorithms introduction
Data structure &amp; algorithms introductionData structure &amp; algorithms introduction
Data structure &amp; algorithms introduction
 
1597380885789.ppt
1597380885789.ppt1597380885789.ppt
1597380885789.ppt
 
Introduction to Data Structure
Introduction to Data StructureIntroduction to Data Structure
Introduction to Data Structure
 
LectureNotes-03-DSA
LectureNotes-03-DSALectureNotes-03-DSA
LectureNotes-03-DSA
 
data structure details of types and .ppt
data structure details of types and .pptdata structure details of types and .ppt
data structure details of types and .ppt
 
Data Structure using c language for beginners
Data Structure using c language for beginners Data Structure using c language for beginners
Data Structure using c language for beginners
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptx
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptx
 
cluod.pdf
cluod.pdfcluod.pdf
cluod.pdf
 
Data Structures and algoithms Unit - 1.pptx
Data Structures and algoithms Unit - 1.pptxData Structures and algoithms Unit - 1.pptx
Data Structures and algoithms Unit - 1.pptx
 
intr_ds.ppt
intr_ds.pptintr_ds.ppt
intr_ds.ppt
 

More from Mukesh Thakur

Constitutional Articles_2.pptx
Constitutional Articles_2.pptxConstitutional Articles_2.pptx
Constitutional Articles_2.pptxMukesh Thakur
 
world_bank 01-11-2018.ppt
world_bank 01-11-2018.pptworld_bank 01-11-2018.ppt
world_bank 01-11-2018.pptMukesh Thakur
 
Sunil GOOD GOVERNANCE.pptx
Sunil GOOD GOVERNANCE.pptxSunil GOOD GOVERNANCE.pptx
Sunil GOOD GOVERNANCE.pptxMukesh Thakur
 
Why reading is important .pptx
Why reading is important .pptxWhy reading is important .pptx
Why reading is important .pptxMukesh Thakur
 
Presentation PFRDA.pptx
Presentation PFRDA.pptxPresentation PFRDA.pptx
Presentation PFRDA.pptxMukesh Thakur
 
PPT on Time Management.pptx
PPT on Time Management.pptxPPT on Time Management.pptx
PPT on Time Management.pptxMukesh Thakur
 
What is motivation.ppt
What is motivation.pptWhat is motivation.ppt
What is motivation.pptMukesh Thakur
 
FISCAL POLICY.of india.pptx
FISCAL POLICY.of india.pptxFISCAL POLICY.of india.pptx
FISCAL POLICY.of india.pptxMukesh Thakur
 
PUNEET GULERIA Q.NO. 14 FINAL ACCOUNTS.docx
PUNEET GULERIA Q.NO. 14 FINAL ACCOUNTS.docxPUNEET GULERIA Q.NO. 14 FINAL ACCOUNTS.docx
PUNEET GULERIA Q.NO. 14 FINAL ACCOUNTS.docxMukesh Thakur
 
microfince prem.pptx
microfince prem.pptxmicrofince prem.pptx
microfince prem.pptxMukesh Thakur
 
FINANCE COMMISSION.pptx
FINANCE  COMMISSION.pptxFINANCE  COMMISSION.pptx
FINANCE COMMISSION.pptxMukesh Thakur
 
Essay on Discipline.pptx
Essay on Discipline.pptxEssay on Discipline.pptx
Essay on Discipline.pptxMukesh Thakur
 
Don’t delay it for tomorrow.pptx
Don’t delay it for tomorrow.pptxDon’t delay it for tomorrow.pptx
Don’t delay it for tomorrow.pptxMukesh Thakur
 

More from Mukesh Thakur (20)

Constitutional Articles_2.pptx
Constitutional Articles_2.pptxConstitutional Articles_2.pptx
Constitutional Articles_2.pptx
 
NITI AAYOG.pptx
NITI AAYOG.pptxNITI AAYOG.pptx
NITI AAYOG.pptx
 
world_bank 01-11-2018.ppt
world_bank 01-11-2018.pptworld_bank 01-11-2018.ppt
world_bank 01-11-2018.ppt
 
Sunil GOOD GOVERNANCE.pptx
Sunil GOOD GOVERNANCE.pptxSunil GOOD GOVERNANCE.pptx
Sunil GOOD GOVERNANCE.pptx
 
SEBI.pptx
SEBI.pptxSEBI.pptx
SEBI.pptx
 
Why reading is important .pptx
Why reading is important .pptxWhy reading is important .pptx
Why reading is important .pptx
 
THINKING.pptx
THINKING.pptxTHINKING.pptx
THINKING.pptx
 
Presentation PFRDA.pptx
Presentation PFRDA.pptxPresentation PFRDA.pptx
Presentation PFRDA.pptx
 
PPT on Time Management.pptx
PPT on Time Management.pptxPPT on Time Management.pptx
PPT on Time Management.pptx
 
What is motivation.ppt
What is motivation.pptWhat is motivation.ppt
What is motivation.ppt
 
FISCAL POLICY.of india.pptx
FISCAL POLICY.of india.pptxFISCAL POLICY.of india.pptx
FISCAL POLICY.of india.pptx
 
PUNEET GULERIA Q.NO. 14 FINAL ACCOUNTS.docx
PUNEET GULERIA Q.NO. 14 FINAL ACCOUNTS.docxPUNEET GULERIA Q.NO. 14 FINAL ACCOUNTS.docx
PUNEET GULERIA Q.NO. 14 FINAL ACCOUNTS.docx
 
microfince prem.pptx
microfince prem.pptxmicrofince prem.pptx
microfince prem.pptx
 
SPEED READING.pptx
SPEED READING.pptxSPEED READING.pptx
SPEED READING.pptx
 
monetry policy.pptx
monetry policy.pptxmonetry policy.pptx
monetry policy.pptx
 
FEAR.pptx
FEAR.pptxFEAR.pptx
FEAR.pptx
 
Cryptocurrency.pptx
Cryptocurrency.pptxCryptocurrency.pptx
Cryptocurrency.pptx
 
FINANCE COMMISSION.pptx
FINANCE  COMMISSION.pptxFINANCE  COMMISSION.pptx
FINANCE COMMISSION.pptx
 
Essay on Discipline.pptx
Essay on Discipline.pptxEssay on Discipline.pptx
Essay on Discipline.pptx
 
Don’t delay it for tomorrow.pptx
Don’t delay it for tomorrow.pptxDon’t delay it for tomorrow.pptx
Don’t delay it for tomorrow.pptx
 

Recently uploaded

POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxAnaBeatriceAblay2
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 

Recently uploaded (20)

POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 

C++ Data Structure PPT.pptx

  • 1.
  • 2. Elementary representation of data can be in forms of raw data, data item, data structures. (i) Raw Data:- Raw data are raw facts. These are simply values or set of values. (ii) Data item:- Data item represents single unit of values of certain type. Data Type:- A Data Type refers to a named group of data which share similar properties or characteristics and which have common behavior among them. For instance: name can contain only alphabets, its data type is alphabetic & age only have digits, its data type is numeric. Data Structure:- A Data Structure is a named grouped of data of different data types which can be processed as a single unit.
  • 3. The data structure can contain any of these data types:- Primitive:- These are those data types, which are not composed of other data types. C++ names primitive data types as standard or fundamental data types. Ex: Integer, Real, Character (i.e., int, float, double, and char). Non-Primitive:- These are those data types which are composed of primitive data types. Sometimes these are called user-define data types because these are defined by users. Ex: array, structure, class, enumeration, union etc. Pointers:- A special data type pointer data types has been introduced by some programming languages. These are of great used in some popular and efficient data structures like linked lists, stacks, queues and trees etc.
  • 4. Data structures are very important in a computer system, as these not only allow the user to combine various data types in a group but also allow processing of the group as a single unit thereby making things much simpler and easier. The data structures can be classified into following two types: 1. Simple data Structure:- The data structures are normally built from primitive data types like integers, reals, characters, boolean. Ex: array, structure. 2. Compound Data Structures:- Simple data structures canbe combined in various ways to form more complex structures called compound data structures. It is classified into two types: (i) Linear data structures- A data structure is said to be linearif its elements form a sequence. Ex. Stack, queue, linked list. (ii) Non-Linear data structures- theseare multilevel data structures. Example of non-linear data structure is Tree.
  • 5. Following figure shows all the data structures.
  • 6. Arrays refer to a named list of a finite number n of similar data elements. Each of the data elements can be referenced respectively by a set of consecutive numbers, usually 0, 1, 2, 3,…n. If the name of an array of 10 elements is ARY, then its elements will be referenced as shown below: ARY[0], ARY[1], ARY[2], ARY[3], …….. ARY[9] Arrays can be one dimensional, two dimensional or multi dimensional. Structure refers to a named collection of variables of different data types. A structure gathers together different atoms of information that form a given entity. The elements of a structure are referenced using the dot operator. Stack data structures refer tro the lists stored and accessed in a special way, where LIFO (last in first out) technique is followed.
  • 7. (a) Stack of plates (b) Queue of people waiting for their turn
  • 8. Queues data structures are FIFO lists where insertions take place at the “rear” and of the queues and deletion take place at the “front” and of the queues. Linked lists are special lists of some data elements linked to one another. The logical ordering is represented by having each elements pointing to the next element. start start INFO INFO INFO INFO INFO INFO
  • 9. In singly linked lists, nodes have one pointer (next) pointing to the next node, whereas nodes of doubly linked lists have two pointers (prev and next). Prev points to the previous node and next points to the node in the lists. Tress are multilevel data structures having a hierarchical relationship among its elements called nodes. Topmost node is called the root of the tree and bottom most nodes are called leaves of the tree.
  • 10. A B E K F L M N C A B D C H I K F L J E G D G H J I (a) General tree (b) Binary tree
  • 11. The basic operations that are performed on data structure are as follows:- 1. Insertion: It means addition of a new data element in a data structure. 2. Deletion: It means removal of a data element from a data structure. The data element is searched for before its removal. 3. Searching: It involves searching for the specific data element in a data structure. 4. Traversal: Traversal of a data structure means processing all the data elements of it. 5. Sorting: Arranging data elements of a data structure in a specified order is called sorting. 6. Merging: Combining elements of two similar data structures to form a new data structure of same type, is called merging.
  • 12. When elements of linear structures are represented in memory by means of sequential memory location, these linear structures are called arrays. For instance, If an array has elements numbered as -7,-6,-5,…0,1,2,…,15, then its UB is 15 and LB is -7 and array length is = 15 – (-7) + 1 = 15 + 7 + 1 = 23 (UB= Upper Bound, LB= Lower Bound) There are different types of arrays: (i) One-Dimensional Array (ii) Two-Dimensional Array
  • 13. The simplest form of array is one-dimensional array. The array itself is given a name and its elements are referred to by their subscript. The notation of an array can be given as follows: Array name [lower bound L, upper bound U] Which indicates the array name’s subscript value ranges from L through U. In C++, an array is denoted as follows: Array name [size] Where size specifies the no. of elements in the array and the subscript value ranges from 0 through size – 1. Ex.: #include<iostream.h> void main() { int A[10],i; for(i=0;i<10;i++) { cout<<“Enter a number: “; cin>>A[i]; } cout<<“n Array Contentsn”; for(i=0;i<10;i++) { cout<<A[i]<<“ “; } }
  • 14. Linear Search: In linear search, each element of array is compared with the given Item to be searched for, one by one. This method, which traverses the array sequentially to locate the given Item, is called linear search or sequential search. Binary Search: This popular search technique searches the given ITEM in minimum possible comparisons. The binary search requires the array, to be scanned, must be sorted in any order. For instance, say ascending order. Insertion of new element in array can be done in two ways: (i) If the array is unordered, the new element is inserted at the end of the array, (ii) If the array is sorted then new element is added at appropriate position without altering the order and to achieve this, rest of the elements are shifted.
  • 15. The element to be deleted is first searched for in the array using one of the search techniques i.e., either linear search or binary search. Traversal in one-dimensional arrays involves processing of all elements one by one. For instance, traversal of array would process in the following order: X[0], X[1], X[2], X[3], ……., X[10], Sorting of an array means arranging the array elements in a specified order i.e., either ascending or descending order. These are several sorting techniques available e.g., shell sort, shuttle sort, bubble sort, selection sort, quick sort, heap sort etc.
  • 16. (a) Selection Sort: One family of internal sorting algorithms is the group of selection sorts. The basic idea of a selection sort is to repeatedly select the smallest key in the remaining unsorted array. (b) Bubble Sort: The basic idea of bubble sort is to compare two adjoining values and exchange them if they are not in proper order. For instance, following unsorted array is to be sorted in ascending order using bubble sort. Merging means combining elements of two arrays to form a new array. Simplest way of merging two arrays is that first copy all the elements of one array into new array and then copy all the elements of other array into new array.