Wednesday, 20 September 2017

Java Algorithms Linear Search

A linear search traverse down a list, one item at a time, without jumping.
public String linearSearchForValue(int value) { String indexesWithValue = ""; for (int i = 0; i < size; i++) { if (theArray[i] == value) { indexesWithValue += i + " ,"; } } return indexesWithValue; }

No comments:

Post a Comment

Search This Blog

Contact us

Name

Email *

Message *