Java Algorithm. PLEASE HELP!!!
I have the code completed, just need help with the algorithm (flowchart)
public class Chpt7_Project { public static void main(String[] args) { int[] a=new int[10]; int b; for(int i=0; i < 10 ; i++) { b=(int)(Math.random()*100+1); //Generate 10 random integer numbers between 1 and 100, //System.out.print("Random Number ["+ (i+1) + "] : " +b ); a[i]=b; } System.out.print("unsorted list is: "); for(int j=0; j < 10 ; j++) System.out.print(a[j] + " "); bubbleSort(a); System.out.print("\nsorted list is: "); for(int q=0; q < 10 ; q++) System.out.print(a[q] + " "); } private static void bubbleSort(int[] a) { int temp; for (int k = a.length - 1; k > 0; k--) { for (int p = 0; p < k; p++) { if (a[p] > a[p + 1]) { temp = a[p]; a[p] = a[p + 1]; a[p + 1] = temp; } } } } }
you post a code with no comments or a description explaining what you want to achieve?
what??
So you want to make a flowchart? With the 4 symbols right?
yes! @mhchen
okay that's quite a bit of code so let me read it real quick
okay! Thanks
I'm gonna be using www.draw.io btw.
ive never used that before
It's okay. I'll screenshot it or share with google drive once I'm done.
okay the code looks right
i know the code is, just need help with the algorithm
it should look something like this
thats not exactly what ur doing just a sample, if u have some flowchat uve already made i can look to see what ur missing
hang on I'm almost done
nad just shhhh
okay but you should let her do it, I know its fun to just make them ourselves but =.=
I wonder what happens if I share an 'editable' thing on google drive xD
if we do this for her now, she will never know the JOY, do you want to deprive her of THE PURE JOY OF FLOW CHARTING
Lol
.-. I hate flowcharting
can either help me or no?
Actually I don't trust you nad.
just take a screenshot
:b, Yumi check pms.
Thank You!
Of course I'm probably not guaranteed to be right, cuz that loop thing was weird.
if u take a screenshot.. i can check it -_-
Actually @518nad do you want to check my work....wow you JUST typed that
https://drive.google.com/a/uaschools.org/file/d/0B0V8TNPLTUd4YmdOVVI0REJOcU0/view?usp=sharing Here I'll make it public
Waiting for chaos to happen.
idk how to use that
You can't view it?
do u have lightshot/
or take a screenshot and attach file
i mean, i dont knowhow to use that google drive thing
I'll attach it.
thankyou -_-
I just realized...why did I waste my time writing the flowchart from my knowledge when I coulda searched 'bubble sort flowchart' online.
ah no this chart is a bit too vague
it should be a bit more technical
So you want the actual lines of code in?
no u can actually follow her logic exactly in the flow chart
:3 yep. That's for Yumi to do.
she has to implement both for loops properly
oh okay thats fine then I thought u were doing the whole thing for her
its my first semester, i just needed help
thanks tho
ive done algorithms for past assignments, just this one had me very confused
okay ill show u the bubblesort part for the 2 for loops
for (int k = a.length - 1; k > 0; k--) { for (int p = 0; p < k; p++) { if (a[p] > a[p + 1]) { temp = a[p]; a[p] = a[p + 1]; a[p + 1] = temp;
?
thanks anyway
umm a little patience please?
Join our real-time social learning platform and learn together with your friends!