Which one is faster?
A binary search of an orderd set of elements in an array
or
a sequential search of the elements.

Answer Posted / ujjwal dave

binary search is faster and more useful in case we need to
perform search a number of times, complexity of sequential
search will be n each time where in binary search will take
more time only at first time when data is not sorted once
the data is sorted......it will take only only log n
attempts to search each element.......so the decision also
depends on frequency of the data beign searched

Is This Answer Correct ?    6 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Does arraylist guarantee insertion order?

505


How to excel in data structures and algorithms?

539


Which interface provides the capability to store objects using a key-value pair?

581


Is tuple immutable?

462


Can we insert null in hashset?

519






If you are using c language to implement the heterogeneous linked list, explain what pointer type will you use?

622


What does args stand for?

465


Which sorting algorithm is the slowest?

473


Write a Program for Insert in a sorted list

511


Will it create any problem if we add elements with key as user defined object into the treemap?

527


What is an algorithm in coding?

431


How does a treemap sort?

435


Which is the simplest file structure? (a) Sequential (b) Indexed (c) Random (a) Sequential

715


Why is an array homogeneous?

473


Can we remove element from arraylist while iterating?

507