Skip to main content

Bubble sort

Term Project

Choose a problem from the topics below or other topics and design two different algorithms for this problem. For each algorithm, write a parallel program. Students will be asked to present their problem description, algorithm(s) employed, program description, and performance plots to the class using 5-10 minutes.


Submit the following: A 3-5 page single-spaced project report (hard copy) containing the following sections:

1.      Problem:
Bubble Sort


2.      chosen algorithms

BUBBLE SORT

·         procedure bubbleSort( A : list of sortable items )
n = length(A)

for i = 1 to  n-1 inclusive do

for j=1to n-2 inclusive do

if A[j] > A[j+1] then
swap( A[i-1], A[i] )

end if
end for
end for

end procedure

#include<stdio.h>
#include<conio.h>
void main()
{
long int i,j,tmp,a[10];
for(i=0;i<n;i++)
printf("enter nos.\n");

for(i=0;i<10;i++)
scanf("%ld",&a[i]);

for(i=0;i<10;i++)
{
for(j=0;j<9;j++)
if(a[j]>a[j+1])
{
tmp=a[j];
a[j]=a[j+1];
a[j+1]=tmp;
}
}
printf("sorted array is -->\n");
for( i=0;i<10;i++)
printf("%ld\n",a[i]);
getch();
}

·         procedure bubbleSort( A : list of sortable items )
n = length(A)
repeat
swapped = false
for i = 1 to n-1 inclusive do
if A[i-1] > A[i] then
swap(A[i-1], A[i])
swapped = true
end if
end for
n = n - 1
until not swapped
end procedure

#include<stdio.h>
#include<conio.h>
void main()
{
long int i,j,tmp,a[10],f=0;
for(i=0;i<n;i++)
printf("enter nos.\n");

for(i=0;i<10;i++)
scanf("%ld",&a[i]);


do
{
f=0;
for(j=0;j<9;j++)
if(a[j]>a[j+1])
{
f=1;
tmp=a[j];
a[j]=a[j+1];
a[j+1]=tmp;
}
}while(f==0);

printf("sorted array is -->\n");
for( i=0;i<10;i++)
printf("%ld\n",a[i]);
getch();
}


3.      associated data structures,

array is used of size n
long int variables are used

4.      underlying communication pattern


5.      parallel time complexity for each implementation


6. performance of each program with reference to the plots for (a) execution time and for (b) speedup as number of processes varies, and

7. your conclusions containing your interpretation of the performance of these programs, their limitations, and possible future improvements.



Comments

Popular posts from this blog

PROGRAM TO PRINT COLOURS OF RAINBOW ACCORDING TO THE NO. INPUTTED BY THE USER

#include,stdio.h> #include<conio.h> void main() { int ch; printf("INPUT A NUMBER\n"); scanf("%d",&ch); switch(ch) { case 6: printf("Red"); break; case 5 : printf(" Orange"); break; case 4 : printf(" Yellow"); break; case 3 : printf(" Green"); break; case 2 : printf(" Blue"); break; case 1 : printf(" Indigo"); break; case 0 : printf(" Violet"); break; default : ("wrong input "); } } SIMPLE PROGRAMS FIND TYPE OF THE TRIANGLE TEMPERATURE CONVERSION COMMISSION OF A SALESMAN PRINT NUMBERS IN DESCENDING ORDER BIGGEST NUMBER AMONG THREE NUMBERS CALCULATE DIVISION A YEAR IS LEAP OR NOT A NUMBER IS ODD OR EVEN PRINT THE SQUARE ROOT ELSE PRINT N TO THE POWER 5 PRINT A NEW NUMBER BY ADDING 1 TO EACH DIGIT OF THE NUMBER PRINT THE NO. OF CURRENCY NOTES ACCORDING TO THE AMOUNT ENTERED DATA STRUCTURES ENTER DETAILS OF A STUDENT ENTER DETAILS OF A ST...

unix commands

 

Baby doge paws

Baby doge paws link 🎉 Join the BabyDoge PAWS Clicker adventure! Solve challenges, join daily events, and invite friends. Stay tuned for the token airdrop! 🐾 🌟 Earn 10k PAWS as a welcome bonus 🌟 Get 25k PAWS with Telegram Premium https://t.me/BabyDogePAWS_Bot?start=r_6394860582