0% found this document useful (0 votes)
6 views

Sorting Algorithms Some Info

The document provides an overview of sorting algorithms, highlighting characteristics such as stability, in-place sorting, internal sorting, and adaptability. It includes procedures for bubble sort and modified bubble sort, detailing their implementation. The modified bubble sort introduces a flag to optimize performance by breaking early if no swaps occur.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Sorting Algorithms Some Info

The document provides an overview of sorting algorithms, highlighting characteristics such as stability, in-place sorting, internal sorting, and adaptability. It includes procedures for bubble sort and modified bubble sort, detailing their implementation. The modified bubble sort introduces a flag to optimize performance by breaking early if no swaps occur.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Information on Sorting algorithms

1. Stable: Equal keys aren’t reordered


2. In place: Requires only one extra space
3. Internal Sorting: Data to be sorted are placed in the main memory
4. Adaptive: Takes advantage of pre-existing order in the data to improve
performance.

procedure bubbleSort(arr)
for i=0 to n-1
for j=0 to n-i-1
if arr[j] > arr[j+1]
Swap arr[j] and arr[j+1]
end if
end for
end for
end procedure

procedure modifiedBubbleSort(arr)
flag = true
for i= 0 to n-1 do
for j=0 to n-i-1
if arr[j] > arr[j+1]
Swap arr[j] and arr[j+1]
flag = false
if flag is true
break
end if
end for
end for
end procedure

You might also like