[OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Pablo Jose Alvarez wrote:my question is then...do good programmers really need to be able to design what in my opinion, is a very complicated algorithm? Meaning, in real life applications, do people really program like that?
Pablo Jose Alvarez wrote:I find the logic of the second set of nested loops (after the "bubble" comment)really weird and complicated. Now, I know there are many other ways to sort arrays in java...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
I can think of several other ways to write those three linesYou don't need to know how the exchange method works. Or the IntSwapper class. But those names may make it easier to understand what is happening inside that loop where you exchange the two values.Pablo Jose Alvarez and Others wrote: . . .
. . .
Pablo Jose Alvarez wrote:...I did this with every single iteration and the end result was a nicely sorted array!!!
Looking at it this way, the algorithm is indeed simple and very clever too...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |