- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Operation Counts Method in Algorithm

There are different methods to estimate the cost of some algorithm. One of them by using the operation count. We can estimate the time complexity of an algorithm by choosing one of different operations. These are like add, subtract etc. We have to check how many of these operations are done. The success of this method depends on our ability to identify the operations that contribute most of the time complexity.

Suppose we have an array, of size n [0 to n - 1]. Our algorithm will find the index of largest element. We can estimate the cost by counting number of comparison operation is performed between each pair of elements of the array. We have to remember that, we will choose only one operation. In this algorithm there are few more operations like increment of iteration variable i, or assign values for index etc. But they are not considered in this case.

## Algorithm

getMax(arr, n): index := 0 max := arr[0] for i in range 1 to n - 1, do if arr[i] > max, then max := arr[i] index := i end if done return index

We have to choose those operations that are performed maximum amount of time to estimate the cost. Suppose we have one bubble sort algorithm, and we count the swap operation. Then we have to keep in mind that when it will be maximum. That will give us maximum result during analysis.

- Related Questions & Answers
- Step Count Method in Algorithm
- Explain operation cycle method in estimation of working capital.
- What is the basic operation of the series.eq() method in pandas?
- What is the basic operation of the series.equals() method in pandas?
- Queries for counts of multiples in an array in C++
- Z algorithm (Linear time pattern searching Algorithm) in C++
- Inverse operation in JavaScript
- Z Algorithm
- Query in MongoDB to perform an operation similar to LIKE operation
- Find the Longest Substring Containing Vowels in Even Counts in C++
- XOR counts of 0s and 1s in binary representation in C++
- Python set operation.
- Database INSERT Operation in Perl
- Database READ Operation in Perl
- Database UPDATE Operation in Perl