Menu
support@authoritypapers.com
+1(805) 568 7317

using c and showing a output window rewrite the linear search function in listing 7 5189433

Using c++ and showing a output window Rewrite the linear search function in Listing 7.9, LinearSearch.cpp, to use a generic type for array elements. Test the function with array of int, double, and string values.

7.9

1 int binarysearch(cons tint list[], int key, int listsize)

2 {

3 int low = 0;

4 int high = listsize – 1;

5

6 while (high >= low)

7 {

8 int mid = (low + high) / 2;

9 if (key

10 high = mid – 1;

11 else if (key == list[mid])

12 return mid;

13 else

14      low = mid + 1;

15 }

16

17 return – low -1;

18 }

"Order a similar paper and get 15% discount on your first order with us
Use the following coupon
"GET15"

Order Now