Send the link below via email or IMCopy
Present to your audienceStart remote presentation
- Invited audience members will follow you as you navigate and present
- People invited to a presentation do not need a Prezi account
- This link expires 10 minutes after you close the presentation
- A maximum of 30 users can follow your presentation
- Learn more about this feature in our knowledge base article
Do you really want to delete this prezi?
Neither you, nor the coeditors you shared it with will be able to recover it again.
Make your likes visible on Facebook?
Connect your Facebook account to Prezi and let your likes appear on your timeline.
You can change this under Settings & Account at any time.
Bubble sort - Group 1
Transcript of Bubble sort - Group 1
*Code for integer.
*Code for String (On Borland).
Big O Notation.
code for integer
printf("Enter no of elements :");
printf("Enter array elements :");
What is Bubble Sort ?!
It is a simple sorting algorithm that works by repeatedly stepping through the list to be sorted ..
By comparing each pair of elements and switching their positions if necessary. This process is repeated as many times as necessary. until the elements is sorted.
The bubble sort gets its name from elements moving up into the correct order like bubbles rising to the surface.
bubble sort pseudo code
code for string
( int a, int n)
i = 1 to n-1
sorted = true
j = 0 to n-i-1
if a[j] > a[j+1]
temp = a[j]
a[j] = a[j+1]
a[j+1] = temp
sorted = false
break from i loop
An algorithm is a sequence of well-defined steps to be followed to solve a problem .
What is An Algorithm ?
*The Big-O notation is Commonly used to represent asymptotic upper bounds. It describes relevant time or space complexity of algorithms(memory usage of an algorithm).
* Big-O analysis provides a simplified estimate of a problem difficulty.
*Usually describes the worst-case running time of algorithm .
The Big-O Notation
bubble_sort(int a , int n)
int I ,j ,k ,temp, flag=1;
for(i=0 ; i<n ; i++)
for(j=0 ; j<n-i-1 ; j++)
Bubble Sort (Big-O)
*It is possible to compare of two algorithms with running times
Running Times of Algorithm A and B
TA(N) = 1000 N = O(N)
TB(N) = N2 = O(N2)
A is asymptotically faster than B !
*Constants can be ignored.
-Units are not important
O(7n2) = O(n2)
*Lower order terms are ignored
-O(n3+7n2+3) = O(n3)
Advantages of O Notation