SlideShare una empresa de Scribd logo
1 de 16
Descargar para leer sin conexión
Data Structures
Arvind Devaraj
Data Structure Selection
• What data structure will you use in the
following Scenarios
Ten people are standing
in a row.
Every third person is
eliminated.
Which person remains
Which Data structure ? Array, List, Tree, Stack, Queue ?????
SCENARIO-1
SCENARIO 2
Recent 5 missed
calls must be
displayed
Which Data structure ? Array, List, Tree, Stack, Queue ?????
SCENARIO 3
• Need to maintain database of student
names…support for
– Insert, Delete, Search
– (also) next and previous person
– (also) find who got maximum marks
Which Data structure ? Array, List, Tree, Stack, Queue ?????
SCENARIO 4
Each person is assigned a priority number
when he enters an office. The person who
has the highest priority is served
Each process is having priority. The OS
schedules the one having the highest
priority
Which Data structure ? Array, List, Tree, Stack, Queue ?????
Arrays (vs List)
+ Fast Access
+ Memory consumption is minimal
- Insertion and deletion is complicated
Linked Lists
• A way of making variable length arrays
– In which insertions and deletions are easy
• But nothing comes for free
– Finding an element can be slow
– Extra space is needed for the links
Linked List Example
Jill Joe Tom
first
Public static main (String[] argv) {
Student first;
…
}
Public class Student {
String name;
public Student next;
}
Trees
• Linked list with multiple next elements
Binary trees are useful for relationships like “<“ ,
“>”
• Insertions and deletions are easy
• Useful for fast searching of large
collections
Binary Tree Example
Jill
Joe
Tom
root Public class Student {
int String name;
public Student left;
public Student right;
}
Write a program
• height of binary tree
• Count leaves
• Find minimum value
• Locate a particular node
• Find successor of a node
• Check if it’s a Binary Search tree
int height( BinaryTree Node t)
{
if t is a null tree
return -1;
hl = height( left subtree of t);
hr = height( right subtree of t);
h = 1 + maximum of hl and hr;
return h;
}
Hashtables
• Find an element nearly as fast as in an
array
– With easy insertion and deletion
– But without the ability to keep things in order
• Fairly complex to implement
– But Java defines a class to make it simple
• Helpful to understand how it works
– “One size fits all” approaches are inefficient
Choosing a Data Structure
• What operations do you need to perform?
• Hashing finds single elements quickly
– But cannot preserve order
• Stacks and linked lists preserve order easily
– But they can only read one element at any time
• Balanced trees are best when you need both
– Need to read in blocks (for disks)
– B-Tree is used

Más contenido relacionado

La actualidad más candente

Data structure and its types
Data structure and its typesData structure and its types
Data structure and its types
Navtar Sidhu Brar
 
Data structure and its types
Data structure and its typesData structure and its types
Data structure and its types
Navtar Sidhu Brar
 
Introductiont To Aray,Tree,Stack, Queue
Introductiont To Aray,Tree,Stack, QueueIntroductiont To Aray,Tree,Stack, Queue
Introductiont To Aray,Tree,Stack, Queue
Ghaffar Khan
 

La actualidad más candente (20)

Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure
 
Datastructure
DatastructureDatastructure
Datastructure
 
Data structures
Data structuresData structures
Data structures
 
Introduction of data structures and algorithms
Introduction of data structures and algorithmsIntroduction of data structures and algorithms
Introduction of data structures and algorithms
 
Data structures
Data structuresData structures
Data structures
 
Data structure
Data structureData structure
Data structure
 
Data structures using c
Data structures using cData structures using c
Data structures using c
 
Introduction to data structure
Introduction to data structure Introduction to data structure
Introduction to data structure
 
Data structure and its types
Data structure and its typesData structure and its types
Data structure and its types
 
Data structure and its types
Data structure and its typesData structure and its types
Data structure and its types
 
Data structure ppt
Data structure pptData structure ppt
Data structure ppt
 
data structure
data structuredata structure
data structure
 
Introduction to data structure ppt
Introduction to data structure pptIntroduction to data structure ppt
Introduction to data structure ppt
 
Data Structures Notes 2021
Data Structures Notes 2021Data Structures Notes 2021
Data Structures Notes 2021
 
Introduction To Data Structures.
Introduction To Data Structures.Introduction To Data Structures.
Introduction To Data Structures.
 
DATA STRUCTURE
DATA STRUCTUREDATA STRUCTURE
DATA STRUCTURE
 
Introductiont To Aray,Tree,Stack, Queue
Introductiont To Aray,Tree,Stack, QueueIntroductiont To Aray,Tree,Stack, Queue
Introductiont To Aray,Tree,Stack, Queue
 
Data structure &amp; algorithms introduction
Data structure &amp; algorithms introductionData structure &amp; algorithms introduction
Data structure &amp; algorithms introduction
 
DATA STRUCTURE IN C LANGUAGE
DATA STRUCTURE IN C LANGUAGEDATA STRUCTURE IN C LANGUAGE
DATA STRUCTURE IN C LANGUAGE
 
Introduction to Data Structure
Introduction to Data Structure Introduction to Data Structure
Introduction to Data Structure
 

Destacado

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
 
Introduction of data structure
Introduction of data structureIntroduction of data structure
Introduction of data structure
eShikshak
 
Fundamentals of data structures
Fundamentals of data structuresFundamentals of data structures
Fundamentals of data structures
Niraj Agarwal
 
Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and Algorithm
Dhaval Kaneria
 
Data Structures and Algorithms
Data Structures and AlgorithmsData Structures and Algorithms
Data Structures and Algorithms
Pierre Vigneras
 
Tree in data structure
Tree in data structureTree in data structure
Tree in data structure
ghhgj jhgh
 
Data structures / C++ Program examples
Data structures / C++ Program examplesData structures / C++ Program examples
Data structures / C++ Program examples
Kevin III
 
Datastructure notes
Datastructure notesDatastructure notes
Datastructure notes
Srikanth
 

Destacado (20)

DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURES
 
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
Data StructureData Structure
Data Structure
 
Introduction of data structure
Introduction of data structureIntroduction of data structure
Introduction of data structure
 
Fundamentals of data structures
Fundamentals of data structuresFundamentals of data structures
Fundamentals of data structures
 
Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and Algorithm
 
Data Structures and Algorithms
Data Structures and AlgorithmsData Structures and Algorithms
Data Structures and Algorithms
 
Linked list
Linked listLinked list
Linked list
 
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)....
 
STACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURESTACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURE
 
Tree in data structure
Tree in data structureTree in data structure
Tree in data structure
 
Linked lists
Linked listsLinked lists
Linked lists
 
Trees data structure
Trees data structureTrees data structure
Trees data structure
 
Queue data structure
Queue data structureQueue data structure
Queue data structure
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
 
Lecture1 data structure(introduction)
Lecture1 data structure(introduction)Lecture1 data structure(introduction)
Lecture1 data structure(introduction)
 
bca data structure
bca data structurebca data structure
bca data structure
 
Data structures / C++ Program examples
Data structures / C++ Program examplesData structures / C++ Program examples
Data structures / C++ Program examples
 
Data structures
Data structuresData structures
Data structures
 
Datastructure notes
Datastructure notesDatastructure notes
Datastructure notes
 

Similar a Data structures (introduction)

INTRODUCTION TO DATA STRUCTURE.pptx
INTRODUCTION TO DATA STRUCTURE.pptxINTRODUCTION TO DATA STRUCTURE.pptx
INTRODUCTION TO DATA STRUCTURE.pptx
AmitSingh770691
 
splaytree-171227043127.pptx NNNNNNNNNNNNNNNNNNNNNNN
splaytree-171227043127.pptx NNNNNNNNNNNNNNNNNNNNNNNsplaytree-171227043127.pptx NNNNNNNNNNNNNNNNNNNNNNN
splaytree-171227043127.pptx NNNNNNNNNNNNNNNNNNNNNNN
ratnapatil14
 
Fundamentalsofdatastructures 110501104205-phpapp02
Fundamentalsofdatastructures 110501104205-phpapp02Fundamentalsofdatastructures 110501104205-phpapp02
Fundamentalsofdatastructures 110501104205-phpapp02
Getachew Ganfur
 
Data Structure - Complete Basic Overview.ppt
Data Structure - Complete Basic Overview.pptData Structure - Complete Basic Overview.ppt
Data Structure - Complete Basic Overview.ppt
ak8820
 

Similar a Data structures (introduction) (20)

INTRODUCTION TO DATA STRUCTURE.pptx
INTRODUCTION TO DATA STRUCTURE.pptxINTRODUCTION TO DATA STRUCTURE.pptx
INTRODUCTION TO DATA STRUCTURE.pptx
 
Splay tree
Splay treeSplay tree
Splay tree
 
splaytree-171227043127.pptx NNNNNNNNNNNNNNNNNNNNNNN
splaytree-171227043127.pptx NNNNNNNNNNNNNNNNNNNNNNNsplaytree-171227043127.pptx NNNNNNNNNNNNNNNNNNNNNNN
splaytree-171227043127.pptx NNNNNNNNNNNNNNNNNNNNNNN
 
Chapter 4.pptx
Chapter 4.pptxChapter 4.pptx
Chapter 4.pptx
 
DOC-20221104-WA0036. بيانات.pptx
DOC-20221104-WA0036. بيانات.pptxDOC-20221104-WA0036. بيانات.pptx
DOC-20221104-WA0036. بيانات.pptx
 
data science
data sciencedata science
data science
 
Data structure unitfirst part1
Data structure unitfirst part1Data structure unitfirst part1
Data structure unitfirst part1
 
Data structure unitfirst part1
Data structure unitfirst part1Data structure unitfirst part1
Data structure unitfirst part1
 
Fundamentalsofdatastructures 110501104205-phpapp02
Fundamentalsofdatastructures 110501104205-phpapp02Fundamentalsofdatastructures 110501104205-phpapp02
Fundamentalsofdatastructures 110501104205-phpapp02
 
DATA STRUCTURE
DATA STRUCTUREDATA STRUCTURE
DATA STRUCTURE
 
Presentations, Documents, Infographics, and more
Presentations, Documents, Infographics, and morePresentations, Documents, Infographics, and more
Presentations, Documents, Infographics, and more
 
Introduction - Data Structures and Algorithms.ppt
Introduction - Data Structures and Algorithms.pptIntroduction - Data Structures and Algorithms.ppt
Introduction - Data Structures and Algorithms.ppt
 
Introduction to Data Structures
Introduction to Data StructuresIntroduction to Data Structures
Introduction to Data Structures
 
Standard template library
Standard template libraryStandard template library
Standard template library
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptx
 
b,Sc it data structure.pptx
b,Sc it data structure.pptxb,Sc it data structure.pptx
b,Sc it data structure.pptx
 
1.1 introduction to Data Structures.ppt
1.1 introduction to Data Structures.ppt1.1 introduction to Data Structures.ppt
1.1 introduction to Data Structures.ppt
 
CPP18 - String Parsing
CPP18 - String ParsingCPP18 - String Parsing
CPP18 - String Parsing
 
Data Structure - Complete Basic Overview.ppt
Data Structure - Complete Basic Overview.pptData Structure - Complete Basic Overview.ppt
Data Structure - Complete Basic Overview.ppt
 
b,Sc it data structure.ppt
b,Sc it data structure.pptb,Sc it data structure.ppt
b,Sc it data structure.ppt
 

Más de Arvind Devaraj

Yourstory Android Workshop
Yourstory Android WorkshopYourstory Android Workshop
Yourstory Android Workshop
Arvind Devaraj
 
Android High performance in GPU using opengles and renderscript
Android High performance in GPU using opengles and renderscriptAndroid High performance in GPU using opengles and renderscript
Android High performance in GPU using opengles and renderscript
Arvind Devaraj
 
Sorting (introduction)
 Sorting (introduction) Sorting (introduction)
Sorting (introduction)
Arvind Devaraj
 
Signal Processing Introduction using Fourier Transforms
Signal Processing Introduction using Fourier TransformsSignal Processing Introduction using Fourier Transforms
Signal Processing Introduction using Fourier Transforms
Arvind Devaraj
 

Más de Arvind Devaraj (20)

Deep learning for NLP and Transformer
 Deep learning for NLP  and Transformer Deep learning for NLP  and Transformer
Deep learning for NLP and Transformer
 
NLP using transformers
NLP using transformers NLP using transformers
NLP using transformers
 
Nodejs presentation
Nodejs presentationNodejs presentation
Nodejs presentation
 
Career hunt pitch
Career hunt pitchCareer hunt pitch
Career hunt pitch
 
Career options for CS and IT students
Career options for CS and IT studentsCareer options for CS and IT students
Career options for CS and IT students
 
Careerhunt ebook
Careerhunt ebookCareerhunt ebook
Careerhunt ebook
 
Static Analysis of Computer programs
Static Analysis of Computer programs Static Analysis of Computer programs
Static Analysis of Computer programs
 
Hyperbook
HyperbookHyperbook
Hyperbook
 
Yourstory Android Workshop
Yourstory Android WorkshopYourstory Android Workshop
Yourstory Android Workshop
 
Android High performance in GPU using opengles and renderscript
Android High performance in GPU using opengles and renderscriptAndroid High performance in GPU using opengles and renderscript
Android High performance in GPU using opengles and renderscript
 
OpenGLES Android Graphics
OpenGLES Android GraphicsOpenGLES Android Graphics
OpenGLES Android Graphics
 
Broadcast Receiver
Broadcast ReceiverBroadcast Receiver
Broadcast Receiver
 
AIDL - Android Interface Definition Language
AIDL  - Android Interface Definition LanguageAIDL  - Android Interface Definition Language
AIDL - Android Interface Definition Language
 
NDK Programming in Android
NDK Programming in AndroidNDK Programming in Android
NDK Programming in Android
 
Google Cloud Messaging
Google Cloud MessagingGoogle Cloud Messaging
Google Cloud Messaging
 
OpenGLES - Graphics Programming in Android
OpenGLES - Graphics Programming in Android OpenGLES - Graphics Programming in Android
OpenGLES - Graphics Programming in Android
 
Operating system
Operating systemOperating system
Operating system
 
Sorting (introduction)
 Sorting (introduction) Sorting (introduction)
Sorting (introduction)
 
Graphics programming in open gl
Graphics programming in open glGraphics programming in open gl
Graphics programming in open gl
 
Signal Processing Introduction using Fourier Transforms
Signal Processing Introduction using Fourier TransformsSignal Processing Introduction using Fourier Transforms
Signal Processing Introduction using Fourier Transforms
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Navigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseNavigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern Enterprise
 
API Governance and Monetization - The evolution of API governance
API Governance and Monetization -  The evolution of API governanceAPI Governance and Monetization -  The evolution of API governance
API Governance and Monetization - The evolution of API governance
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformLess Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
 
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
 
Decarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational PerformanceDecarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational Performance
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 

Data structures (introduction)

  • 2. Data Structure Selection • What data structure will you use in the following Scenarios
  • 3. Ten people are standing in a row. Every third person is eliminated. Which person remains Which Data structure ? Array, List, Tree, Stack, Queue ????? SCENARIO-1
  • 4. SCENARIO 2 Recent 5 missed calls must be displayed Which Data structure ? Array, List, Tree, Stack, Queue ?????
  • 5. SCENARIO 3 • Need to maintain database of student names…support for – Insert, Delete, Search – (also) next and previous person – (also) find who got maximum marks Which Data structure ? Array, List, Tree, Stack, Queue ?????
  • 6. SCENARIO 4 Each person is assigned a priority number when he enters an office. The person who has the highest priority is served Each process is having priority. The OS schedules the one having the highest priority Which Data structure ? Array, List, Tree, Stack, Queue ?????
  • 7. Arrays (vs List) + Fast Access + Memory consumption is minimal - Insertion and deletion is complicated
  • 8. Linked Lists • A way of making variable length arrays – In which insertions and deletions are easy • But nothing comes for free – Finding an element can be slow – Extra space is needed for the links
  • 9. Linked List Example Jill Joe Tom first Public static main (String[] argv) { Student first; … } Public class Student { String name; public Student next; }
  • 10. Trees • Linked list with multiple next elements Binary trees are useful for relationships like “<“ , “>” • Insertions and deletions are easy • Useful for fast searching of large collections
  • 11. Binary Tree Example Jill Joe Tom root Public class Student { int String name; public Student left; public Student right; }
  • 12. Write a program • height of binary tree • Count leaves • Find minimum value • Locate a particular node • Find successor of a node • Check if it’s a Binary Search tree
  • 13.
  • 14. int height( BinaryTree Node t) { if t is a null tree return -1; hl = height( left subtree of t); hr = height( right subtree of t); h = 1 + maximum of hl and hr; return h; }
  • 15. Hashtables • Find an element nearly as fast as in an array – With easy insertion and deletion – But without the ability to keep things in order • Fairly complex to implement – But Java defines a class to make it simple • Helpful to understand how it works – “One size fits all” approaches are inefficient
  • 16. Choosing a Data Structure • What operations do you need to perform? • Hashing finds single elements quickly – But cannot preserve order • Stacks and linked lists preserve order easily – But they can only read one element at any time • Balanced trees are best when you need both – Need to read in blocks (for disks) – B-Tree is used