SlideShare a Scribd company logo
Topics ,[object Object],[object Object],[object Object],[object Object],[object Object]
To implement the List ADT ,[object Object],[object Object],[object Object]
Recall: 4 Basic Kinds of ADT Operations ,[object Object],[object Object],[object Object],[object Object],[object Object]
List Operations ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],change state observe state
ADT List Operations ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Iteration Pair
Array-based  class List Reset IsFull Length  IsPresent Delete IsEmpty Insert GetNexItem Private data: length data  [ 0] [1] [2] [MAX_LENGTH-1] currentPos SelSort
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Implementation Structures  ,[object Object],[object Object],[object Object]
Implementation Possibilities for a List List Linked list Built-in array Built-in  dynamic data and pointers Built-in array of structs
A Linked List ,[object Object],[object Object],head ‘ X’  ‘C’  ‘L’
Dynamic Linked List ,[object Object],head “ Ted”  “Irv”  “Lee”
Nodes can be located anywhere in memory ,[object Object],head 3000   “Ted”  5000   “Irv”  2000   “Lee”  NULL 3000  5000  2000
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Declarations for a Dynamic Linked List .   info  .   link ‘ A’   6000
Pointer Dereferencing and Member Selection ‘ A’  6000 ptr .   info  .   link ptr ptr .   info  .   link ‘ A’  6000 *ptr ptr .   info  .   link (*ptr).info ptr->info ‘ A’  6000
ptr  is a pointer to a node ‘ A’  6000 ptr .   info  .   link ptr
*ptr  is the entire node pointed to by ptr .   info  .   link ‘ A’  6000 *ptr ptr
ptr->info  is a node member ptr->info (*ptr).info  // Equivalent ‘ A’  6000 ptr .   info  .   link
ptr->link  is a node member ptr->link (*ptr).link  // Equivalent ‘ A’  6000 ptr .   info  .   link
Traversing a Dynamic Linked List // Pre:  head points to a dynamic linked list ptr  =  head; while (ptr != NULL)  { cout  <<  ptr->info;   // Or, do something else with node *ptr ptr  =  ptr->link; } ptr 3000   “Ted”  5000   “Irv”  2000   “Lee”  NULL 3000  5000  2000 head
Traversing a Dynamic Linked List // Pre:  head points to a dynamic linked list ptr  =  head; while (ptr != NULL)  { cout  <<  ptr->info;   // Or, do something else with node *ptr   ptr  =  ptr->link; } ptr  3000 3000   “Ted”  5000   “Irv”  2000   “Lee”  NULL 3000  5000  2000 head
Traversing a Dynamic Linked List // Pre:  head points to a dynamic linked list ptr  =  head; while (ptr != NULL)  { cout  <<  ptr->info;   // Or, do something else with node *ptr   ptr  =  ptr->link; } ptr  3000 3000   “Ted”  5000   “Irv”  2000   “Lee”  NULL 3000  5000  2000 head
Traversing a Dynamic Linked List // Pre:  head points to a dynamic linked list ptr  =  head; while (ptr != NULL)  { cout  <<  ptr->info;   // Or, do something else with node *ptr   ptr  =  ptr->link; } ptr  3000 3000   “Ted”  5000   “Irv”  2000   “Lee”  NULL 3000  5000  2000 head
Traversing a Dynamic Linked List // Pre:  head points to a dynamic linked list ptr  =  head; while (ptr != NULL)  { cout  <<  ptr->info;   // Or, do something else with node *ptr   ptr  =  ptr->link; } ptr  5000 3000   “Ted”  5000   “Irv”  2000   “Lee”  NULL 3000  5000  2000 head
Traversing a Dynamic Linked List // Pre:  head points to a dynamic linked list ptr  =  head; while (ptr != NULL)  { cout  <<  ptr->info;   // Or, do something else with node *ptr   ptr  =  ptr->link; } ptr  5000 3000   “Ted”  5000   “Irv”  2000   “Lee”  NULL 3000  5000  2000 head
Traversing a Dynamic Linked List // Pre:  head points to a dynamic linked list ptr  =  head; while (ptr != NULL)  { cout  <<  ptr->info;   // Or, do something else with node *ptr   ptr  =  ptr->link; } ptr  5000 3000   “Ted”  5000   “Irv”  2000   “Lee”  NULL 3000  5000  2000 head
Traversing a Dynamic Linked List // Pre:  head points to a dynamic linked list ptr  =  head; while (ptr != NULL)  { cout  <<  ptr->info;   // Or, do something else with node *ptr   ptr  =  ptr->link; } ptr  2000 3000   “Ted”  5000   “Irv”  2000   “Lee”  NULL 3000  5000  2000 head
Traversing a Dynamic Linked List // Pre:  head points to a dynamic linked list ptr  =  head; while (ptr != NULL)  { cout  <<  ptr->info;   // Or, do something else with node *ptr   ptr  =  ptr->link; } ptr  2000 3000   “Ted”  5000   “Irv”  2000   “Lee”  NULL 3000  5000  2000 head
Traversing a Dynamic Linked List // Pre:  head points to a dynamic linked list ptr  =  head; while (ptr != NULL)  { cout  <<  ptr->info;   // Or, do something else with node *ptr   ptr  =  ptr->link; } ptr  2000 3000   “Ted”  5000   “Irv”  2000   “Lee”  NULL 3000  5000  2000 head
Traversing a Dynamic Linked List // Pre:  head points to a dynamic linked list ptr  =  head; while (ptr != NULL)  { cout  <<  ptr->info;   // Or, do something else with node *ptr   ptr  =  ptr->link; } ptr  NULL 3000   “Ted”  5000   “Irv”  2000   “Lee”  NULL 3000  5000  2000 head
Traversing a Dynamic Linked List // Pre:  head points to a dynamic linked list ptr  =  head; while (ptr != NULL)  { cout  <<  ptr->info;   // Or, do something else with node *ptr   ptr  =  ptr->link; } ptr  NULL 3000   “Ted”  5000   “Irv”  2000   “Lee”  NULL 3000  5000  2000 head
Using Operator  new ,[object Object],[object Object],[object Object]
Inserting a Node at the Front of a List ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],‘ B’ item head ‘ X’  ‘C’  ‘L’
Inserting a Node at the Front of a List ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],location head ‘ X’  ‘C’  ‘L’ ‘ B’ item
Inserting a Node at the Front of a List ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],location head ‘ X’  ‘C’  ‘L’ ‘ B’ item
Inserting a Node at the Front of a List ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],location ‘ B’ head ‘ X’  ‘C’  ‘L’ ‘ B’ item
Inserting a Node at the Front of a List ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],location ‘ B’ head ‘ X’  ‘C’  ‘L’ ‘ B’ item
Inserting a Node at the Front of a List ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],‘ X’  ‘C’  ‘L’ location ‘ B’ head ‘ B’ item
[object Object],[object Object],[object Object],Using Operator  delete
Deleting the First Node from the List  ,[object Object],[object Object],[object Object],[object Object],[object Object],‘ B’  ‘X’  ‘C’  ‘L’ tempPtr head item
Deleting the First Node from the List ,[object Object],[object Object],[object Object],[object Object],[object Object],‘ B’  ‘X’  ‘C’  ‘L’ tempPtr head item ‘ B’
Deleting the First Node from the List ,[object Object],[object Object],[object Object],[object Object],[object Object],‘ B’  ‘X’  ‘C’  ‘L’ tempPtr head item ‘ B’
Deleting the First Node from the List ,[object Object],[object Object],[object Object],[object Object],[object Object],‘ B’  ‘X’  ‘C’  ‘L’ tempPtr head item ‘ B’
Deleting the First Node from the List ,[object Object],[object Object],[object Object],[object Object],[object Object],‘ X’  ‘C’  ‘L’ tempPtr head item ‘ B’
What is a Sorted List? ,[object Object],[object Object],[object Object],[object Object]
ADT HybridList Operations ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],change state

More Related Content

What's hot

Programming with Python - Week 2
Programming with Python - Week 2Programming with Python - Week 2
Programming with Python - Week 2
Ahmet Bulut
 
Programming with Python - Week 3
Programming with Python - Week 3Programming with Python - Week 3
Programming with Python - Week 3
Ahmet Bulut
 
Unit 1-array,lists and hashes
Unit 1-array,lists and hashesUnit 1-array,lists and hashes
Unit 1-array,lists and hashes
sana mateen
 
DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURES
bca2010
 
DocumentationofchangesondocumentparsingofBlueHOUND
DocumentationofchangesondocumentparsingofBlueHOUNDDocumentationofchangesondocumentparsingofBlueHOUND
DocumentationofchangesondocumentparsingofBlueHOUNDXulang Wan
 
Array,lists and hashes in perl
Array,lists and hashes in perlArray,lists and hashes in perl
Array,lists and hashes in perl
sana mateen
 
Duyet file
Duyet fileDuyet file
Duyet file
phuchieuct
 
Chapter 15 Lists
Chapter 15 ListsChapter 15 Lists
Chapter 15 Lists
Praveen M Jigajinni
 
Heaptree
HeaptreeHeaptree
Heaptree
Rajapriya82
 

What's hot (12)

Chap10
Chap10Chap10
Chap10
 
Programming with Python - Week 2
Programming with Python - Week 2Programming with Python - Week 2
Programming with Python - Week 2
 
Programming with Python - Week 3
Programming with Python - Week 3Programming with Python - Week 3
Programming with Python - Week 3
 
Unit 1-array,lists and hashes
Unit 1-array,lists and hashesUnit 1-array,lists and hashes
Unit 1-array,lists and hashes
 
강의자료9
강의자료9강의자료9
강의자료9
 
DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURES
 
DocumentationofchangesondocumentparsingofBlueHOUND
DocumentationofchangesondocumentparsingofBlueHOUNDDocumentationofchangesondocumentparsingofBlueHOUND
DocumentationofchangesondocumentparsingofBlueHOUND
 
Array,lists and hashes in perl
Array,lists and hashes in perlArray,lists and hashes in perl
Array,lists and hashes in perl
 
Duyet file
Duyet fileDuyet file
Duyet file
 
Chapter 15 Lists
Chapter 15 ListsChapter 15 Lists
Chapter 15 Lists
 
jfs-masters-1
jfs-masters-1jfs-masters-1
jfs-masters-1
 
Heaptree
HeaptreeHeaptree
Heaptree
 

Viewers also liked

02 20110314-simulation
02 20110314-simulation02 20110314-simulation
02 20110314-simulation
Saad Gabr
 

Viewers also liked (7)

Ch3
Ch3Ch3
Ch3
 
Ch5
Ch5Ch5
Ch5
 
Ch2
Ch2Ch2
Ch2
 
Ch4
Ch4Ch4
Ch4
 
Lec4
Lec4Lec4
Lec4
 
Ch1
Ch1Ch1
Ch1
 
02 20110314-simulation
02 20110314-simulation02 20110314-simulation
02 20110314-simulation
 

Similar to Lec6 mod linked list

Chapter 5 ds
Chapter 5 dsChapter 5 ds
Chapter 5 ds
Hanif Durad
 
Ll.pptx
Ll.pptxLl.pptx
Ll.pptx
chin463670
 
linked list.pptx
linked list.pptxlinked list.pptx
linked list.pptx
chin463670
 
Linked List.pptx
Linked List.pptxLinked List.pptx
Linked List.pptx
PoonamPatil120
 
Unit ii(dsc++)
Unit ii(dsc++)Unit ii(dsc++)
Unit ii(dsc++)
Durga Devi
 
dynamicList.ppt
dynamicList.pptdynamicList.ppt
dynamicList.ppt
ssuser0be977
 
Please refer this solution. This is working file for IntegersHeade.pdf
Please refer this solution. This is working file for IntegersHeade.pdfPlease refer this solution. This is working file for IntegersHeade.pdf
Please refer this solution. This is working file for IntegersHeade.pdf
sooryasalini
 
Linked lists a
Linked lists aLinked lists a
Linked lists a
Khuram Shahzad
 
Objective Manipulate the Linked List Pointer.Make acopy of LList..pdf
Objective Manipulate the Linked List Pointer.Make acopy of LList..pdfObjective Manipulate the Linked List Pointer.Make acopy of LList..pdf
Objective Manipulate the Linked List Pointer.Make acopy of LList..pdf
rajeshjangid1865
 
Consider a double-linked linked list implementation with the followin.pdf
Consider a double-linked linked list implementation with the followin.pdfConsider a double-linked linked list implementation with the followin.pdf
Consider a double-linked linked list implementation with the followin.pdf
sales98
 
Link List
Link ListLink List
Link List
umiekalsum
 
Chap 4 List of Data Structure.ppt
Chap 4 List of Data Structure.pptChap 4 List of Data Structure.ppt
Chap 4 List of Data Structure.ppt
shashankbhadouria4
 
Data Structures and Agorithm: DS 04 Linked List.pptx
Data Structures and Agorithm: DS 04 Linked List.pptxData Structures and Agorithm: DS 04 Linked List.pptx
Data Structures and Agorithm: DS 04 Linked List.pptx
RashidFaridChishti
 
Linked list1.ppt
Linked list1.pptLinked list1.ppt
Linked list1.ppt
KasthuriKAssistantPr
 

Similar to Lec6 mod linked list (20)

강의자료10
강의자료10강의자료10
강의자료10
 
Chapter 5 ds
Chapter 5 dsChapter 5 ds
Chapter 5 ds
 
DS Unit 2.ppt
DS Unit 2.pptDS Unit 2.ppt
DS Unit 2.ppt
 
Ll.pptx
Ll.pptxLl.pptx
Ll.pptx
 
linked list.pptx
linked list.pptxlinked list.pptx
linked list.pptx
 
Linked List.pptx
Linked List.pptxLinked List.pptx
Linked List.pptx
 
CSE240 Doubly Linked Lists
CSE240 Doubly Linked ListsCSE240 Doubly Linked Lists
CSE240 Doubly Linked Lists
 
Unit ii(dsc++)
Unit ii(dsc++)Unit ii(dsc++)
Unit ii(dsc++)
 
dynamicList.ppt
dynamicList.pptdynamicList.ppt
dynamicList.ppt
 
강의자료7
강의자료7강의자료7
강의자료7
 
Please refer this solution. This is working file for IntegersHeade.pdf
Please refer this solution. This is working file for IntegersHeade.pdfPlease refer this solution. This is working file for IntegersHeade.pdf
Please refer this solution. This is working file for IntegersHeade.pdf
 
Linked lists a
Linked lists aLinked lists a
Linked lists a
 
Objective Manipulate the Linked List Pointer.Make acopy of LList..pdf
Objective Manipulate the Linked List Pointer.Make acopy of LList..pdfObjective Manipulate the Linked List Pointer.Make acopy of LList..pdf
Objective Manipulate the Linked List Pointer.Make acopy of LList..pdf
 
Consider a double-linked linked list implementation with the followin.pdf
Consider a double-linked linked list implementation with the followin.pdfConsider a double-linked linked list implementation with the followin.pdf
Consider a double-linked linked list implementation with the followin.pdf
 
Unit7 C
Unit7 CUnit7 C
Unit7 C
 
Link List
Link ListLink List
Link List
 
Chap 4 List of Data Structure.ppt
Chap 4 List of Data Structure.pptChap 4 List of Data Structure.ppt
Chap 4 List of Data Structure.ppt
 
Data Structures and Agorithm: DS 04 Linked List.pptx
Data Structures and Agorithm: DS 04 Linked List.pptxData Structures and Agorithm: DS 04 Linked List.pptx
Data Structures and Agorithm: DS 04 Linked List.pptx
 
Linked list1.ppt
Linked list1.pptLinked list1.ppt
Linked list1.ppt
 
Lists
ListsLists
Lists
 

More from Saad Gabr

Lec2&3 data structure
Lec2&3 data structureLec2&3 data structure
Lec2&3 data structureSaad Gabr
 

More from Saad Gabr (7)

Ch1
Ch1Ch1
Ch1
 
Lec5
Lec5Lec5
Lec5
 
Lec3
Lec3Lec3
Lec3
 
Lec2
Lec2Lec2
Lec2
 
Lec2&3 data structure
Lec2&3 data structureLec2&3 data structure
Lec2&3 data structure
 
Lec1
Lec1Lec1
Lec1
 
Lec8
Lec8Lec8
Lec8
 

Recently uploaded

Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 

Recently uploaded (20)

Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 

Lec6 mod linked list

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6. Array-based class List Reset IsFull Length IsPresent Delete IsEmpty Insert GetNexItem Private data: length data [ 0] [1] [2] [MAX_LENGTH-1] currentPos SelSort
  • 7.
  • 8.
  • 9. Implementation Possibilities for a List List Linked list Built-in array Built-in dynamic data and pointers Built-in array of structs
  • 10.
  • 11.
  • 12.
  • 13.
  • 14. Pointer Dereferencing and Member Selection ‘ A’ 6000 ptr . info . link ptr ptr . info . link ‘ A’ 6000 *ptr ptr . info . link (*ptr).info ptr->info ‘ A’ 6000
  • 15. ptr is a pointer to a node ‘ A’ 6000 ptr . info . link ptr
  • 16. *ptr is the entire node pointed to by ptr . info . link ‘ A’ 6000 *ptr ptr
  • 17. ptr->info is a node member ptr->info (*ptr).info // Equivalent ‘ A’ 6000 ptr . info . link
  • 18. ptr->link is a node member ptr->link (*ptr).link // Equivalent ‘ A’ 6000 ptr . info . link
  • 19. Traversing a Dynamic Linked List // Pre: head points to a dynamic linked list ptr = head; while (ptr != NULL) { cout << ptr->info; // Or, do something else with node *ptr ptr = ptr->link; } ptr 3000 “Ted” 5000 “Irv” 2000 “Lee” NULL 3000 5000 2000 head
  • 20. Traversing a Dynamic Linked List // Pre: head points to a dynamic linked list ptr = head; while (ptr != NULL) { cout << ptr->info; // Or, do something else with node *ptr ptr = ptr->link; } ptr 3000 3000 “Ted” 5000 “Irv” 2000 “Lee” NULL 3000 5000 2000 head
  • 21. Traversing a Dynamic Linked List // Pre: head points to a dynamic linked list ptr = head; while (ptr != NULL) { cout << ptr->info; // Or, do something else with node *ptr ptr = ptr->link; } ptr 3000 3000 “Ted” 5000 “Irv” 2000 “Lee” NULL 3000 5000 2000 head
  • 22. Traversing a Dynamic Linked List // Pre: head points to a dynamic linked list ptr = head; while (ptr != NULL) { cout << ptr->info; // Or, do something else with node *ptr ptr = ptr->link; } ptr 3000 3000 “Ted” 5000 “Irv” 2000 “Lee” NULL 3000 5000 2000 head
  • 23. Traversing a Dynamic Linked List // Pre: head points to a dynamic linked list ptr = head; while (ptr != NULL) { cout << ptr->info; // Or, do something else with node *ptr ptr = ptr->link; } ptr 5000 3000 “Ted” 5000 “Irv” 2000 “Lee” NULL 3000 5000 2000 head
  • 24. Traversing a Dynamic Linked List // Pre: head points to a dynamic linked list ptr = head; while (ptr != NULL) { cout << ptr->info; // Or, do something else with node *ptr ptr = ptr->link; } ptr 5000 3000 “Ted” 5000 “Irv” 2000 “Lee” NULL 3000 5000 2000 head
  • 25. Traversing a Dynamic Linked List // Pre: head points to a dynamic linked list ptr = head; while (ptr != NULL) { cout << ptr->info; // Or, do something else with node *ptr ptr = ptr->link; } ptr 5000 3000 “Ted” 5000 “Irv” 2000 “Lee” NULL 3000 5000 2000 head
  • 26. Traversing a Dynamic Linked List // Pre: head points to a dynamic linked list ptr = head; while (ptr != NULL) { cout << ptr->info; // Or, do something else with node *ptr ptr = ptr->link; } ptr 2000 3000 “Ted” 5000 “Irv” 2000 “Lee” NULL 3000 5000 2000 head
  • 27. Traversing a Dynamic Linked List // Pre: head points to a dynamic linked list ptr = head; while (ptr != NULL) { cout << ptr->info; // Or, do something else with node *ptr ptr = ptr->link; } ptr 2000 3000 “Ted” 5000 “Irv” 2000 “Lee” NULL 3000 5000 2000 head
  • 28. Traversing a Dynamic Linked List // Pre: head points to a dynamic linked list ptr = head; while (ptr != NULL) { cout << ptr->info; // Or, do something else with node *ptr ptr = ptr->link; } ptr 2000 3000 “Ted” 5000 “Irv” 2000 “Lee” NULL 3000 5000 2000 head
  • 29. Traversing a Dynamic Linked List // Pre: head points to a dynamic linked list ptr = head; while (ptr != NULL) { cout << ptr->info; // Or, do something else with node *ptr ptr = ptr->link; } ptr NULL 3000 “Ted” 5000 “Irv” 2000 “Lee” NULL 3000 5000 2000 head
  • 30. Traversing a Dynamic Linked List // Pre: head points to a dynamic linked list ptr = head; while (ptr != NULL) { cout << ptr->info; // Or, do something else with node *ptr ptr = ptr->link; } ptr NULL 3000 “Ted” 5000 “Irv” 2000 “Lee” NULL 3000 5000 2000 head
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.