SlideShare a Scribd company logo
1 of 8
DATA STRUCTURES
The logical and mathematical model of a particular organization of data is called
data structure.
PRIMITIVE
Array:
Array is an ordered collection of items. It contains same data type.
Array is a static object i.e. no of item is fixed and is assigned by the
declaration of the array
Stack:
Stack is a ordered collection of items
It is a list of dynamic objects/ elements in which an element may be inserted
or deleted only at one end called top of the stack.
DS
PRIMITIVE NON PRIMITIVE
LINEAR NON
LINEAR
ARRAYS
STRUCTURE
LIST
STACKS
QUEUES
TREE
GRAPH
Elements are removed from a stack in the reverse order of that in which they are
inserted in the stack.
“Push”- to insert into the stack
“pop”- to delete an element from a stack.
Stacks are used to indicate the order of processing of data when certain steps of
the processing must be postponed until other conditions are fulfilled.
Follows LIFO
Elements are removed from a stack (pop) in the reverse order of that in which
they were inserted into the stack (push).
It may contain different data types
Integer to indicate the current stack top within the array.
Operations: push, pop.
Queue:
An ordered collection of items from which items may be deleted at one end
(front end) & items inserted at the other end (rear end).
It follows FIFO.
Priority Queue: priority queue is a data structure in which the intrinsic ordering
of the elements (numeric or alphabetic)
Linked list:
A linked list is a linear collection of data elements, called nodes, where the
linear order is given by pointers. Each node has two parts 1st part contain the
information of the element 2nd part contains the address of the next node in
the list.
double linked list:
It is a collection of data elements called nodes, where each node is divided into
three parts
i) An info field that contains the information stored in the node
ii) Left field that contain pointer to node on left side
iii) Right field that contain pointer to node on right side
Tree: It is used to represent data which has a hierarical relationship. It can
have any no. of children per node.
Binary tree: it can have max. 2 children per node.
LEFT SUCCESSOR RIGHT SUCCESSOR
A spanning tree is a tree associated with a network. All the nodes of the graph
appear on the tree once. A minimum spanning tree is a spanning tree organized
so that the total edge weight between nodes is minimized
Binary search tree:
The values in all nodes in the right subtree of a node are greater than the
node values.
AVL tree: An empty binary tree, is an AVL tree, a non empty binary T tree is a
AVL tree. If given, TL & TR to be the left & right subtrees of T & H(TL) &
H(TR) to be the height of the subtrees TL & TR respectively. TL & TR are AVL
trees &
| H(TL)- H(TR)| <=1 where { H(TL)- H(TR } is known as the balance factor. The
balance factor of a node can be either 0,1, or -1
B=-1
B=0 B=-1
50
40 60
()
70
R
T1 T2
B=0
Graph:
A+B ::: INFIX
+AB ::: PREFIX
AB+ ::: POSTFIX
Precedence order:
1. Exponential
2. Multiplication
3. Divison
4. Addition
5. Substraction
Operations done:
1. Insertion
2. Deletion
3. Display/traversing
4. Searching
5. Sorting
Bubble sort:
Compare 2 adjacent elements, adjust by swapping & compare next 2 elements.
Insertion sort:
1st
element will be considered as a total array & the rest would be considered as a 2nd
array & the adjustment is made by swapping.
2nd
step: take 1st
2 elements as the 1st
array & rest as 2nd
array.
Continue till the 2nd
array becomes null.
Selection sort:
Take the smallest element & place it in the 1st
position.
Then start from the 2nd
block & take the 2nd
smallest element
In each pass we store 2 variables.
Binary search:
Last index will be in high. 1st
index will be in low.
Middle index will be stored in mid=(low + high)/2 for low<=high
Merge sort:
Last index will be in high. 1st
index will be in low.
Middle index will be stored in mid=(low + high)/2 for low<=high
Quick sort:
Mid= a[(high +low)/2] =p0
We will start checking from the left side & we will compare with p0 element.
Towers of Hanoi
A B C
Moving the blocks, from peg A to peg C, the condition is that only one block can be
moved at a time.
TREE:
It is used in networking.
Binary tree:
A set of elements that is either empty or is portioned into 3 disjoint subset.
The 1st
subset contains a single element called “root of the tree”.
Each element is called “node of the tree”
ROOT
LEFT SUB TREE
A
B C
RIGHT SUB TREE
D F
PREDEESSOR
SIBBLINGS
S
E
D,E,F – LEAVE NODE, because they don’t have successor.
Different type of binary tree:
1. Strictly binary tree:
A non leave node has non empty left & right sub tree.
A node can contain max. 2 child.
2. Complete binary tree:
Each node will contain maximum no. of child.
A
B C
D E F G
H I J K L
M N O
MAX.
1
2
3
4
LEVEL
0
1
2
3
3. Almost binary tree:
All nodes are at its max. level except possibly the last level & all nodes at the last level
appear as far left as possible
A
B C
E F G

More Related Content

What's hot

Lecture 1 data structures and algorithms
Lecture 1 data structures and algorithmsLecture 1 data structures and algorithms
Lecture 1 data structures and algorithms
Aakash deep Singhal
 

What's hot (20)

Data structure day1
Data structure day1Data structure day1
Data structure day1
 
Linked stacks and queues
Linked stacks and queuesLinked stacks and queues
Linked stacks and queues
 
Linked list
Linked listLinked list
Linked list
 
What is Link list? explained with animations
What is Link list? explained with animationsWhat is Link list? explained with animations
What is Link list? explained with animations
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure
 
linked list in Data Structure, Simple and Easy Tutorial
linked list in Data Structure, Simple and Easy Tutoriallinked list in Data Structure, Simple and Easy Tutorial
linked list in Data Structure, Simple and Easy Tutorial
 
Linked list in Data Structure and Algorithm
Linked list in Data Structure and Algorithm Linked list in Data Structure and Algorithm
Linked list in Data Structure and Algorithm
 
DATA STRUCTURE
DATA STRUCTUREDATA STRUCTURE
DATA STRUCTURE
 
Linked lists
Linked listsLinked lists
Linked lists
 
Linked list
Linked listLinked list
Linked list
 
Introduction to data structure
Introduction to data structure Introduction to data structure
Introduction to data structure
 
Lecture 1 data structures and algorithms
Lecture 1 data structures and algorithmsLecture 1 data structures and algorithms
Lecture 1 data structures and algorithms
 
DATA STRUCTURE IN C LANGUAGE
DATA STRUCTURE IN C LANGUAGEDATA STRUCTURE IN C LANGUAGE
DATA STRUCTURE IN C LANGUAGE
 
Data structure
 Data structure Data structure
Data structure
 
single linked list
single linked listsingle linked list
single linked list
 
Lecture7
Lecture7Lecture7
Lecture7
 
Java Linked List Tutorial | Edureka
Java Linked List Tutorial |  EdurekaJava Linked List Tutorial |  Edureka
Java Linked List Tutorial | Edureka
 
Data structure power point presentation
Data structure power point presentation Data structure power point presentation
Data structure power point presentation
 
Introduction of data structures and algorithms
Introduction of data structures and algorithmsIntroduction of data structures and algorithms
Introduction of data structures and algorithms
 
Data Structure and Algorithms Linked List
Data Structure and Algorithms Linked ListData Structure and Algorithms Linked List
Data Structure and Algorithms Linked List
 

Similar to Data structures notes

1.Introduction to Data Structures and Algorithms.pptx
1.Introduction to Data Structures and Algorithms.pptx1.Introduction to Data Structures and Algorithms.pptx
1.Introduction to Data Structures and Algorithms.pptx
BlueSwede
 
Introduction to Data Structure
Introduction to Data StructureIntroduction to Data Structure
Introduction to Data Structure
Jazz Jinia Bhowmik
 
Fundamentals of data structures
Fundamentals of data structuresFundamentals of data structures
Fundamentals of data structures
Niraj Agarwal
 
unit-ids17-180709051413-1.pdf
unit-ids17-180709051413-1.pdfunit-ids17-180709051413-1.pdf
unit-ids17-180709051413-1.pdf
KarthiKeyan326587
 
Ch 1 intriductions
Ch 1 intriductionsCh 1 intriductions
Ch 1 intriductions
irshad17
 

Similar to Data structures notes (20)

Data Structure
Data StructureData Structure
Data Structure
 
Data Structures
Data StructuresData Structures
Data Structures
 
Lecture notes data structures tree
Lecture notes data structures   treeLecture notes data structures   tree
Lecture notes data structures tree
 
[Queue , linked list , tree]
[Queue , linked list , tree][Queue , linked list , tree]
[Queue , linked list , tree]
 
data structures and algorithms Unit 1
data structures and algorithms Unit 1data structures and algorithms Unit 1
data structures and algorithms Unit 1
 
Data Structures & Algorithms Unit 1.pptx
Data Structures & Algorithms Unit 1.pptxData Structures & Algorithms Unit 1.pptx
Data Structures & Algorithms Unit 1.pptx
 
1.Introduction to Data Structures and Algorithms.pptx
1.Introduction to Data Structures and Algorithms.pptx1.Introduction to Data Structures and Algorithms.pptx
1.Introduction to Data Structures and Algorithms.pptx
 
Introduction to Data Structure
Introduction to Data StructureIntroduction to Data Structure
Introduction to Data Structure
 
Fundamentals of data structures
Fundamentals of data structuresFundamentals of data structures
Fundamentals of data structures
 
46267037-Data-Structures-PPT.ppt
46267037-Data-Structures-PPT.ppt46267037-Data-Structures-PPT.ppt
46267037-Data-Structures-PPT.ppt
 
General Data structures
General Data structuresGeneral Data structures
General Data structures
 
Data Structures (CS8391)
Data Structures (CS8391)Data Structures (CS8391)
Data Structures (CS8391)
 
unit-ids17-180709051413-1.pdf
unit-ids17-180709051413-1.pdfunit-ids17-180709051413-1.pdf
unit-ids17-180709051413-1.pdf
 
Operations on linked list
Operations on linked listOperations on linked list
Operations on linked list
 
UNITIII LDS.pdf
UNITIII LDS.pdfUNITIII LDS.pdf
UNITIII LDS.pdf
 
unit 1.pptx
unit 1.pptxunit 1.pptx
unit 1.pptx
 
VCE Unit 05.pptx
VCE Unit 05.pptxVCE Unit 05.pptx
VCE Unit 05.pptx
 
Ch 1 intriductions
Ch 1 intriductionsCh 1 intriductions
Ch 1 intriductions
 
Data structure &amp; algorithms introduction
Data structure &amp; algorithms introductionData structure &amp; algorithms introduction
Data structure &amp; algorithms introduction
 
unit 5 stack & queue.ppt
unit 5 stack & queue.pptunit 5 stack & queue.ppt
unit 5 stack & queue.ppt
 

More from Upasana Talukdar

More from Upasana Talukdar (20)

Large group intervention at airbus
Large group intervention at airbusLarge group intervention at airbus
Large group intervention at airbus
 
Shine life insurance
Shine life insuranceShine life insurance
Shine life insurance
 
Ohio department of taxation case study
Ohio department of taxation case studyOhio department of taxation case study
Ohio department of taxation case study
 
Oprah winfrey-charismatic leader
Oprah winfrey-charismatic leaderOprah winfrey-charismatic leader
Oprah winfrey-charismatic leader
 
Reliance vs big bazaar
Reliance vs big bazaarReliance vs big bazaar
Reliance vs big bazaar
 
Case analysis of wal mart
Case analysis of wal martCase analysis of wal mart
Case analysis of wal mart
 
Key Account Management
Key Account ManagementKey Account Management
Key Account Management
 
contract act
contract actcontract act
contract act
 
Emma
Emma Emma
Emma
 
Real estate market
Real estate market Real estate market
Real estate market
 
interviews
interviewsinterviews
interviews
 
computer organization and architecture notes
computer organization and architecture notescomputer organization and architecture notes
computer organization and architecture notes
 
How to use movie maker
How to use movie maker How to use movie maker
How to use movie maker
 
Html tags list
Html tags listHtml tags list
Html tags list
 
Crytocurrency and bitcoins
Crytocurrency and bitcoinsCrytocurrency and bitcoins
Crytocurrency and bitcoins
 
FISCAL POLICY
FISCAL POLICYFISCAL POLICY
FISCAL POLICY
 
Ben and jerry's CASE STUDY ORGANIZATIONAL DESIGN
Ben and jerry's CASE STUDY ORGANIZATIONAL DESIGNBen and jerry's CASE STUDY ORGANIZATIONAL DESIGN
Ben and jerry's CASE STUDY ORGANIZATIONAL DESIGN
 
Dbms notes
Dbms notesDbms notes
Dbms notes
 
Java notes
Java notesJava notes
Java notes
 
Mba in India 101
Mba in India 101Mba in India 101
Mba in India 101
 

Recently uploaded

Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
mphochane1998
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
AldoGarca30
 

Recently uploaded (20)

FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptxOrlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal load
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network Devices
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and properties
 
Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planes
 

Data structures notes

  • 1. DATA STRUCTURES The logical and mathematical model of a particular organization of data is called data structure. PRIMITIVE Array: Array is an ordered collection of items. It contains same data type. Array is a static object i.e. no of item is fixed and is assigned by the declaration of the array Stack: Stack is a ordered collection of items It is a list of dynamic objects/ elements in which an element may be inserted or deleted only at one end called top of the stack. DS PRIMITIVE NON PRIMITIVE LINEAR NON LINEAR ARRAYS STRUCTURE LIST STACKS QUEUES TREE GRAPH
  • 2. Elements are removed from a stack in the reverse order of that in which they are inserted in the stack. “Push”- to insert into the stack “pop”- to delete an element from a stack. Stacks are used to indicate the order of processing of data when certain steps of the processing must be postponed until other conditions are fulfilled. Follows LIFO Elements are removed from a stack (pop) in the reverse order of that in which they were inserted into the stack (push). It may contain different data types Integer to indicate the current stack top within the array. Operations: push, pop. Queue: An ordered collection of items from which items may be deleted at one end (front end) & items inserted at the other end (rear end). It follows FIFO. Priority Queue: priority queue is a data structure in which the intrinsic ordering of the elements (numeric or alphabetic) Linked list: A linked list is a linear collection of data elements, called nodes, where the linear order is given by pointers. Each node has two parts 1st part contain the information of the element 2nd part contains the address of the next node in the list. double linked list: It is a collection of data elements called nodes, where each node is divided into three parts i) An info field that contains the information stored in the node
  • 3. ii) Left field that contain pointer to node on left side iii) Right field that contain pointer to node on right side Tree: It is used to represent data which has a hierarical relationship. It can have any no. of children per node. Binary tree: it can have max. 2 children per node. LEFT SUCCESSOR RIGHT SUCCESSOR A spanning tree is a tree associated with a network. All the nodes of the graph appear on the tree once. A minimum spanning tree is a spanning tree organized so that the total edge weight between nodes is minimized Binary search tree: The values in all nodes in the right subtree of a node are greater than the node values. AVL tree: An empty binary tree, is an AVL tree, a non empty binary T tree is a AVL tree. If given, TL & TR to be the left & right subtrees of T & H(TL) & H(TR) to be the height of the subtrees TL & TR respectively. TL & TR are AVL trees & | H(TL)- H(TR)| <=1 where { H(TL)- H(TR } is known as the balance factor. The balance factor of a node can be either 0,1, or -1 B=-1 B=0 B=-1 50 40 60 () 70 R T1 T2
  • 4. B=0 Graph: A+B ::: INFIX +AB ::: PREFIX AB+ ::: POSTFIX Precedence order: 1. Exponential 2. Multiplication 3. Divison 4. Addition 5. Substraction
  • 5. Operations done: 1. Insertion 2. Deletion 3. Display/traversing 4. Searching 5. Sorting Bubble sort: Compare 2 adjacent elements, adjust by swapping & compare next 2 elements. Insertion sort: 1st element will be considered as a total array & the rest would be considered as a 2nd array & the adjustment is made by swapping. 2nd step: take 1st 2 elements as the 1st array & rest as 2nd array. Continue till the 2nd array becomes null. Selection sort: Take the smallest element & place it in the 1st position. Then start from the 2nd block & take the 2nd smallest element In each pass we store 2 variables. Binary search: Last index will be in high. 1st index will be in low. Middle index will be stored in mid=(low + high)/2 for low<=high Merge sort: Last index will be in high. 1st index will be in low. Middle index will be stored in mid=(low + high)/2 for low<=high Quick sort: Mid= a[(high +low)/2] =p0 We will start checking from the left side & we will compare with p0 element. Towers of Hanoi
  • 6. A B C Moving the blocks, from peg A to peg C, the condition is that only one block can be moved at a time. TREE: It is used in networking. Binary tree: A set of elements that is either empty or is portioned into 3 disjoint subset. The 1st subset contains a single element called “root of the tree”. Each element is called “node of the tree” ROOT LEFT SUB TREE A B C RIGHT SUB TREE D F PREDEESSOR SIBBLINGS S E
  • 7. D,E,F – LEAVE NODE, because they don’t have successor. Different type of binary tree: 1. Strictly binary tree: A non leave node has non empty left & right sub tree. A node can contain max. 2 child. 2. Complete binary tree: Each node will contain maximum no. of child. A B C D E F G H I J K L M N O MAX. 1 2 3 4 LEVEL 0 1 2 3
  • 8. 3. Almost binary tree: All nodes are at its max. level except possibly the last level & all nodes at the last level appear as far left as possible A B C E F G