ChatterBank2 mins ago
Consider The Problem Of Searching For A Particular Entry In A Large But Sorted Database. Which Algorithm Would Be Preferable?
i. Sequential Search
ii. Binary Search
iii. Both the above would be equally preferable
ii. Binary Search
iii. Both the above would be equally preferable
Answers
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.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.
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.
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.
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.
////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.
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.
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.