How can i calculate one single step for linear and binarysearch?
Here is my code
long STime1 = System.nanoTime();
LinearSearch(array, a);
long ETime1 = System.nanoTime();
TotalTimeL2=TotalTimeL2 + (ETime1 – STime1);
System.out.println(“Worst-case of linearsearch running time (n =10^5) is “+TotalTimeL2+” nano seconds”);
long STime2 = System.nanoTime();
BinarySearch(array, a);
long ETime2 = System.nanoTime();
TotalTimeB2 = (TotalTimeB2 + (ETime2 – STime2))/n;
System.out.println(“One single step for linearsearch: “+((TotalTimeL2 *Math.pow(10, -9))/tenfive+ “seconds” ));
System.out.println(“One single step for binarysearch:”+(TotalTimeB2 * Math.pow(10, -9) / (Math.log(tenfive)/Math.log(2))+ ” seconds” ));
Expert Answer
An answer will be send to you shortly. . . . .