A problem that i cant find solution, someone help me..!

Often is presented the need of search of k keys in a sorted table of n elements. Draw and are analyze three algorithms of mass search, where that is the keys must search with one call of algorithm and no with successive k calls. The three algorithms must support in sequential search, the binary search and search of interjection.

2
Contributors
1
3
Views
9 Years
Discussion Span
Last Post by ddanbe

A problem that i cant find solution, someone help me..!

Let us say you have boxes with marbles in it and that they have been placed in such a way that the first box contains the least amount of marbles and sorted, the last box would contain the most marbles.
Now someone asks you : "Find the box with 14 marbles in it!".
What would you do?
sequential : start with the first box, open it, count the marbles, if the count equals 14 you have found the box, if not continue with the next box until the last box.
binary : Pick out the box in the middle, count the marbles, if the count equals 14 you have found the box, if not you know (depending on the count you found) that the box you are looking for must be in the higher part or the lower part of your row of boxes. Again pick a box from that part and look inside to count etc.
interjection search? never heard of.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.