We study complexity of finding a local minimum in the worst and the average cases. We introduce several neighborhoods and show that the corresponding. In the average case we note that standard local descent algorithm is polynomial.
INTRODUCTION:
An algorithm is a set of instructions to be followed to solve a problem Worst, Average and Best Cases
In the previous post, we discussed how asymptotic analysis overcomes the problems of naive way of analyzing algorithms. In this post, we will take an example of Linear Search and analyze it using asymptotic analysis.
We can have three cases to analyze an algorithm: 1) Worst Case 2) Average Case 3) Best Case
WORST CASE ANALYSIS (USUALLY DONE):
In the worst case analysis, we calculate upper bound on running time of an algorithm. We must know the case that causes maximum number of operations to be executed. For Linear Search, the worst case happens when the element to be searched (x in the above code) is not present in the array. When x is not present, the search () functions compares it with all the elements of arr [] one by one. Therefore, the worst case time complexity of linear search would be.
AVERAGE CASE ANALYSIS (SOMETIMES DONE): In average case analysis, we take all possible inputs and calculate computing time for all of the inputs. Sum all the calculated values and divide the sum by total number of inputs. We must know (or predict) distribution of cases. For the linear search problem, let us assume that all cases are uniformly distributed (including the case of x not being present in array). So we sum all the cases and divide the sum by (n+1). Following is the value of average case time complexity.
BEST CASE ANALYSIS (BOGUS): In the best case analysis, we calculate lower bound on running time of an algorithm. We must know the case that causes minimum number of operations to be executed. In the linear search problem, the best case occurs when x is