Write a program that has array of at least 20 integers. It should call a function that uses the linear search algorithm to locate one of the values. The function should keep a count of the number of comparisons it makes until it finds the value. The program then should call a function the uses the binary search algorithm to locate the same value. It shoulf also keep count of the number of comparsions it makes. Display these on the screen.

And your question is?
I can tell you straight from the beginning: We don't solve homeworks, but we can help.
Liniar search algorithm, this is the pseudocode:

number_of_times<-0
i<-0
intput<-given input
while input!=array[i] do
    number_of_times++
    i++
end_while
if number_of_times=20 then
    print element not found
end_if

It's not that hard to do these things. Search on the internet or in your course book how to do things, try to do something, and then, if you have problems post them here.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.