Help me techguy/(& techgirl if he has one!) - Sajha Mobile
SAJHA MOBILE
Help me techguy/(& techgirl if he has one!)
Posts 12 · Viewed 5119 · Go to Last Post
zeePa
· Snapshot
Like · Likedby · 2

Write a program that implements a method that receives an array parameter and sorts that array using the bubble-sort algorithm. The bubble-sort algorithm makes several passes through the array. On each pass, successive neighboring pairs are compared. If a pair is in decreasing order, its values are swapped: otherwise, the values remain unchanged. The technique is called a bubble sort because the smaller values gradually "bubble" their way to the top.

USE THIS ALGORITHM:

boolean changed;

do{

  changed = false;

  for(int i = 0; i < list.length - 1; i++){

    if(list[i] > list[i + 1]){ 

      swap list[i] with list[i + 1];
      changed = true; 
    }

  }
}while(changed

sathi_mero
· Snapshot
Like · Liked by · 2
ha ha ha.. this is freaking crap.... no one's going to write a whole code for you... you should practice it yourself and post the lines of codes where you get error... If you keep on posting your problems in the blogs and someone posts the codes then when you'll learn to code yourself? Do, some research dude, read some books, follow programming basics and finally you'll be able to generate the codes by yourself...
nepali_geek
· Snapshot
Like · Liked by · 0
Seriously? You can't even code a simple bubble sort algorithm?

I am sorry to be so critical of you zeepa but I think programming is not for you.
ice_cop123
· Snapshot
Like · Liked by · 2
is that your assignment given by your professor...if so..its better to get help from your professor ....we are here to learn...not to plagiarize...
techGuy
· Snapshot
Like · Liked by · 1

You have already done everything, where r u stuck...about that swap logic?

well here is how it works,

suppose you have oil on bucket A

A=oil

 and water in bucket B

B=water

, now you got to transfer oil to B and water to A,

final result B=oil, A=water

 how will you do it?

Take another empty bucket C.

Put oil from A to C

C=A; (well in  real world bucket A will get empty, but in programming,  A and C both will have oil, ignore  that and think this is real world)

Then,

Put the content of B(water) to A, so A contains water

A=B;

then put the content of C(oil)  to B, so B contains Oil

B=C

This is how swap works.

For your problem

temp=list(i);

list(i)=list(i+1);

list(i+1)=temp;

Hope that explains .

 Post your code, if therez logical or syntax error we can point it out. Java or C or C++?

zeePa
· Snapshot
Like · Liked by · 0

Thanks techguy! BTW, its java.

This was specifically for you. Others talked about plagiarism and shit like that. I tell u , except techguy, what!

Fear of Plagiarism shouldn't hinder sharing of knowledge. Knowledge is open surce and free!

Techguy knows what i am talking about!

But guys, I am cool with your suggestions too..

thanks anyways.

nepali_geek
· Snapshot
Like · Liked by · 0
Plagiarism not only hinders sharing of knowledge but is the lowest you can go. I mean it is good to have a genuine desire to learn but blatant plagiarism and copying isn't the right way.

However I do like Techguy's style of analysis and I hope that it helped you. Good luck.
vname
· Snapshot
Like · Liked by · 1
Asking questions is not plagiarism.Copying from someone else is.
yellow
· Snapshot
Like · Liked by · 1
Over the last few threads, I am kind of amazed with people bashing someone asking for help. And People who are asking for help are asking for the whole code... #include ... to return blah.

I think you are doing java, and it is a good question, how to pass array to a function. As java does not use pointers like C++.

Zeepa, you seem to have already done the hard part, so whats going  on ? make a function, like the question says passs an argument ( array). .

String myArray == new array[20];
// put your values into myArray in each elements.

public string  myArrayFunction( myArray) {

 type that code... you found or did.

return myArray; // which at this point is already sorted.
}

Last edited: 30-Oct-08 09:52 AM
CHOR
· Snapshot
Like · Liked by · 0
I saw kudos to Techie bro and yellow.. the poster is trying to learn, what the hell yaar.. if you don't' want to help than don't' ridicule the poor chap..

Maybe he doesn't' want to be a programmer, he has to take programming class to get his degree... what is wrong with cheating and passing if you are not going to use it ever in your life...>???

so most of you guy's here are trying to tell us, you guys are geniuses..
a learned man will never make fun of a person who has less knowledge than them,., that only shows how intelligent you are..
micky_mouse
· Snapshot
Like · Liked by · 0

Test it. I may be wrong. I did not test it.

/// Routine sorts the array that holds integer values. Make sure list[i] returns integer but NOT string or object or double or any

//boolean changed; not needed
//changed = false; not needed
int temp = 0;

  for(int i = 0; i < list.length - 1; i++){

    //initialize the temp varaible for every spin
    temp = 0;

    //Swap it only if first value is greater than next value
    if(list[i] > list[i + 1]){ 
    temp = list[i];

    list[i] = list[i+1];

    list[i+1] = temp;

    //swap list[i] with list[i + 1]; 
    // changed = true; not needed
    }

  }

the_hareeb
· Snapshot
Like · Liked by · 0
this dude is too lazy lol
Please log in to reply to this post

You can also log in using your Facebook
View in Desktop
What people are reading
You might like these other discussions...
· Posts 2 · Viewed 106
· Posts 5 · Viewed 579 · Likes 1
· Posts 1 · Viewed 83
· Posts 1 · Viewed 85
· Posts 1 · Viewed 71
· Posts 1 · Viewed 65
· Posts 8 · Viewed 802
· Posts 2 · Viewed 605 · Likes 2
· Posts 5 · Viewed 497
· Posts 1 · Viewed 112



Your Banner Here
Travel Partners
Travel House Nepal