Docsity

DSA (BUBBLE SORT SLIDES ), Slides of Data Structures and Algorithms

Partial preview of the text

Download DSA (BUBBLE SORT SLIDES ) and more Slides Data Structures and Algorithms in PDF only on Docsity!

Faculty School of Engineering & Technology K.R. Mangalam University

Data Structure

Dr Swati Gupta & Ms Suman

Unit 4 : Sorting and Searching

Dr. Swati & Ms Suman

Session Agenda ➢ Applications of Sorting in Real World ➢ Basic Introduction of Sorting ➢ Bubble Sort ➢ Algorithm and Complexity Analysis of Bubble Sorts ➢ Brainstorming Session ➢ Insertion sort ➢ Algorithm and Complexity Analysis of Insertion sort ➢ Example of Insertion Sort ➢ Brainstorming Session Session 32 : Introduction to Sorting Session 33 :Insertion Sort

Session Agenda ➢ Divide and Conquer Strategy ➢ Merge Sort ➢ Example of Merge Sort ➢ Algorithm of Merge Sort ➢ Complexity Analysis of Merge Sort ➢ Brainstorming Session ➢ Quick Sort ➢ Choosing the pivot element in Quick Sort ➢ Example of Quick Sort ➢ Algorithm of Quick Sort ➢ Complexity Analysis of all the Sorting Algorithm ➢ Brainstorming Session Session 36: Merge Sort Session 37: Quick Sort

Session Agenda ➢ Linear Search ➢ How to search an Element ➢ Example of Linear Search ➢ Algorithm of Linear Search and Its Applications ➢ Complexity Analysis of the Linear Search ➢ Brainstorming Session ➢ Binary Search ➢ How to search an Element ➢ Example of Binary Search ➢ Algorithm of Binary Search and Its Applications ➢ Complexity Analysis of the Binary Search ➢ Brainstorming Session Session 38 : Linear Search Session 39 :Binary Search

Session 32 ➢ Basic Introduction of Sorting ➢ Applications of Sorting in Real World ➢ Bubble Sort ➢ Algorithm and Complexity Analysis of Bubble Sorts ➢ Brainstorming Session INTRODUCTION TO SORTING

Basic Introduction of Sorting ➢ In data structure, we often need to rearrange elements of our data on basis of increasing/decreasing order to perform our key operation. This process of rearrangement is called Sorting. ➢ Sorting data allows a user to find information faster and easier.

Applications of Sorting in Computer Science ➢ Database Management : Sorting is crucial for efficient querying and indexing in databases. ➢ Machine Learning : Sorting is used in preprocessing steps for feature scaling and normalization. ➢ Parallel Computing : Sorting algorithms are fundamental in parallel computing for tasks like load balancing and task scheduling

Types of Sorting Source : https://techvidvan.com/tutorials/wp- content/uploads/sites/2/2021/06/TechVidvan-Bubble-sort- normal-image01.jpg.

Real World Application of Bubble Sort

Example of Bubble Sort Let's take an array of 5 elements. int arr[5] = {50, 25, 5, 20, 10}

Example of Bubble Sort

Example of Bubble Sort

Bubble Sort Algorithm

  • declare variables i, j
  • loop : i = 0 to n – 1 // outer loop
    • loop : j = 0 to n - i- 1 // inner loop
      • if ( a[j]>a[j+1] ) then
        • swap a[j] & a[j+1]
    • end loop // inner loop
  • end loop // outer loop

Bubble Sort Algorithm Complexity Analysis