Pages

Showing posts with label bubble. Show all posts
Showing posts with label bubble. Show all posts

Monday, April 14, 2014

Bubble sort algorithm with time complexity calculation


//Bubble sort algorithm implementation. Also calculate time complexity.
#include<stdio.h>
#include<conio.h>
void main()
{
 int a[100],temp,i,j,n,count;
 count=0;count++;
 printf("Bubble Sort
Enter total no. of values: ");

 {
  scanf("%d",&n);
  count++;
 }
 printf("Enter the values:-
");

 for(i=0;i<n;i++)
 {
  scanf("%d",&a[i]);
  count++;
 }
 for(i=0;i<n;i++)
 {
  for(j=i;j<n;j++)
  {
   if(a[j]<a[i])
   {
    temp=a[j];count++;
    a[j]=a[i];count++;
    a[i]=temp;count++;
   }
   count++;
  }
  count++;
 }
 printf("Bubble-Sort result:-
");

 for(i=0;i<n;i++)
 {
  printf("%d ",a[i]);
  count++;
 }
 printf("
Time Complexity is: %d",count);

 getch();
}
//program written by Mars.
Read More..

Wednesday, March 26, 2014

Bubble Shooter

Bubble Shooter is a very simple Marble Popper type game. It has no fancy graphics but its fun and addictive. It is a great choice to play this little game online if you feel bored at work or at home. It is small in size and you dont need to wait a long time to load the game. Your task in this game is to clear the balls from the board by shooting at them with like-colored balls. You just need to use your mouse to aim and shoot. It is simple, fun, and addictive. Click here to play Bubble Shooter game online for free.
Read More..