SlideShare a Scribd company logo
1 of 18
Download to read offline
STL
Standard Template Library 
• Standard Template Library 
template 
standard 
• container 
‘sequentieel’ 
‘associatief’ 
empty() size() 
• iterator 
vgl. pointer 
*p p++ == 
• algoritme 
zoeken, tellen 
kopiëren, reverse 
sorteren 
heap 
31 
77 
67 
35 
02 
- 
c.begin() 
c.end()
STL container 
sequential 
vector array, dynamisch 
list lijst, dubbel verbonden 
deque array, tweezijdige 
associative 
set verzameling 
map sleutel+waarde paren 
multimap .. meerwaardig 
adaptor 
priority_queue (niet list) 
queue rij (niet vector) 
stack stapel
STL vector 
#include <vector> 
int main() { 
vector<int> v; int i; 
for (i=0; i<10; i++) v.push_back(i); 
cout << v.size() << endl; 
for (i=0; i<10; i++) 
cout << v[i] << “ ”; 
cout << endl << v.front() 
<< “ ” << v.back() << endl; 
vector<int>::iterator p = v.begin(); 
while ( p != v.end() ) 
{ cout << *p << “ ”; p++; } 
return 0; 
}
STL adaptor, map 
#include <vector> 
#include <stack> 
int main() { 
stack<vector<int> > st; int i; 
for (i=0; i<10; i++) st.push(i); 
while ( !st.isempty() ) 
{ cout << st.top() << “ ”; st.pop(); } 
return 0; 
} 
#include <map> 
#include <string> 
int main() { 
map<string,int> mp; 
mp[“tim”] = 3; 
cout << mp[“tim”] << “ ” << mp[“bob”]; 
return 0; 
} 
map<string,int>::iterator 
p = mp.find(“bob”); 
spatie
abstracte datatypen
abstract data type 
ADT 
test 
in 
out
lijsten 
3 
6 
-1 
7 
6 
lijsten linear lists ADT vs. implementatie 
•list 
•double ended queue “deque” 
•stapel stack LIFO 
•rij queue FIFO data type elementen hier niet belangrijk (bij sommige adt’s wél)
lijsten 
3 
6 
-1 
7 
6 
ADT linear list 
first 
front/head 
last 
back/tail 
position 
•create 
•is empty 
•insert 
at/from front, back, position 
(?) before/after 
•delete 
at … (?) new position 
•value at position 
•search value 
return position (?) not found 
‘abstract’ 
data elementen 
lijst 
data types 
•element 
•position 
•list 
•boolean
lijsten 
3 
6 
-1 
7 
6 
ADT double ended queue 
first 
front/head 
last 
back/tail 
position 
•create 
•is empty 
•insert 
•delete 
•value at front, back (?) when empty 
‘abstract’ 
data elementen 
lijst 
data types 
•element 
•position 
•list 
•boolean
lijsten 
ADT double ended queue 
operation 
common name(s) 
Ada 
C++ 
Java 
Perl 
PHP 
Python 
Ruby 
Javascript 
insert element at back 
inject, snoc 
Append 
push_back 
offerLast 
push 
array_push 
append 
push 
push 
insert element at front 
push, cons 
Prepend 
push_front 
offerFirst 
unshift 
array_unshift 
appendleft 
unshift 
unshift 
remove last element 
eject 
Delete_Last 
pop_back 
pollLast 
pop 
array_pop 
pop 
pop 
pop 
remove first element 
pop 
Delete_First 
pop_front 
pollFirst 
shift 
array_shift 
popleft 
shift 
shift 
examine last element 
Last_Element 
back 
peekLast 
$array[- 1] 
end 
<obj>[-1] 
last 
<obj>[<obj>.length - 1] 
examine first element 
First_Element 
front 
peekFirst 
$array[0] 
reset 
<obj>[0] 
first 
<obj>[0] 
zegt wie? 
http://en.wikipedia.org/wiki/Double-ended_queue#Operations
lijsten 
3 
6 
-1 
7 
6 
ADT stack last-in-first-out 
top 
•create 
•is empty 
•insert ‘push’ 
•delete ‘pop’ 
•value at ‘top’ (?) when empty 
data types 
•element 
•position 
•list 
•boolean 
Drozdek 4.1
lijsten 
3 
6 
-1 
7 
6 
ADT queue first-in-first-out 
last 
back/tail 
•create 
•is empty 
•insert ‘enqueue’ 
•delete ‘dequeue’ 
•value at front (*) (?) when empty 
data types 
•element 
•position 
•list 
•boolean 
first 
front/head 
(*) andere kant makkelijk te implementeren 
Drozdek 4.2
representaties lijst 
representatie/implementatie lege lijst kopiëren, gelijkheidstest ‘diepte’ 
•array (bv:stack) willekeurige positie langzaam flexibele grootte: vector 
•linked enkel(queue) /dubbel verbonden 
prev 
next 
Λ 
last 
first
representaties lijst 
representatie/implementatie 
•array deque circular 
last 
first 
last 
first 
enqueue 
leeg / vol 
Drozdek 3.3
representaties lijst 
simplist: linkinversie 
vorig 
deze 
vorig 
deze 
slechts één positie ‘binnen lijst’ 
niet bij Drozdek
lijsten 
lijsten linear lists ADT vs. implementatie 
•list 
•double ended queue “deque” 
•stapel stack LIFO 
•rij queue FIFO 
gaan uit van 
elementen zonder ‘eigenschappen’ 
lineaire structuur vergelijk nu met 
set 
priority queue
set 
set [=verzameling] 
•als ADT, operaties? 
•implementatie? zoeken?

More Related Content

What's hot

Java 8 - An Introduction by Jason Swartz
Java 8 - An Introduction by Jason SwartzJava 8 - An Introduction by Jason Swartz
Java 8 - An Introduction by Jason SwartzJason Swartz
 
Functional Algebra: Monoids Applied
Functional Algebra: Monoids AppliedFunctional Algebra: Monoids Applied
Functional Algebra: Monoids AppliedSusan Potter
 
Property based Testing - generative data & executable domain rules
Property based Testing - generative data & executable domain rulesProperty based Testing - generative data & executable domain rules
Property based Testing - generative data & executable domain rulesDebasish Ghosh
 
Link list part 2
Link list part 2Link list part 2
Link list part 2Anaya Zafar
 
Modular Module Systems
Modular Module SystemsModular Module Systems
Modular Module Systemsleague
 
Python 2.5 reference card (2009)
Python 2.5 reference card (2009)Python 2.5 reference card (2009)
Python 2.5 reference card (2009)gekiaruj
 
Real World Generics In Swift
Real World Generics In SwiftReal World Generics In Swift
Real World Generics In SwiftVadym Markov
 
Blank Row Find and Select
Blank Row Find and SelectBlank Row Find and Select
Blank Row Find and SelectRobert Burns
 
NodeUkraine - Postgresql для хипстеров или почему ваш следующий проект должен...
NodeUkraine - Postgresql для хипстеров или почему ваш следующий проект должен...NodeUkraine - Postgresql для хипстеров или почему ваш следующий проект должен...
NodeUkraine - Postgresql для хипстеров или почему ваш следующий проект должен...DmitryChirkin1
 
Julia meetup bangalore
Julia meetup bangaloreJulia meetup bangalore
Julia meetup bangaloreKrishna Kalyan
 

What's hot (15)

Collection Core Concept
Collection Core ConceptCollection Core Concept
Collection Core Concept
 
Java 8 - An Introduction by Jason Swartz
Java 8 - An Introduction by Jason SwartzJava 8 - An Introduction by Jason Swartz
Java 8 - An Introduction by Jason Swartz
 
Functional Algebra: Monoids Applied
Functional Algebra: Monoids AppliedFunctional Algebra: Monoids Applied
Functional Algebra: Monoids Applied
 
Namespace and methods
Namespace and methodsNamespace and methods
Namespace and methods
 
Clojure Linters
Clojure LintersClojure Linters
Clojure Linters
 
Property based Testing - generative data & executable domain rules
Property based Testing - generative data & executable domain rulesProperty based Testing - generative data & executable domain rules
Property based Testing - generative data & executable domain rules
 
Link list part 2
Link list part 2Link list part 2
Link list part 2
 
Modular Module Systems
Modular Module SystemsModular Module Systems
Modular Module Systems
 
Python 2.5 reference card (2009)
Python 2.5 reference card (2009)Python 2.5 reference card (2009)
Python 2.5 reference card (2009)
 
Real World Generics In Swift
Real World Generics In SwiftReal World Generics In Swift
Real World Generics In Swift
 
Python in 90 minutes
Python in 90 minutesPython in 90 minutes
Python in 90 minutes
 
Blank Row Find and Select
Blank Row Find and SelectBlank Row Find and Select
Blank Row Find and Select
 
NodeUkraine - Postgresql для хипстеров или почему ваш следующий проект должен...
NodeUkraine - Postgresql для хипстеров или почему ваш следующий проект должен...NodeUkraine - Postgresql для хипстеров или почему ваш следующий проект должен...
NodeUkraine - Postgresql для хипстеров или почему ваш следующий проект должен...
 
Stack queue
Stack queueStack queue
Stack queue
 
Julia meetup bangalore
Julia meetup bangaloreJulia meetup bangalore
Julia meetup bangalore
 

Similar to Datastruct2

Collections Framework Beginners Guide 2
Collections Framework Beginners Guide 2Collections Framework Beginners Guide 2
Collections Framework Beginners Guide 2Kenji HASUNUMA
 
Collections Framework Begineers guide 2
Collections Framework Begineers guide 2Collections Framework Begineers guide 2
Collections Framework Begineers guide 2Kenji HASUNUMA
 
Revisiting a data structures in detail with linked list stack and queue
Revisiting a data structures in detail with linked list stack and queueRevisiting a data structures in detail with linked list stack and queue
Revisiting a data structures in detail with linked list stack and queuessuser7319f8
 
Bsc cs ii dfs u-2 linklist,stack,queue
Bsc cs ii  dfs u-2 linklist,stack,queueBsc cs ii  dfs u-2 linklist,stack,queue
Bsc cs ii dfs u-2 linklist,stack,queueRai University
 
Mca ii dfs u-3 linklist,stack,queue
Mca ii dfs u-3 linklist,stack,queueMca ii dfs u-3 linklist,stack,queue
Mca ii dfs u-3 linklist,stack,queueRai University
 
Bca ii dfs u-2 linklist,stack,queue
Bca ii  dfs u-2 linklist,stack,queueBca ii  dfs u-2 linklist,stack,queue
Bca ii dfs u-2 linklist,stack,queueRai University
 
Front end fundamentals session 1: javascript core
Front end fundamentals session 1: javascript coreFront end fundamentals session 1: javascript core
Front end fundamentals session 1: javascript coreWeb Zhao
 
Data Structures and Files
Data Structures and FilesData Structures and Files
Data Structures and FilesKanchanPatil34
 
Basic data structures in python
Basic data structures in pythonBasic data structures in python
Basic data structures in pythonLifna C.S
 
Ch03_stacks_and_queues.ppt
Ch03_stacks_and_queues.pptCh03_stacks_and_queues.ppt
Ch03_stacks_and_queues.pptOliverKane3
 
Scala collections api expressivity and brevity upgrade from java
Scala collections api  expressivity and brevity upgrade from javaScala collections api  expressivity and brevity upgrade from java
Scala collections api expressivity and brevity upgrade from javaIndicThreads
 
Swift, functional programming, and the future of Objective-C
Swift, functional programming, and the future of Objective-CSwift, functional programming, and the future of Objective-C
Swift, functional programming, and the future of Objective-CAlexis Gallagher
 
Learning notes of r for python programmer (Temp1)
Learning notes of r for python programmer (Temp1)Learning notes of r for python programmer (Temp1)
Learning notes of r for python programmer (Temp1)Chia-Chi Chang
 
standard template library(STL) in C++
standard template library(STL) in C++standard template library(STL) in C++
standard template library(STL) in C++•sreejith •sree
 

Similar to Datastruct2 (20)

9 python data structure-2
9 python data structure-29 python data structure-2
9 python data structure-2
 
Collections Framework Beginners Guide 2
Collections Framework Beginners Guide 2Collections Framework Beginners Guide 2
Collections Framework Beginners Guide 2
 
Collections Framework Begineers guide 2
Collections Framework Begineers guide 2Collections Framework Begineers guide 2
Collections Framework Begineers guide 2
 
Data structures
Data structuresData structures
Data structures
 
Revisiting a data structures in detail with linked list stack and queue
Revisiting a data structures in detail with linked list stack and queueRevisiting a data structures in detail with linked list stack and queue
Revisiting a data structures in detail with linked list stack and queue
 
Java Generics
Java GenericsJava Generics
Java Generics
 
Bsc cs ii dfs u-2 linklist,stack,queue
Bsc cs ii  dfs u-2 linklist,stack,queueBsc cs ii  dfs u-2 linklist,stack,queue
Bsc cs ii dfs u-2 linklist,stack,queue
 
Mca ii dfs u-3 linklist,stack,queue
Mca ii dfs u-3 linklist,stack,queueMca ii dfs u-3 linklist,stack,queue
Mca ii dfs u-3 linklist,stack,queue
 
Bca ii dfs u-2 linklist,stack,queue
Bca ii  dfs u-2 linklist,stack,queueBca ii  dfs u-2 linklist,stack,queue
Bca ii dfs u-2 linklist,stack,queue
 
Python3
Python3Python3
Python3
 
Front end fundamentals session 1: javascript core
Front end fundamentals session 1: javascript coreFront end fundamentals session 1: javascript core
Front end fundamentals session 1: javascript core
 
Data Structures and Files
Data Structures and FilesData Structures and Files
Data Structures and Files
 
Basic data structures in python
Basic data structures in pythonBasic data structures in python
Basic data structures in python
 
Ch03_stacks_and_queues.ppt
Ch03_stacks_and_queues.pptCh03_stacks_and_queues.ppt
Ch03_stacks_and_queues.ppt
 
Scala collections api expressivity and brevity upgrade from java
Scala collections api  expressivity and brevity upgrade from javaScala collections api  expressivity and brevity upgrade from java
Scala collections api expressivity and brevity upgrade from java
 
U3.stack queue
U3.stack queueU3.stack queue
U3.stack queue
 
Swift, functional programming, and the future of Objective-C
Swift, functional programming, and the future of Objective-CSwift, functional programming, and the future of Objective-C
Swift, functional programming, and the future of Objective-C
 
Queue
QueueQueue
Queue
 
Learning notes of r for python programmer (Temp1)
Learning notes of r for python programmer (Temp1)Learning notes of r for python programmer (Temp1)
Learning notes of r for python programmer (Temp1)
 
standard template library(STL) in C++
standard template library(STL) in C++standard template library(STL) in C++
standard template library(STL) in C++
 

More from roy-de-zomer

More from roy-de-zomer (11)

Fis 12languages
Fis 12languagesFis 12languages
Fis 12languages
 
Fis 10binary
Fis 10binaryFis 10binary
Fis 10binary
 
Fis 05dragonl
Fis 05dragonlFis 05dragonl
Fis 05dragonl
 
Fis 04recursion
Fis 04recursionFis 04recursion
Fis 04recursion
 
Fis 03functions
Fis 03functionsFis 03functions
Fis 03functions
 
Fis 02relations
Fis 02relationsFis 02relations
Fis 02relations
 
Fis 01sets
Fis 01setsFis 01sets
Fis 01sets
 
Ds intro
Ds introDs intro
Ds intro
 
eg Datastruc4
eg Datastruc4eg Datastruc4
eg Datastruc4
 
Datastruct3
Datastruct3Datastruct3
Datastruct3
 
Datastruct1
Datastruct1Datastruct1
Datastruct1
 

Recently uploaded

Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Pooja Bhuva
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 

Recently uploaded (20)

Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 

Datastruct2

  • 1. STL
  • 2. Standard Template Library • Standard Template Library template standard • container ‘sequentieel’ ‘associatief’ empty() size() • iterator vgl. pointer *p p++ == • algoritme zoeken, tellen kopiëren, reverse sorteren heap 31 77 67 35 02 - c.begin() c.end()
  • 3. STL container sequential vector array, dynamisch list lijst, dubbel verbonden deque array, tweezijdige associative set verzameling map sleutel+waarde paren multimap .. meerwaardig adaptor priority_queue (niet list) queue rij (niet vector) stack stapel
  • 4. STL vector #include <vector> int main() { vector<int> v; int i; for (i=0; i<10; i++) v.push_back(i); cout << v.size() << endl; for (i=0; i<10; i++) cout << v[i] << “ ”; cout << endl << v.front() << “ ” << v.back() << endl; vector<int>::iterator p = v.begin(); while ( p != v.end() ) { cout << *p << “ ”; p++; } return 0; }
  • 5. STL adaptor, map #include <vector> #include <stack> int main() { stack<vector<int> > st; int i; for (i=0; i<10; i++) st.push(i); while ( !st.isempty() ) { cout << st.top() << “ ”; st.pop(); } return 0; } #include <map> #include <string> int main() { map<string,int> mp; mp[“tim”] = 3; cout << mp[“tim”] << “ ” << mp[“bob”]; return 0; } map<string,int>::iterator p = mp.find(“bob”); spatie
  • 7. abstract data type ADT test in out
  • 8. lijsten 3 6 -1 7 6 lijsten linear lists ADT vs. implementatie •list •double ended queue “deque” •stapel stack LIFO •rij queue FIFO data type elementen hier niet belangrijk (bij sommige adt’s wél)
  • 9. lijsten 3 6 -1 7 6 ADT linear list first front/head last back/tail position •create •is empty •insert at/from front, back, position (?) before/after •delete at … (?) new position •value at position •search value return position (?) not found ‘abstract’ data elementen lijst data types •element •position •list •boolean
  • 10. lijsten 3 6 -1 7 6 ADT double ended queue first front/head last back/tail position •create •is empty •insert •delete •value at front, back (?) when empty ‘abstract’ data elementen lijst data types •element •position •list •boolean
  • 11. lijsten ADT double ended queue operation common name(s) Ada C++ Java Perl PHP Python Ruby Javascript insert element at back inject, snoc Append push_back offerLast push array_push append push push insert element at front push, cons Prepend push_front offerFirst unshift array_unshift appendleft unshift unshift remove last element eject Delete_Last pop_back pollLast pop array_pop pop pop pop remove first element pop Delete_First pop_front pollFirst shift array_shift popleft shift shift examine last element Last_Element back peekLast $array[- 1] end <obj>[-1] last <obj>[<obj>.length - 1] examine first element First_Element front peekFirst $array[0] reset <obj>[0] first <obj>[0] zegt wie? http://en.wikipedia.org/wiki/Double-ended_queue#Operations
  • 12. lijsten 3 6 -1 7 6 ADT stack last-in-first-out top •create •is empty •insert ‘push’ •delete ‘pop’ •value at ‘top’ (?) when empty data types •element •position •list •boolean Drozdek 4.1
  • 13. lijsten 3 6 -1 7 6 ADT queue first-in-first-out last back/tail •create •is empty •insert ‘enqueue’ •delete ‘dequeue’ •value at front (*) (?) when empty data types •element •position •list •boolean first front/head (*) andere kant makkelijk te implementeren Drozdek 4.2
  • 14. representaties lijst representatie/implementatie lege lijst kopiëren, gelijkheidstest ‘diepte’ •array (bv:stack) willekeurige positie langzaam flexibele grootte: vector •linked enkel(queue) /dubbel verbonden prev next Λ last first
  • 15. representaties lijst representatie/implementatie •array deque circular last first last first enqueue leeg / vol Drozdek 3.3
  • 16. representaties lijst simplist: linkinversie vorig deze vorig deze slechts één positie ‘binnen lijst’ niet bij Drozdek
  • 17. lijsten lijsten linear lists ADT vs. implementatie •list •double ended queue “deque” •stapel stack LIFO •rij queue FIFO gaan uit van elementen zonder ‘eigenschappen’ lineaire structuur vergelijk nu met set priority queue
  • 18. set set [=verzameling] •als ADT, operaties? •implementatie? zoeken?