[VIEWED 5978
TIMES]
|
SAVE! for ease of future access.
|
|
|
zeePa
Please log in to subscribe to zeePa's postings.
Posted on 10-29-08 7:14
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
2
?
Liked by
|
|
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
Please log in to subscribe to sathi_mero's postings.
Posted on 10-29-08 7:39
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
2
?
Liked by
|
|
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
Please log in to subscribe to nepali_geek's postings.
Posted on 10-29-08 8:06
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
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
Please log in to subscribe to ice_cop123's postings.
Posted on 10-29-08 8:30
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
2
?
Liked by
|
|
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
Please log in to subscribe to techGuy's postings.
Posted on 10-29-08 9:05
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
1
?
Liked by
|
|
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
Please log in to subscribe to zeePa's postings.
Posted on 10-29-08 9:33
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
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
Please log in to subscribe to nepali_geek's postings.
Posted on 10-29-08 10:42
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
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
Please log in to subscribe to vname's postings.
Posted on 10-30-08 12:23
AM
Reply
[Subscribe]
|
Login in to Rate this Post:
1
?
Liked by
|
|
Asking questions is not plagiarism.Copying from someone else is.
|
|
|
yellow
Please log in to subscribe to yellow's postings.
Posted on 10-30-08 9:47
AM
Reply
[Subscribe]
|
Login in to Rate this Post:
1
?
Liked by
|
|
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
Please log in to subscribe to CHOR's postings.
Posted on 10-30-08 4:19
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
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
Please log in to subscribe to micky_mouse's postings.
Posted on 10-31-08 9:12
AM
Reply
[Subscribe]
|
Login in to Rate this Post:
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
Please log in to subscribe to the_hareeb's postings.
Posted on 10-31-08 12:03
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
this dude is too lazy lol
|
|