SlideShare a Scribd company logo
Sorting  Prepared by Anis
Outline ,[object Object]
Sorting
Types Of Sorting
    Using Predefined Header File
   Inversion Counting (Merge Sort)
Related Problem (UVA online-judge)
   References,[object Object]
How to solve a problem ???? “a small, basic set of primitive instructions”. ,[object Object],[object Object]
To introduce notion of algorithm as means of specifying how to solve a problem.
To introduce and appreciate approaches for defining and solving very complex tasks in terms of simpler tasks.,[object Object]
Types Of Sorting Bubble Sort                 Speed: O(n^2), extremely slow but stable sorting algorithm                 Space: The size of initial array                 Coding Complexity: Simple Quick Sort                 Speed: O(nlogn), one of the best sorting algorithm  for unsorted data                 Space: The size of initial array                  Coding Complexity: Complex, Divide and Conquer Merge Sort                 Speed: O(nlogn) , one of the best stable sorting algorithm  Space: The size of initial array                  Coding Complexity: Complex, Merging Heap Sort                 Speed: O(nlogn) , one of the best unstable sorting algorithm                  Space: The size of linked list used                 Coding Complexity: Complex, Uses Tree Data structure
 Using Predefined Header File Sometimes it is needed to reduce the hassle of recoding same thing over and over again. Sometimes it is needed to sort a more complex stuffs, such as record, structure etc. where these record / structure might be sorted based on key present in the record/structure. Quick Sort header for C++ Language. qsort(<arrayname>,<size>,sizeof(<elementsize>),compare_function);
Compare function intcompare_function(const void *a,const void *b)     {              // The comparison Code goes here.      } Return type of the compare_function 1. negative, if a comes before b  Ž                 2. 0,             if a == b  Ž                 3. positive, if a comes after b  Using Predefined Header File
 Using Predefined Header File Comparing a list of integers                 1.   simply cast a and b to integers                2.  x  <  y, x-y is negative                     x == y, x-y is zero                      x  >  y, x-y is positive
 Using Predefined Header File Comparing a list of strings Comparing floating point numbers
 Using Predefined Header File Multi field sorting Before Sorting After Sorting
 Using Predefined Header File
Inversion Counting (Merge Sort)
Inversion Counting (Merge Sort) 4 7 6 2 1 5 8 3 Divide into front and back halves 4 7 6 2 1 5 8 3 4 3 2 4 6 7 1 3 5 8 Count inversions within each half, and sort each half Then, count inversions between front and back half
Inversion Counting (Merge Sort) 2 4 6 7 front: 1 3 5 8 back: Merge.  Whenever a back item is pushed up, count how many it goes past
Inversion Counting (Merge Sort) 2 4 6 7 front: 1 3 5 8 back: skips over 2, 4, 6 and 7 Inversions: 4 Merge.  Whenever a back item is pushed up, count how many it goes past
Inversion Counting (Merge Sort) 2 4 6 7 front: 1 3 5 8 back: from front, nothing to count Inversions: 4 Merge.  Whenever a back item is pushed up, count how many it goes past
Inversion Counting (Merge Sort) 4 6 7 front: 1 2 3 5 8 back: from front, nothing to count Inversions: 4 Merge.  Whenever a back item is pushed up, count how many it goes past
4 6 7 3 5 8 Inversion Counting (Merge Sort) front: 1 2 back: 3 skips over 4, 6, and 7 Inversions: 4 Inversions: 7 Merge.  Whenever a back item is pushed up, count how many it goes past
4 6 7 3 5 8 Inversion Counting (Merge Sort) front: 1 2 back: 4 is in front: no change Inversions: 4 Inversions: 7 Merge.  Whenever a back item is pushed up, count how many it goes past
4 6 7 3 5 8 Inversion Counting (Merge Sort) front: 1 2 back: 5 moves past 6 and 7 Inversions: 4 Inversions: 7 Merge.  Whenever a back item is pushed up, count how many it goes past
4 6 7 3 5 8 Inversion Counting (Merge Sort) front: 1 2 back: 6 is in front: no change Inversions: 4 Inversions: 9 Merge.  Whenever a back item is pushed up, count how many it goes past
4 6 7 3 5 8 Inversion Counting (Merge Sort) front: 1 2 back: 7 is in front: no change Inversions: 4 Inversions: 9 Merge.  Whenever a back item is pushed up, count how many it goes past
4 6 7 3 5 8 Inversion Counting (Merge Sort) 1 2 back: 8 just moves out Inversions: 4 Inversions: 9 Merge.  Whenever a back item is pushed up, count how many it goes past
4 6 7 3 5 8 Inversion Counting (Merge Sort) 1 2 Inversions: 4 Inversions: 9 Merge.  Whenever a back item is pushed up, count how many it goes past

More Related Content

What's hot

Sorting algorithms
Sorting algorithmsSorting algorithms
Sorting algorithms
Eleonora Ciceri
 
Sorting algorithms
Sorting algorithmsSorting algorithms
Sorting algorithms
Maher Alshammari
 
(Data Structure) Chapter11 searching & sorting
(Data Structure) Chapter11 searching & sorting(Data Structure) Chapter11 searching & sorting
(Data Structure) Chapter11 searching & sorting
Fadhil Ismail
 
Data Structures - Searching & sorting
Data Structures - Searching & sortingData Structures - Searching & sorting
Data Structures - Searching & sorting
Kaushal Shah
 
Lect11 Sorting
Lect11 SortingLect11 Sorting
Lect11 Sorting
ryokollll
 
Sorting
SortingSorting
Sorting
Ghaffar Khan
 
SORTTING IN LINEAR TIME - Radix Sort
SORTTING IN LINEAR TIME - Radix SortSORTTING IN LINEAR TIME - Radix Sort
SORTTING IN LINEAR TIME - Radix Sort
Devanshu Taneja
 
Sorting
SortingSorting
Sorting
Gopi Saiteja
 
Counting Sort and Radix Sort Algorithms
Counting Sort and Radix Sort AlgorithmsCounting Sort and Radix Sort Algorithms
Counting Sort and Radix Sort Algorithms
Sarvesh Rawat
 
Counting Sort Lowerbound
Counting Sort LowerboundCounting Sort Lowerbound
Counting Sort Lowerbound
despicable me
 
Array linear data_structure_2 (1)
Array linear data_structure_2 (1)Array linear data_structure_2 (1)
Array linear data_structure_2 (1)
eShikshak
 
Hub 102 - Lesson 5 - Algorithm: Sorting & Searching
Hub 102 - Lesson 5 - Algorithm: Sorting & SearchingHub 102 - Lesson 5 - Algorithm: Sorting & Searching
Hub 102 - Lesson 5 - Algorithm: Sorting & Searching
Tiểu Hổ
 
Lecture 3 data structures & algorithms - sorting techniques - http://techiem...
Lecture 3  data structures & algorithms - sorting techniques - http://techiem...Lecture 3  data structures & algorithms - sorting techniques - http://techiem...
Lecture 3 data structures & algorithms - sorting techniques - http://techiem...
Dharmendra Prasad
 
Merge sort
Merge sortMerge sort
Merge sort
Rojin Khadka
 
sorting algorithm graphical method
sorting algorithm graphical method sorting algorithm graphical method
sorting algorithm graphical method
Shantanu Mishra
 
Data structure using c module 3
Data structure using c module 3Data structure using c module 3
Data structure using c module 3
smruti sarangi
 
Lecture 6 data structures and algorithms
Lecture 6 data structures and algorithmsLecture 6 data structures and algorithms
Lecture 6 data structures and algorithms
Aakash deep Singhal
 
Counting sort
Counting sortCounting sort
Counting sort
arjunnaik19
 
6.queue
6.queue6.queue
6.queue
Chandan Singh
 
Lecture 13 data structures and algorithms
Lecture 13 data structures and algorithmsLecture 13 data structures and algorithms
Lecture 13 data structures and algorithms
Aakash deep Singhal
 

What's hot (20)

Sorting algorithms
Sorting algorithmsSorting algorithms
Sorting algorithms
 
Sorting algorithms
Sorting algorithmsSorting algorithms
Sorting algorithms
 
(Data Structure) Chapter11 searching & sorting
(Data Structure) Chapter11 searching & sorting(Data Structure) Chapter11 searching & sorting
(Data Structure) Chapter11 searching & sorting
 
Data Structures - Searching & sorting
Data Structures - Searching & sortingData Structures - Searching & sorting
Data Structures - Searching & sorting
 
Lect11 Sorting
Lect11 SortingLect11 Sorting
Lect11 Sorting
 
Sorting
SortingSorting
Sorting
 
SORTTING IN LINEAR TIME - Radix Sort
SORTTING IN LINEAR TIME - Radix SortSORTTING IN LINEAR TIME - Radix Sort
SORTTING IN LINEAR TIME - Radix Sort
 
Sorting
SortingSorting
Sorting
 
Counting Sort and Radix Sort Algorithms
Counting Sort and Radix Sort AlgorithmsCounting Sort and Radix Sort Algorithms
Counting Sort and Radix Sort Algorithms
 
Counting Sort Lowerbound
Counting Sort LowerboundCounting Sort Lowerbound
Counting Sort Lowerbound
 
Array linear data_structure_2 (1)
Array linear data_structure_2 (1)Array linear data_structure_2 (1)
Array linear data_structure_2 (1)
 
Hub 102 - Lesson 5 - Algorithm: Sorting & Searching
Hub 102 - Lesson 5 - Algorithm: Sorting & SearchingHub 102 - Lesson 5 - Algorithm: Sorting & Searching
Hub 102 - Lesson 5 - Algorithm: Sorting & Searching
 
Lecture 3 data structures & algorithms - sorting techniques - http://techiem...
Lecture 3  data structures & algorithms - sorting techniques - http://techiem...Lecture 3  data structures & algorithms - sorting techniques - http://techiem...
Lecture 3 data structures & algorithms - sorting techniques - http://techiem...
 
Merge sort
Merge sortMerge sort
Merge sort
 
sorting algorithm graphical method
sorting algorithm graphical method sorting algorithm graphical method
sorting algorithm graphical method
 
Data structure using c module 3
Data structure using c module 3Data structure using c module 3
Data structure using c module 3
 
Lecture 6 data structures and algorithms
Lecture 6 data structures and algorithmsLecture 6 data structures and algorithms
Lecture 6 data structures and algorithms
 
Counting sort
Counting sortCounting sort
Counting sort
 
6.queue
6.queue6.queue
6.queue
 
Lecture 13 data structures and algorithms
Lecture 13 data structures and algorithmsLecture 13 data structures and algorithms
Lecture 13 data structures and algorithms
 

Viewers also liked

Algoritmo Counting sort
Algoritmo Counting sortAlgoritmo Counting sort
Algoritmo Counting sort
Fernando Simeone
 
Merge sort
Merge sortMerge sort
Merge sort
Maher Alshammari
 
Distributed Coordination
Distributed CoordinationDistributed Coordination
Distributed Coordination
Luis Galárraga
 
Computer notes - Sorting
Computer notes  - SortingComputer notes  - Sorting
Computer notes - Sorting
ecomputernotes
 
Dijkstra s algorithm
Dijkstra s algorithmDijkstra s algorithm
Dijkstra s algorithm
mansab MIRZA
 
3.5 merge sort
3.5 merge sort3.5 merge sort
3.5 merge sort
Krish_ver2
 
Quicksort Presentation
Quicksort PresentationQuicksort Presentation
Quicksort Presentation
irdginfo
 
Merge sort and quick sort
Merge sort and quick sortMerge sort and quick sort
Merge sort and quick sort
Shakila Mahjabin
 
Divide and conquer - Quick sort
Divide and conquer - Quick sortDivide and conquer - Quick sort
Divide and conquer - Quick sort
Madhu Bala
 
Algorithm: Quick-Sort
Algorithm: Quick-SortAlgorithm: Quick-Sort
Algorithm: Quick-Sort
Tareq Hasan
 
Organisational designs and structures, traditional & contemporary organisatio...
Organisational designs and structures, traditional & contemporary organisatio...Organisational designs and structures, traditional & contemporary organisatio...
Organisational designs and structures, traditional & contemporary organisatio...
Al - Qurmoshi Institute of Business Management, Hyderabad
 
Quick Sort , Merge Sort , Heap Sort
Quick Sort , Merge Sort ,  Heap SortQuick Sort , Merge Sort ,  Heap Sort
Quick Sort , Merge Sort , Heap Sort
Mohammed Hussein
 
Merge sort
Merge sortMerge sort
Merge sort
Vidushi Pathak
 
Quick Sort
Quick SortQuick Sort
Quick Sort
priyankanaidu6
 

Viewers also liked (14)

Algoritmo Counting sort
Algoritmo Counting sortAlgoritmo Counting sort
Algoritmo Counting sort
 
Merge sort
Merge sortMerge sort
Merge sort
 
Distributed Coordination
Distributed CoordinationDistributed Coordination
Distributed Coordination
 
Computer notes - Sorting
Computer notes  - SortingComputer notes  - Sorting
Computer notes - Sorting
 
Dijkstra s algorithm
Dijkstra s algorithmDijkstra s algorithm
Dijkstra s algorithm
 
3.5 merge sort
3.5 merge sort3.5 merge sort
3.5 merge sort
 
Quicksort Presentation
Quicksort PresentationQuicksort Presentation
Quicksort Presentation
 
Merge sort and quick sort
Merge sort and quick sortMerge sort and quick sort
Merge sort and quick sort
 
Divide and conquer - Quick sort
Divide and conquer - Quick sortDivide and conquer - Quick sort
Divide and conquer - Quick sort
 
Algorithm: Quick-Sort
Algorithm: Quick-SortAlgorithm: Quick-Sort
Algorithm: Quick-Sort
 
Organisational designs and structures, traditional & contemporary organisatio...
Organisational designs and structures, traditional & contemporary organisatio...Organisational designs and structures, traditional & contemporary organisatio...
Organisational designs and structures, traditional & contemporary organisatio...
 
Quick Sort , Merge Sort , Heap Sort
Quick Sort , Merge Sort ,  Heap SortQuick Sort , Merge Sort ,  Heap Sort
Quick Sort , Merge Sort , Heap Sort
 
Merge sort
Merge sortMerge sort
Merge sort
 
Quick Sort
Quick SortQuick Sort
Quick Sort
 

Similar to Presentation

Unit6 C
Unit6 C Unit6 C
Unit6 C
arnold 7490
 
Daa chapter5
Daa chapter5Daa chapter5
Daa chapter5
B.Kirron Reddi
 
Sorting Seminar Presentation by Ashin Guha Majumder
Sorting Seminar Presentation by Ashin Guha MajumderSorting Seminar Presentation by Ashin Guha Majumder
Sorting Seminar Presentation by Ashin Guha Majumder
Ashin Guha Majumder
 
Data structure 8.pptx
Data structure 8.pptxData structure 8.pptx
Data structure 8.pptx
SajalFayyaz
 
Chapter 4 ds
Chapter 4 dsChapter 4 ds
Chapter 4 ds
Hanif Durad
 
data structures and algorithms Unit 3
data structures and algorithms Unit 3data structures and algorithms Unit 3
data structures and algorithms Unit 3
infanciaj
 
Sorting2
Sorting2Sorting2
Sorting2
Saurabh Mishra
 
Dsa – data structure and algorithms sorting
Dsa – data structure and algorithms  sortingDsa – data structure and algorithms  sorting
Dsa – data structure and algorithms sorting
sajinis3
 
Insersion & Bubble Sort in Algoritm
Insersion & Bubble Sort in AlgoritmInsersion & Bubble Sort in Algoritm
Insersion & Bubble Sort in Algoritm
Ehsan Ehrari
 
Sorting algorithums > Data Structures & Algorithums
Sorting algorithums  > Data Structures & AlgorithumsSorting algorithums  > Data Structures & Algorithums
Sorting algorithums > Data Structures & Algorithums
Ain-ul-Moiz Khawaja
 
Analysis of algorithms
Analysis of algorithms Analysis of algorithms
Analysis of algorithms
MUSAIDRIS15
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
Julie Iskander
 
lecture 9
lecture 9lecture 9
lecture 9
sajinsc
 
sorting.pptx
sorting.pptxsorting.pptx
sorting.pptx
DrRanjeetKumar51721
 
Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0
BG Java EE Course
 
DA_02_algorithms.pptx
DA_02_algorithms.pptxDA_02_algorithms.pptx
DA_02_algorithms.pptx
Alok Mohapatra
 
L1 - Recap.pdf
L1 - Recap.pdfL1 - Recap.pdf
L1 - Recap.pdf
Ifat Nix
 
Unit 7 sorting
Unit   7 sortingUnit   7 sorting
Unit 7 sorting
Dabbal Singh Mahara
 
Parallel search
Parallel searchParallel search
Parallel search
Md. Mahedi Mahfuj
 
Data Structures 6
Data Structures 6Data Structures 6
Data Structures 6
Dr.Umadevi V
 

Similar to Presentation (20)

Unit6 C
Unit6 C Unit6 C
Unit6 C
 
Daa chapter5
Daa chapter5Daa chapter5
Daa chapter5
 
Sorting Seminar Presentation by Ashin Guha Majumder
Sorting Seminar Presentation by Ashin Guha MajumderSorting Seminar Presentation by Ashin Guha Majumder
Sorting Seminar Presentation by Ashin Guha Majumder
 
Data structure 8.pptx
Data structure 8.pptxData structure 8.pptx
Data structure 8.pptx
 
Chapter 4 ds
Chapter 4 dsChapter 4 ds
Chapter 4 ds
 
data structures and algorithms Unit 3
data structures and algorithms Unit 3data structures and algorithms Unit 3
data structures and algorithms Unit 3
 
Sorting2
Sorting2Sorting2
Sorting2
 
Dsa – data structure and algorithms sorting
Dsa – data structure and algorithms  sortingDsa – data structure and algorithms  sorting
Dsa – data structure and algorithms sorting
 
Insersion & Bubble Sort in Algoritm
Insersion & Bubble Sort in AlgoritmInsersion & Bubble Sort in Algoritm
Insersion & Bubble Sort in Algoritm
 
Sorting algorithums > Data Structures & Algorithums
Sorting algorithums  > Data Structures & AlgorithumsSorting algorithums  > Data Structures & Algorithums
Sorting algorithums > Data Structures & Algorithums
 
Analysis of algorithms
Analysis of algorithms Analysis of algorithms
Analysis of algorithms
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
 
lecture 9
lecture 9lecture 9
lecture 9
 
sorting.pptx
sorting.pptxsorting.pptx
sorting.pptx
 
Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0
 
DA_02_algorithms.pptx
DA_02_algorithms.pptxDA_02_algorithms.pptx
DA_02_algorithms.pptx
 
L1 - Recap.pdf
L1 - Recap.pdfL1 - Recap.pdf
L1 - Recap.pdf
 
Unit 7 sorting
Unit   7 sortingUnit   7 sorting
Unit 7 sorting
 
Parallel search
Parallel searchParallel search
Parallel search
 
Data Structures 6
Data Structures 6Data Structures 6
Data Structures 6
 

Recently uploaded

Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Tosin Akinosho
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Alpen-Adria-Universität
 
Webinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data WarehouseWebinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data Warehouse
Federico Razzoli
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
saastr
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
SitimaJohn
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
Wouter Lemaire
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Wask
 
OpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - AuthorizationOpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - Authorization
David Brossard
 

Recently uploaded (20)

Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
 
Webinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data WarehouseWebinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data Warehouse
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
 
OpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - AuthorizationOpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - Authorization
 

Presentation

  • 2.
  • 5. Using Predefined Header File
  • 6. Inversion Counting (Merge Sort)
  • 7. Related Problem (UVA online-judge)
  • 8.
  • 9.
  • 10. To introduce notion of algorithm as means of specifying how to solve a problem.
  • 11.
  • 12. Types Of Sorting Bubble Sort Speed: O(n^2), extremely slow but stable sorting algorithm Space: The size of initial array Coding Complexity: Simple Quick Sort Speed: O(nlogn), one of the best sorting algorithm for unsorted data Space: The size of initial array Coding Complexity: Complex, Divide and Conquer Merge Sort Speed: O(nlogn) , one of the best stable sorting algorithm Space: The size of initial array Coding Complexity: Complex, Merging Heap Sort Speed: O(nlogn) , one of the best unstable sorting algorithm Space: The size of linked list used Coding Complexity: Complex, Uses Tree Data structure
  • 13. Using Predefined Header File Sometimes it is needed to reduce the hassle of recoding same thing over and over again. Sometimes it is needed to sort a more complex stuffs, such as record, structure etc. where these record / structure might be sorted based on key present in the record/structure. Quick Sort header for C++ Language. qsort(<arrayname>,<size>,sizeof(<elementsize>),compare_function);
  • 14. Compare function intcompare_function(const void *a,const void *b) { // The comparison Code goes here. } Return type of the compare_function 1. negative, if a comes before b Ž 2. 0, if a == b Ž 3. positive, if a comes after b Using Predefined Header File
  • 15. Using Predefined Header File Comparing a list of integers 1. simply cast a and b to integers 2. x < y, x-y is negative x == y, x-y is zero x > y, x-y is positive
  • 16. Using Predefined Header File Comparing a list of strings Comparing floating point numbers
  • 17. Using Predefined Header File Multi field sorting Before Sorting After Sorting
  • 18. Using Predefined Header File
  • 20. Inversion Counting (Merge Sort) 4 7 6 2 1 5 8 3 Divide into front and back halves 4 7 6 2 1 5 8 3 4 3 2 4 6 7 1 3 5 8 Count inversions within each half, and sort each half Then, count inversions between front and back half
  • 21. Inversion Counting (Merge Sort) 2 4 6 7 front: 1 3 5 8 back: Merge. Whenever a back item is pushed up, count how many it goes past
  • 22. Inversion Counting (Merge Sort) 2 4 6 7 front: 1 3 5 8 back: skips over 2, 4, 6 and 7 Inversions: 4 Merge. Whenever a back item is pushed up, count how many it goes past
  • 23. Inversion Counting (Merge Sort) 2 4 6 7 front: 1 3 5 8 back: from front, nothing to count Inversions: 4 Merge. Whenever a back item is pushed up, count how many it goes past
  • 24. Inversion Counting (Merge Sort) 4 6 7 front: 1 2 3 5 8 back: from front, nothing to count Inversions: 4 Merge. Whenever a back item is pushed up, count how many it goes past
  • 25. 4 6 7 3 5 8 Inversion Counting (Merge Sort) front: 1 2 back: 3 skips over 4, 6, and 7 Inversions: 4 Inversions: 7 Merge. Whenever a back item is pushed up, count how many it goes past
  • 26. 4 6 7 3 5 8 Inversion Counting (Merge Sort) front: 1 2 back: 4 is in front: no change Inversions: 4 Inversions: 7 Merge. Whenever a back item is pushed up, count how many it goes past
  • 27. 4 6 7 3 5 8 Inversion Counting (Merge Sort) front: 1 2 back: 5 moves past 6 and 7 Inversions: 4 Inversions: 7 Merge. Whenever a back item is pushed up, count how many it goes past
  • 28. 4 6 7 3 5 8 Inversion Counting (Merge Sort) front: 1 2 back: 6 is in front: no change Inversions: 4 Inversions: 9 Merge. Whenever a back item is pushed up, count how many it goes past
  • 29. 4 6 7 3 5 8 Inversion Counting (Merge Sort) front: 1 2 back: 7 is in front: no change Inversions: 4 Inversions: 9 Merge. Whenever a back item is pushed up, count how many it goes past
  • 30. 4 6 7 3 5 8 Inversion Counting (Merge Sort) 1 2 back: 8 just moves out Inversions: 4 Inversions: 9 Merge. Whenever a back item is pushed up, count how many it goes past
  • 31. 4 6 7 3 5 8 Inversion Counting (Merge Sort) 1 2 Inversions: 4 Inversions: 9 Merge. Whenever a back item is pushed up, count how many it goes past
  • 32. merge-and-count(A,B) ; A,B two input lists (sorted) ; C output list ; i,j current pointers to each list, start at beginning ; a_i, b_j elements pointed by i, j ; count number of inversion, initially 0 while A,B != empty copy min(a_i,b_j) to C if b_j < a_i count += number of element remaining in A j++ else i++ ; now one list is empty copy the remainder of the list to C return count, C Inversion Counting (Merge Sort)
  • 33. sort-and-count(L) if L become less then 2 return 0 else divide L into A, B copy first to mid to A copy from mid to last to B (rA, A) = sort-and-count(A) (rB, B) = sort-and-count(B) (r, L) = merge-and-count(A,B) return r = rA+rB+r, L Inversion Counting (Merge Sort)
  • 34. Related Problem (UVA online-judge) Sorting 299 612 10327 11462 Record based Sorting 482 10194 11804 Inversion Counting 299 10810 11495
  • 35. References Art of Programming Contest by Ahmed ShamsulArefin http://en.wikipedia.org/wiki/Sorting_algorithm
  • 36. While(1) { if(any questions pops) { printf(“Shout”); process(); } else break; }