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

Breadth first search and depth first search
Breadth first search and  depth first searchBreadth first search and  depth first search
Breadth first search and depth first searchHossain Md Shakhawat
 
Presentation on Breadth First Search (BFS)
Presentation on Breadth First Search (BFS)Presentation on Breadth First Search (BFS)
Presentation on Breadth First Search (BFS)Shuvongkor Barman
 
Double Linked List (Algorithm)
Double Linked List (Algorithm)Double Linked List (Algorithm)
Double Linked List (Algorithm)Huba Akhtar
 
Data structure & its types
Data structure & its typesData structure & its types
Data structure & its typesRameesha Sadaqat
 
Asymptotic Notation and Complexity
Asymptotic Notation and ComplexityAsymptotic Notation and Complexity
Asymptotic Notation and ComplexityRajandeep Gill
 
Infix to-postfix examples
Infix to-postfix examplesInfix to-postfix examples
Infix to-postfix examplesmua99
 
Timing and control
Timing and controlTiming and control
Timing and controlchauhankapil
 
Symbol table in compiler Design
Symbol table in compiler DesignSymbol table in compiler Design
Symbol table in compiler DesignKuppusamy P
 
Unit 4 python -list methods
Unit 4   python -list methodsUnit 4   python -list methods
Unit 4 python -list methodsnarmadhakin
 
linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure shameen khan
 
Tree and binary tree
Tree and binary treeTree and binary tree
Tree and binary treeZaid Shabbir
 
Algorithm Design and Complexity - Course 3
Algorithm Design and Complexity - Course 3Algorithm Design and Complexity - Course 3
Algorithm Design and Complexity - Course 3Traian Rebedea
 

What's hot (20)

Selection sorting
Selection sortingSelection sorting
Selection sorting
 
Arrays
ArraysArrays
Arrays
 
Breadth first search and depth first search
Breadth first search and  depth first searchBreadth first search and  depth first search
Breadth first search and depth first search
 
Presentation on Breadth First Search (BFS)
Presentation on Breadth First Search (BFS)Presentation on Breadth First Search (BFS)
Presentation on Breadth First Search (BFS)
 
Double Linked List (Algorithm)
Double Linked List (Algorithm)Double Linked List (Algorithm)
Double Linked List (Algorithm)
 
Data structure & its types
Data structure & its typesData structure & its types
Data structure & its types
 
Linked List
Linked ListLinked List
Linked List
 
Asymptotic Notation and Complexity
Asymptotic Notation and ComplexityAsymptotic Notation and Complexity
Asymptotic Notation and Complexity
 
Infix to-postfix examples
Infix to-postfix examplesInfix to-postfix examples
Infix to-postfix examples
 
Timing and control
Timing and controlTiming and control
Timing and control
 
Bfs and Dfs
Bfs and DfsBfs and Dfs
Bfs and Dfs
 
Symbol table in compiler Design
Symbol table in compiler DesignSymbol table in compiler Design
Symbol table in compiler Design
 
Unit 4 python -list methods
Unit 4   python -list methodsUnit 4   python -list methods
Unit 4 python -list methods
 
linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure
 
Graphs bfs dfs
Graphs bfs dfsGraphs bfs dfs
Graphs bfs dfs
 
Tree and binary tree
Tree and binary treeTree and binary tree
Tree and binary tree
 
Radix sorting
Radix sortingRadix sorting
Radix sorting
 
Acid properties
Acid propertiesAcid properties
Acid properties
 
Algorithm Design and Complexity - Course 3
Algorithm Design and Complexity - Course 3Algorithm Design and Complexity - Course 3
Algorithm Design and Complexity - Course 3
 
Tower Of Hanoi
Tower Of HanoiTower Of Hanoi
Tower Of Hanoi
 

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 toanHữu Duy Duy
 
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 throughYoshi Watanabe
 
Selection sort
Selection sortSelection sort
Selection sortJay Patel
 
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 FPTMasterCode.vn
 

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 structuresNiraj Agarwal
 
Array linked list.ppt
Array  linked list.pptArray  linked list.ppt
Array linked list.pptWaf1231
 
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).pptxAbhishek Tirkey
 
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).pptxGauravPandey43518
 
01-intro_stacks.ppt
01-intro_stacks.ppt01-intro_stacks.ppt
01-intro_stacks.pptsoniya555961
 
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 .docxdebishakespeare
 
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)Peter Antman
 
DS_LinkedList.pptx
DS_LinkedList.pptxDS_LinkedList.pptx
DS_LinkedList.pptxmsohail37
 

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

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

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
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
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 

Recently uploaded (20)

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
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
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 

Sorting & Linked Lists