Counting the number of comparisons in an array to find a value

  • (2 Pages)
  • +
  • 1
  • 2

15 Replies - 984 Views - Last Post: 07 June 2011 - 04:17 PM Rate Topic: -----

#16 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5846
  • View blog
  • Posts: 12,705
  • Joined: 16-October 07

Re: Counting the number of comparisons in an array to find a value

Posted 07 June 2011 - 04:17 PM

View PostNickDMax, on 07 June 2011 - 05:50 PM, said:

By my reckoning you example would get the wrong count.


This is why I said my way was more interesting. ;)

Yeah, the count is correct. It relies on the fact the code always gets to the bottom of the block if it does the second comparison. I think doing the count outside of the compare is more of a programmer style challenge.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2