Posts

Showing posts from July, 2023

Complexity Calculation - Frequency Count Method

Frequency Count Method The frequency count method is a simple approach used in algorithm analysis to estimate the time complexity of an algorithm. It involves counting the number of basic operations performed by the algorithm as a function of the input size. The basic operations could be simple arithmetic operations, assignments, comparisons, etc.It involves counting the number of times each basic statement in the algorithm is executed, and then multiplying this count by the time it takes to execute each statement. The total time complexity of the algorithm is then the sum of the time complexities of all of its basic statements. Let's break down the frequency count method with an example: Linear search an element x on array arr of size n int LinearSearch(int arr[], int n,int  x)     for( i=0; i<n-1:;i++)          if (arr[i]==x)             return i     return -1 Assignment Operations: i = 0 (1 assignment operation) i++ (n times, where n is the size of the array) Comparison Oper