Answer: </I>Just as qsort() was the easiest sorting method, because it is part of the standard library, bsearch() is the easiest searching method to use. If the given array is in the sorted order bsearch() is the best method. Following is the prototype for bsearch(): void *bsearch(const void *key, const void *buf, size_t num, size_t size, int (*comp)(const void *, const void*)); Another simple searching method is a linear search. A linear search is not as fast as bsearch() for searching among a large number of items, but it is adequate for many purposes. A linear search might be the only method available, if the data isn't sorted or can't be accessed randomly. A linear search starts at the beginning and sequentially compares the key to each element in the data set.
Tags:Interview Questions, Languages, C,
Please submit your Interview Answer for the above Question via replying to this post. Thank you for visiting to our blog, Have a Good Day!.
Sponsor Advertisement
Library Management System Software
Our Library Management Softare offers complete library management modules and automation solution that enables information providers, information managers, resource incharge, resource managers & librarians to manage & disseminate information & resources....
No comments:
Post a Comment