SlideShare una empresa de Scribd logo
1 de 31
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

Más contenido relacionado

La actualidad más candente

(Data Structure) Chapter11 searching & sorting
(Data Structure) Chapter11 searching & sorting(Data Structure) Chapter11 searching & sorting
(Data Structure) Chapter11 searching & sortingFadhil Ismail
 
Data Structures - Searching & sorting
Data Structures - Searching & sortingData Structures - Searching & sorting
Data Structures - Searching & sortingKaushal Shah
 
Lect11 Sorting
Lect11 SortingLect11 Sorting
Lect11 Sortingryokollll
 
SORTTING IN LINEAR TIME - Radix Sort
SORTTING IN LINEAR TIME - Radix SortSORTTING IN LINEAR TIME - Radix Sort
SORTTING IN LINEAR TIME - Radix SortDevanshu Taneja
 
Counting Sort and Radix Sort Algorithms
Counting Sort and Radix Sort AlgorithmsCounting Sort and Radix Sort Algorithms
Counting Sort and Radix Sort AlgorithmsSarvesh Rawat
 
Counting Sort Lowerbound
Counting Sort LowerboundCounting Sort Lowerbound
Counting Sort Lowerbounddespicable 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 & SearchingTiể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
 
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 3smruti sarangi
 
Lecture 6 data structures and algorithms
Lecture 6 data structures and algorithmsLecture 6 data structures and algorithms
Lecture 6 data structures and algorithmsAakash deep Singhal
 
Lecture 13 data structures and algorithms
Lecture 13 data structures and algorithmsLecture 13 data structures and algorithms
Lecture 13 data structures and algorithmsAakash deep Singhal
 

La actualidad más candente (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
 

Destacado

Destacado (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 a Presentation

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 MajumderAshin Guha Majumder
 
Data structure 8.pptx
Data structure 8.pptxData structure 8.pptx
Data structure 8.pptxSajalFayyaz
 
data structures and algorithms Unit 3
data structures and algorithms Unit 3data structures and algorithms Unit 3
data structures and algorithms Unit 3infanciaj
 
Dsa – data structure and algorithms sorting
Dsa – data structure and algorithms  sortingDsa – data structure and algorithms  sorting
Dsa – data structure and algorithms sortingsajinis3
 
Insersion & Bubble Sort in Algoritm
Insersion & Bubble Sort in AlgoritmInsersion & Bubble Sort in Algoritm
Insersion & Bubble Sort in AlgoritmEhsan Ehrari
 
Sorting algorithums > Data Structures & Algorithums
Sorting algorithums  > Data Structures & AlgorithumsSorting algorithums  > Data Structures & Algorithums
Sorting algorithums > Data Structures & AlgorithumsAin-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 algorithmsJulie Iskander
 
lecture 9
lecture 9lecture 9
lecture 9sajinsc
 
Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0BG Java EE Course
 
L1 - Recap.pdf
L1 - Recap.pdfL1 - Recap.pdf
L1 - Recap.pdfIfat Nix
 

Similar a 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
 

Último

TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 

Último (20)

TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 

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; }