Code Complexity compute it by using the control flow graph of the program. Cyclomatic complexity measures the number of nested conditions within the code, such as those created by for, if/else, switch, while, and until. The greater the number of conditions (as in example b from above), the greater the complexity.

 

Time complexity:
 Worst Case ScenarioAverage Case ScenarioBest Case Scenario
Accessing an elementO(1)O(1)O(1)
Updating an elementO(1)O(1)O(1)
Deleting an elementO(n)O(n)O(1)
Inserting an elementO(n)O(n)O(1)
Searching for an elementO(n)O(n)O(1)

  Algorithm complexity:  
Worst CaseAverage CaseBest CaseSpace Complexity
QuicksortO(n2)O(n log(n))O(n log(n))O(log(n))
MergesortO(n log(n))O(n log(n))O(n log(n))O(n)
HeapsortO(n log(n))O(n log(n))O(n log(n))O(1)
Bubble SortO(n2)O(n2)O(n)O(1)
Insertion SortO(n2)O(n2)O(n)O(1)
Selection SortO(n2)O(n2)O(n2)O(1)

Lear more about Map code complexity



Leave a Reply

Your email address will not be published. Required fields are marked *