Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

(Note: there are more efficient ways of writing this method, but I wanted to show you several features at once)

Wiki MarkupA vararg parameter comes in as an array, so one can figure out how many parameters were supplied (params.length) and one can access each supplied value using regular array syntax, e.g. params\[i\]. \\

The following are all valid calls to the above method:

...

Consider the following sorted array of values:

Wiki Markup{{\[1, 2, 4, 7, 10, 11, 12, 13, 20, 25, 27, 28, 30\]}}

Supposed you're give a value, x, what's the fastest way to either find that value in the array or determine if it is not present?

...

No Format
                    12
                /        \
             7               25
          /     \         /     \
        2        10     13        28
      /  \          \      \     /  \
     1    4          11     20  27   30

It is a very useful notion to conceptually view an array as a tree.   This enables one to leverage the power of recursive data structures with the speed and compactness of an array.

===================================================================================================================

...

 Inserting a node into a doubly-linked list, ala BiList, isn't difficult, but it does take care to make sure that one has the right values for the node references at any given moment.    Here's a pictoral explanation of the process: