Search:

Type: Posts; User: Junky

Search: Search took 0.29 seconds.

  1. Replies
    7
    Views
    1,400

    Re: Sorting and Searching: Most Efficient Code

    Imagine you have an array with 1000 numbers in it: 1, 3, 4, 5, etc. Then you attempt to search for 2. When you get to 3 (the second element) you know that 2 is not in the array. However your code...
  2. Replies
    7
    Views
    1,400

    Re: Sorting and Searching: Most Efficient Code

    That still does not address my second point.
  3. Replies
    7
    Views
    1,400

    Re: Sorting and Searching: Most Efficient Code

    That has addressed my first point but not my second point.
  4. Replies
    7
    Views
    1,400

    Re: Sorting and Searching: Most Efficient Code

    Make the inner if statement the first thing the code does in the loop. Why do anything else when you have found the number?

    Stop searching as soon as the value in the array is larger than the...
Results 1 to 4 of 4