KEMBAR78
Data Structure | PDF | Teaching Methods & Materials | Computers
0% found this document useful (0 votes)
28 views18 pages

Data Structure

The document discusses three sorting techniques: bubble sort, insertion sort, and merge sort. Bubble sort works by repeatedly swapping adjacent elements until they are in order. Insertion sort transfers elements one by one to the right position. Merge sort uses a divide and conquer approach to sort elements by dividing the list in half, recursively sorting the halves, and then merging the sorted halves.

Uploaded by

Vibishiniya V
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views18 pages

Data Structure

The document discusses three sorting techniques: bubble sort, insertion sort, and merge sort. Bubble sort works by repeatedly swapping adjacent elements until they are in order. Insertion sort transfers elements one by one to the right position. Merge sort uses a divide and conquer approach to sort elements by dividing the list in half, recursively sorting the halves, and then merging the sorted halves.

Uploaded by

Vibishiniya V
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 18

DATA

STRUCTURE
VIBISHINIYA V
SORTING TECHNIQUES

• BUBBLE SORT
• INSERTION SORT
• MERGE SORT

20XX Pitch deck title 2


BUBBLE SORT
WHAT IS BUBBLE SORT?
Bubble sort is a basic algorithm for arranging a
string of numbers or other elements in the
correct order. Bubble sort works on the
repeatedly swapping of adjacent elements until
they are not in the intended order.
WHY IT IS CALLED BUBBLE SORT?
It is called bubble sort because the movement
of array elements is just like the movement of
air bubbles in the water. Bubbles in water rise
up to the surface; similarly, the array elements
in bubble sort move to the end in each
iteration.
WORKING OF BUBBLE SORT

Let’s take an unsorted array.

Let the elements of array are

20XX Pitch deck title 4


FIRST PASS
Sorting will start from the initial two elements. Let compare them
to check which is greater.
SECOND PASS
THIRD PASS
FOURTH PASS

Hence no swapping is needed


INSERTION SORT

WHAT IS INSERTION SORT?


Insertion sort is a sorting algorithm in which the
elements are transferred one at a time to the
right position.
ALGORITHM FOR INSERTION
SORT
The simple steps of achieving the insertion sort are
listed as follows -
Step 1 - If the element is the first element, assume
that it is already sorted. Return 1.
Step2 - Pick the next element, and store it separately
in a key.
Step3 - Now, compare the key with all elements in the
sorted array.
Step 4 - If the element in the sorted array is smaller
than the current element, then move to the next
element. Else, shift greater elements in the array
towards the right.
Step 5 - Insert the value.
Step 6 - Repeat until the array is sorted.
20XX Pitch deck title 10
MERGE SORT

WHAT IS MERGE SORT?


Merge sort is similar to the quick sort algorithm
as it uses the divide and conquer approach to
sort the elements. It is one of the most popular
and efficient sorting algorithm. It divides the
given list into two equal halves, calls itself for
the two halves and then merges the two sorted
halves. We have to define the merge() function
to perform the merging.
SUMMARY

You might also like