#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

#### Categories

Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

# Sequential Search / Linear Search

2»

• Posts: 209Member
: Binary search is just an algorithm. You can use it on any datastructure you like, as long as the structure is sorted on the key you search for.
: Don't think that arrays and search-algorithms are closely related.
:
: If your two-dimensional array is sorted, sure you can do binary search on it. It is just a way to find something in a collection of somethings.
:
: For an explanation of binary search, suppose you want to find the name 'Johnson' in a phone-book of 1,000 pages by hand.
: You would open the book somewhere in the middle. You will see immediately if you need to go back- or forward, thus reducing the candidates by 50%.
: You continue like that. If you do a perfect search and go to the exact middle always, you will see no more than 10 pages before you find the name.
:
: Greets,
: Eric Goldstein
: http://www.gvh-maatwerk.nl
:
:
:

OK, I think as you said I was confused about the search-algorithm and array or other insertion method.

So then [b]size 6[/b] (for example) for the one-dimentional array simply is,

[b]array[0][1][2][3][4][5][/b]

Then the [b]size 6[/b] for the two dimentional array should simply,

[b]array[0][0], [0][1], [1][0], [1][1], [2][0], [2][1][/b]

or something similer...

and to search either the array in binary way is not the big difference in fact I think the same.