SvenWoltmann / o-notation-and-time-complexity

Code examples demonstrating the complexity classes O(1), O(log n), O(n), O(n log n), O(n²).

Home Page:https://www.happycoders.eu/algorithms/big-o-notation-time-complexity/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

O Notation and Time Complexity

What is "Big O notation" and "time complexity"?

Code examples demonstrating the following complexity classes:

  • O(1) - constant time (inserting elements at the beginning of a linked list)
  • O(n) - linear time (summing up all elements of an array)
  • O(n²) - quadratic time (sorting an array with Insertion Sort)
  • O(log n) - logarithmic time (finding an element within a sorted array using binary search)
  • O(n log n) - quasi-linear time (sorting an array with Quicksort)

The code belongs to this article:

About

Code examples demonstrating the complexity classes O(1), O(log n), O(n), O(n log n), O(n²).

https://www.happycoders.eu/algorithms/big-o-notation-time-complexity/


Languages

Language:Java 100.0%