> There are several ways of doing this. What have you come up with so far?
Why bother with the Socratic method? Hoping to actually teach the OP something? There are enough forum members that someone soon comes along to post a complete solution, specially when dukes are involved. <sigh/>
> I link to the javadocs can't be too bad. [url
> http://java.sun.com/j2se/1.5.0/docs/api/java/util/Coll
> ections.html#reverse(java.util.List)]Collections.rever
> se(List)[/url]
Of course I fortell the next question, but I want an Array not a List? So I provide the next link: [url http://java.sun.com/j2se/1.5.0/docs/api/java/util/Arrays.html#asList(T...)]Arrays.asList(T...)[/url]
> > I link to the javadocs can't be too bad. [url
> >
> http://java.sun.com/j2se/1.5.0/docs/api/java/util/Coll
>
> >
> ections.html#reverse(java.util.List)]Collections.rever
>
> > se(List)[/url]
>
> Of course I fortell the next question, but I want an
> Array not a List? So I provide the next link: [url
> http://java.sun.com/j2se/1.5.0/docs/api/java/util/Arra
> ys.html#asList(T...)]Arrays.asList(T...)[/url]
The next question. But the results need to be an Array. So once more. Another link: [url http://java.sun.com/j2se/1.5.0/docs/api/java/util/Collection.html#toArray()]Collection.toArray()[/url]
> > I link to the javadocs can't be too bad. [url
> >
> http://java.sun.com/j2se/1.5.0/docs/api/java/util/Coll
>
> >
> ections.html#reverse(java.util.List)]Collections.rever
>
> > se(List)[/url]
>
> Of course I fortell the next question, but I want an
> Array not a List? So I provide the next link: [url
> http://java.sun.com/j2se/1.5.0/docs/api/java/util/Arra
> ys.html#asList(T...)]Arrays.asList(T...)[/url]
Yeah but then you have to worry about the next question which is more of a statement: "I can't use Arrays".
> > > I link to the javadocs can't be too bad. [url
> > >
> >
> http://java.sun.com/j2se/1.5.0/docs/api/java/util/Coll
>
> >
> > >
> >
> ections.html#reverse(java.util.List)]Collections.rever
>
> >
> > > se(List)[/url]
> >
> > Of course I fortell the next question, but I want
> an
> > Array not a List? So I provide the next link:
> [url
> http://java.sun.com/j2se/1.5.0/docs/api/java/util/Arr
>
> > ys.html#asList(T...)]Arrays.asList(T...)[/url]
>
> Yeah but then you have to worry about the next
> question which is more of a statement: "I can't use
> Arrays".
Then I would as them: How would you do it in real life? Of course they could think a real world way of doing it. In that case, I'll give them an real life example.
Assumed List
1 2 3 4 5 6 7 8 9 10 11 12 13
Switch the first and the last elements
13 2 3 4 5 6 7 8 9 10 11 12 1
Then the second and second to the last
13 12 3 4 5 6 7 8 9 10 11 2 1
And repeat until your half way.
13 12 10 4 5 6 7 8 9 3 2 1
13 12 10 9 5 6 7 8 4 3 2 1
13 12 10 9 8 6 7 5 4 3 2 1
13 12 10 9 8 7 6 5 4 3 2 1
Done.
> Of course the next question. How do a repeat? and
> How do I swap?
>
> It just drives people to just give the solution.
Drives me to point them in the direction they need to head to learn themselves. If they choose not to pursue it then I have no sympathy for them. People who aren't looking to have their work done for them may not know where to find the information they need or what precisely to "Google" for. Give them that information and they'll either help themselves and come back with questions or they aren't worth the trouble.
> Then I would as them: How would you do it in real life?
This morning I wanted to reverse the order of 6 or 7 cereal boxes on a shelf. I grabbed them as a bunch (by squeezing them all together) and put them together on the kitchen table. Then I walked around to the other size of the table and grabbed them as a bunch again, but from behind and placed them back on the shelf, now in the reverse order.
Code please!
> > Then I would as them: How would you do it in real
> life?
>
> This morning I wanted to reverse the order of 6 or 7
> cereal boxes on a shelf. I grabbed them as a bunch
> (by squeezing them all together) and put them
> together on the kitchen table. Then I walked around
> to the other size of the table and grabbed them as a
> bunch again, but from behind and placed them back on
> the shelf, now in the reverse order.
>
> Code please!
As soon as I finish building my Quantum computer. I'll give you the code.
I posted the cereal example because I was thinking back on all the times Ive gotten those sorts of answers when trying to help people come up with algorithms. I remember one time I was tring to help someone do something simple -- find the max int in an array -- and I asked him how he would do it in real life. He said, "I would stare at the numbers until I knew the answer." Then he stared at me. Presumably he would have stared until I gave him the answer...
> > Then I would as them: How would you do it in real
> life?
>
> This morning I wanted to reverse the order of 6 or 7
> cereal boxes on a shelf. I grabbed them as a bunch
> (by squeezing them all together) and put them
> together on the kitchen table. Then I walked around
> to the other size of the table and grabbed them as a
> bunch again, but from behind and placed them back on
> the shelf, now in the reverse order.
>
> Code please!
Seriously. It is the same as the example I gave. Your example just does the number swapping as you turn around.It just does each number switch (cereal switch) gradually over the 180% turn. It is just a two dimensional example of the same process.