Jump to content

Sequential search, last occurrence

- - - - -

  • Please log in to reply
2 replies to this topic

#1
bloodchains

bloodchains

    Learning Programmer

  • Members
  • PipPipPip
  • 73 posts
I have to make a sequential search method where I have to find the last occurrence of an item. I just want to make sure, it basically means I'll just have to start the search from the end of an array, right?

#2
lethalwire

lethalwire

    while(false){ ... }

  • Members
  • PipPipPipPipPipPipPip
  • 748 posts
  • Programming Language:Java, PHP
  • Learning:Java, PHP
You can start a sequential search from the beginning or the end.
In your case, it is more efficient to start at the end of the array though.

So yes, I'd start the search from the end of the array.

#3
bloodchains

bloodchains

    Learning Programmer

  • Members
  • PipPipPip
  • 73 posts
Yes, that's what I thought. Thanks for confirming. ^^




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users