SlideShare a Scribd company logo
1 of 26
Sorting, ADTs, Linked Lists
No New Material This Week ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Sorting ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Sorting ,[object Object],[object Object],[object Object],[object Object]
Selection Sort ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Selection Sort ,[object Object],[object Object],[object Object],[object Object],Example:  small-to-large sort 0
Selection sort Example:  small-to-large sort
Selection Sort: Example Code ,[object Object],[object Object],[object Object]
Insertion Sort ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Insertion Sort Remove Insert
Insertion sort Example (1 st  unsorted item is automatially the 1 st  sorted item)
Abstract Data Types:  ADT s ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Abstract Data Types:  ADT s ,[object Object],[object Object],[object Object],[object Object],[object Object],k c e f s v g q pBgn pEnd pSortEnd NULL
ADTs: How to do it ,[object Object],[object Object],[object Object]
ADTs ADT Data structure  Operations Interface Users (you, and other  project programmers)
ADT Examples ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
An ADT: Singly Linked List ,[object Object],[object Object],[object Object],[object Object],[object Object],k c e f s v g q pBgn pEnd pSortEnd NULL
ADT: Linked Lists ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
ADT: Singly Linked Lists ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],head 8 3 12 1 NULL node node node node
ADT: Singly Linked Lists ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],A little tricky here: Recall: data type is  struct node , typedef renames it all as  nodeT , thus  member variable  pNext  is  a pointer-to-nodeT-type-objects
ADT: Singly Linked Lists ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],This works! NO! THE  OBVIOUS  WAY DOESN’T WORK!
Singly Linked Lists ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],10 NULL pHead
ADT: Singly Linked Lists ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Singly Linked Lists ,[object Object],[object Object],[object Object],[object Object],[object Object],8 12 1 NULL 10 pNew pHead pNow
Singly Linked Lists ,[object Object],[object Object],[object Object],[object Object],[object Object],8 12 1 NULL 10 pNew pHead pNow
Singly Linked Lists ,[object Object],[object Object],[object Object],[object Object],[object Object],8 12 1 NULL 10 pNew pHead pNow

More Related Content

What's hot

What's hot (20)

Polynomial reppresentation using Linkedlist-Application of LL.pptx
Polynomial reppresentation using Linkedlist-Application of LL.pptxPolynomial reppresentation using Linkedlist-Application of LL.pptx
Polynomial reppresentation using Linkedlist-Application of LL.pptx
 
DFS and BFS
DFS and BFSDFS and BFS
DFS and BFS
 
Singly link list
Singly link listSingly link list
Singly link list
 
Python Data-Types
Python Data-TypesPython Data-Types
Python Data-Types
 
Doubly Linked List
Doubly Linked ListDoubly Linked List
Doubly Linked List
 
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
 
Expression trees
Expression treesExpression trees
Expression trees
 
Linked List - Insertion & Deletion
Linked List - Insertion & DeletionLinked List - Insertion & Deletion
Linked List - Insertion & Deletion
 
Join
JoinJoin
Join
 
Binary tree
Binary tree Binary tree
Binary tree
 
Abstract Data Types
Abstract Data TypesAbstract Data Types
Abstract Data Types
 
Doubly Linked List
Doubly Linked ListDoubly Linked List
Doubly Linked List
 
Linked list
Linked list Linked list
Linked list
 
Trees (data structure)
Trees (data structure)Trees (data structure)
Trees (data structure)
 
Queue implementation
Queue implementationQueue implementation
Queue implementation
 
Doubly linked list (animated)
Doubly linked list (animated)Doubly linked list (animated)
Doubly linked list (animated)
 
stack & queue
stack & queuestack & queue
stack & queue
 
Functional dependency
Functional dependencyFunctional dependency
Functional dependency
 
Unit II - LINEAR DATA STRUCTURES
Unit II -  LINEAR DATA STRUCTURESUnit II -  LINEAR DATA STRUCTURES
Unit II - LINEAR DATA STRUCTURES
 
Binary search tree(bst)
Binary search tree(bst)Binary search tree(bst)
Binary search tree(bst)
 

Viewers also liked

Insertion into linked lists
Insertion into linked lists Insertion into linked lists
Insertion into linked lists
MrDavinderSingh
 
Bai toan va thuat toan
Bai toan va thuat toanBai toan va thuat toan
Bai toan va thuat toan
Hữu Duy Duy
 
Selection sort
Selection sortSelection sort
Selection sort
Jay Patel
 

Viewers also liked (13)

Linked list
Linked listLinked list
Linked list
 
Linked list
Linked listLinked list
Linked list
 
Insertion into linked lists
Insertion into linked lists Insertion into linked lists
Insertion into linked lists
 
Bai toan va thuat toan
Bai toan va thuat toanBai toan va thuat toan
Bai toan va thuat toan
 
Quicksort: illustrated step-by-step walk through
Quicksort: illustrated step-by-step walk throughQuicksort: illustrated step-by-step walk through
Quicksort: illustrated step-by-step walk through
 
Binary tree
Binary  treeBinary  tree
Binary tree
 
Linked List
Linked ListLinked List
Linked List
 
Quicksort
QuicksortQuicksort
Quicksort
 
Selection sort
Selection sortSelection sort
Selection sort
 
Bài 5: Các thuật toán sắp xếp và tìm kiếm cơ bản - Giáo trình FPT
Bài 5: Các thuật toán sắp xếp và tìm kiếm cơ bản - Giáo trình FPTBài 5: Các thuật toán sắp xếp và tìm kiếm cơ bản - Giáo trình FPT
Bài 5: Các thuật toán sắp xếp và tìm kiếm cơ bản - Giáo trình FPT
 
Sorting
SortingSorting
Sorting
 
Linked lists
Linked listsLinked lists
Linked lists
 
Quick Sort
Quick SortQuick Sort
Quick Sort
 

Similar to Sorting & Linked Lists

Fundamentals of data structures
Fundamentals of data structuresFundamentals of data structures
Fundamentals of data structures
Niraj Agarwal
 
Required to augment the authors Binary Search Tree (BST) code to .docx
Required to augment the authors Binary Search Tree (BST) code to .docxRequired to augment the authors Binary Search Tree (BST) code to .docx
Required to augment the authors Binary Search Tree (BST) code to .docx
debishakespeare
 

Similar to Sorting & Linked Lists (20)

Fundamentals of data structures
Fundamentals of data structuresFundamentals of data structures
Fundamentals of data structures
 
Chapter 5 ds
Chapter 5 dsChapter 5 ds
Chapter 5 ds
 
Data structures
Data structuresData structures
Data structures
 
Adt of lists
Adt of listsAdt of lists
Adt of lists
 
Linked list1.ppt
Linked list1.pptLinked list1.ppt
Linked list1.ppt
 
Unit7 C
Unit7 CUnit7 C
Unit7 C
 
List
ListList
List
 
Array linked list.ppt
Array  linked list.pptArray  linked list.ppt
Array linked list.ppt
 
General Data structures
General Data structuresGeneral Data structures
General Data structures
 
Data structure
 Data structure Data structure
Data structure
 
DS_PPT.pptx
DS_PPT.pptxDS_PPT.pptx
DS_PPT.pptx
 
C++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptxC++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptx
 
C++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptxC++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptx
 
01-intro_stacks.ppt
01-intro_stacks.ppt01-intro_stacks.ppt
01-intro_stacks.ppt
 
Required to augment the authors Binary Search Tree (BST) code to .docx
Required to augment the authors Binary Search Tree (BST) code to .docxRequired to augment the authors Binary Search Tree (BST) code to .docx
Required to augment the authors Binary Search Tree (BST) code to .docx
 
Java 1.5 - whats new and modern patterns (2007)
Java 1.5 - whats new and modern patterns (2007)Java 1.5 - whats new and modern patterns (2007)
Java 1.5 - whats new and modern patterns (2007)
 
17 linkedlist (1)
17 linkedlist (1)17 linkedlist (1)
17 linkedlist (1)
 
DS_LinkedList.pptx
DS_LinkedList.pptxDS_LinkedList.pptx
DS_LinkedList.pptx
 
Unit - 2.pdf
Unit - 2.pdfUnit - 2.pdf
Unit - 2.pdf
 
Unit i(dsc++)
Unit i(dsc++)Unit i(dsc++)
Unit i(dsc++)
 

More from J.T.A.JONES (20)

Seismic
SeismicSeismic
Seismic
 
Fire Detection and Alarm Systems
Fire Detection and Alarm SystemsFire Detection and Alarm Systems
Fire Detection and Alarm Systems
 
Productivity
ProductivityProductivity
Productivity
 
Public Switched Telephone Network (PSTN)
Public Switched Telephone Network (PSTN)Public Switched Telephone Network (PSTN)
Public Switched Telephone Network (PSTN)
 
Video phone
Video phoneVideo phone
Video phone
 
navigation
navigationnavigation
navigation
 
Radar
RadarRadar
Radar
 
safety belts
safety beltssafety belts
safety belts
 
Safety
SafetySafety
Safety
 
Powder Metallurgy
Powder Metallurgy Powder Metallurgy
Powder Metallurgy
 
Die Casting
Die Casting Die Casting
Die Casting
 
Casting
CastingCasting
Casting
 
Fuel Systems
Fuel SystemsFuel Systems
Fuel Systems
 
Carburetor Theory
Carburetor TheoryCarburetor Theory
Carburetor Theory
 
Software Development Life Cycle Model
Software Development Life Cycle ModelSoftware Development Life Cycle Model
Software Development Life Cycle Model
 
Types of os
Types of osTypes of os
Types of os
 
IO Management
IO ManagementIO Management
IO Management
 
Disk scheduling
Disk schedulingDisk scheduling
Disk scheduling
 
php
phpphp
php
 
Transformer
TransformerTransformer
Transformer
 

Recently uploaded

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
 
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
AnaAcapella
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
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
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
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...
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
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
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
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
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
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
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
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...
 

Sorting & Linked Lists