- 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

The step count method is one of the method to analyze the algorithm. In this method, we count number of times one instruction is executing. From that we will try to find the complexity of the algorithm.

Suppose we have one algorithm to perform sequential search. Suppose each instruction will take c1, c2, …. amount of time to execute, then we will try to find out the time complexity of this algorithm

Algorithm | Number of times | Cost |
---|---|---|

seqSearch(arr, n, key) i := 0 while i < n, do if arr[i] = key, then break end if done return i | 1 n+1 n 0/1 1 | c1 c2 c3 c4 c5 |

Now if we add the cost by multiplying the number of times it is executed, (considering the worst case situation), we will get

* Cost=c1+(n+1)c 2+nc3+c 4+c 5*

* Cost=c1+nc 2+c2+nc 3+c 4+c5*

* Cost=n(c 2+c3)+c 1+c 4+c5*

* Cost=n(c 2+c3)+C*

Considering the c1 + c4 + c5 is C, so the final equation is like straight line y = mx + b. So we can say that the function is linear. The complexity will be O(n).

- Related Questions & Answers
- Operation Counts Method in Algorithm
- How to make a Website step by step?
- What is social bookmarking? Step by step explanation?
- HTML step Attribute
- How to break your addictions in a step by step manner?
- Step Angle in Stepper Motor
- What is frequency count and its importance in analysis of algorithm?
- IntStream count() method in Java
- LongStream count() method in Java
- DoubleStream count() method in Java
- Count ways to reach the nth stair using step 1, 2 or 3 in C++
- C# Linq Count method
- Explain a Step Definition in SpecFlow.
- Count number of step required to reduce N to 1 by following certain rule in C++
- How to use step attribute in HTML?

Advertisements