August 14, 2022August 16, 2022 Algorithm Code Complexity 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 Scenario Average Case Scenario Best Case Scenario Accessing an element O(1) O(1) O(1) Updating an element O(1) O(1) O(1) Deleting an element O(n) O(n) O(1) Inserting an element O(n) O(n) O(1) Searching for an element O(n) O(n) O(1) Algorithm complexity: Worst Case Average Case Best Case Space Complexity Quicksort O(n2) O(n log(n)) O(n log(n)) O(log(n)) Mergesort O(n log(n)) O(n log(n)) O(n log(n)) O(n) Heapsort O(n log(n)) O(n log(n)) O(n log(n)) O(1) Bubble Sort O(n2) O(n2) O(n) O(1) Insertion Sort O(n2) O(n2) O(n) O(1) Selection Sort O(n2) O(n2) O(n2) O(1) Lear more about Map code complexity Algorithm algoArraysBubble SortHeapsortInsertion SortMergesortQuicksortSelection Sortspace complexitytime complexity