Donate SIGN UP

Consider The Problem Of Searching For A Particular Entry In A Large But Sorted Database. Which Algorithm Would Be Preferable?

Avatar Image
Hanna1 | 20:45 Thu 26th Jul 2018 | Science
17 Answers
i. Sequential Search

ii. Binary Search

iii. Both the above would be equally preferable
Gravatar

Answers

1 to 17 of 17rss feed

Best Answer

No best answer has yet been selected by Hanna1. Once a best answer has been selected, it will be shown here.

For more on marking an answer as the "Best Answer", please visit our FAQ.
Someone will probably answer, but we don't generally do homework on here; better to attempt it yourself and learn from your mistakes if you get it wrong.
ii
The answer depends on how much data you are talking about.

If you are talking about a dataset which comprised 10s of items, a sequential search would be fine. If you are talking about one which has hundreds or a few thousand items, a binary search is more efficient.

There is a third option, which would only be used on really massive datasets and which I never needed to make use of when I was programming. That's a hybrid search, which combines two (or more) types of search into a single algorithm. Sorry, I can't tell you much about it, because I never needed to code one.

The OPer is taking a little break from AB atm.
a shame anyone can be suspended for asking homework questions on a question and answer site. As valid as any other questions, imho, and nobody has to answer them if they don't want to.
Agreed Jno, this is a Q&A site, unless the poster is a troll or a spammer they should be entitled to ask this question.
Suspending seems a wee bit harsh doesn't it? Nothing to indicate it's going to be followed by a link to an absolutely tip-top website with just what the doctor ordered...
Which site rule has this poster violated?
Definitely a binary search as it's a sorted file (often known as a binary chop).
I was pretty sure the OPer had posted homework questions before, but looking at her/his details, I see not. Still suspension does seem a bit stiff for homework questions, especially given the nature of this particular question.
Perhaps it's because this poster has fielded three computer questions tonight that he's been suspended.


Don't get many hes called Hanna, not down here anyway.
A lot of the questions in the sub-sections of Home and Garden are homework questions.
Canary, binary search is not always the most efficient in terms of speed. It's great for large datasets but for very small ones a sequential search is as good if not better and is simpler to write.

The OPer did slip up, though, by mentioning a database. Unless the definition has changed in the last 15 years, databases use indexes and pointers to let you find data, so a search using any of the three options listed would be kind of silly.
In reality, databases have tree-like indexes which are something else again.
////great for large datasets////

The question refers to a LARGE database

//// did slip up, though, by mentioning a database.////

I thought that a bit odd - the references appeared to refer to a standard serial file. Any decent database management system should be able to locate a database entry via links/pointers. As you state, it would be silly using any of the options given.
Just checked Hanna1's profile.She is shown as active.

1 to 17 of 17rss feed

Do you know the answer?

Consider The Problem Of Searching For A Particular Entry In A Large But Sorted Database. Which Algorithm Would Be Preferable?

Answer Question >>

Related Questions

Sorry, we can't find any related questions. Try using the search bar at the top of the page to search for some keywords, or choose a topic and submit your own question.