Sorting Algorithms: Bubble Sort, Selection Sort, and Insertion Sort, Slides of Object Oriented Programming

This is an easily understandable brief description of concepts for problem solving and object oriented programming.

Typology: Slides

2019/2020

Uploaded on 08/07/2020

muskan278
muskan278 🇮🇳

4

(1)

5 documents

1 / 49

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
Sorting
Session – 31 to 32
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31

Partial preview of the text

Download Sorting Algorithms: Bubble Sort, Selection Sort, and Insertion Sort and more Slides Object Oriented Programming in PDF only on Docsity!

Sorting

Session – 31 to 32

Problem

 (^) Results of VIT entrance exam has been released. Given the details of the students such as name, address and marks scored in entrance, write a program to sort the student details so that it will be convenient to call for counselling.

Sorting also means…

There are several sorting algorithms available like bubble sort, selection sort, insertion sort, quick sort, merge sort, radix sort etc.  (^) Sorting operation is performed in many applications to provide the output in desired order. For example listing all the product in the increasing order of their names or decreasing order of supplier names Searching will be easier in a sorted collection of elements List containing exam scores sorted from lowest to highest or vice versa We study Bubble Sorting, Selection Sorting and Insertion Sorting in this lab course

Compares neighboring pairs of array elements, starting with the last array element, and swaps neighbors whenever they are not in correct order. On each pass, this causes the smallest element to “bubble up” to its correct place in the array.

Bubble Sort

values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ]

Bubble Sort: Pass One

values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ]

U N S O R T E D

Bubble Sort: Pass One

values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ]

U N S O R T E D

Bubble Sort: Pass One

values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ]

U N S O R T E D

Bubble Sort: End Pass One

values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ]

U N S O R T E D

SORTED

Bubble Sort: Pass Two

values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ]

U N S O R T E D

SORTED

Bubble Sort: Pass Two

values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ]

U N S O R T E D

SORTED

Bubble Sort: Pass Three

values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ]

U N S O R T E D

SORTED

Bubble Sort: Pass Three

values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ]

U N S O R T E D

SORTED

Bubble Sort: Pass Four

values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ]

UNSORTED

S O R T E D

Bubble Sort: End Pass Four

values [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ]

S O R T E D