What Is O N in Data Structure?


Larry Thompson

In the world of data structures, “O N” refers to the concept of time complexity. Time complexity is a measure of the amount of time it takes for an algorithm to run as a function of the input size. The “O” in “O N” stands for “order”, which represents the upper bound or worst-case scenario for the algorithm’s runtime.

Understanding Time Complexity

Time complexity is an essential concept in computer science and is used to analyze and compare different algorithms. It allows us to predict how an algorithm will perform as the input size increases.

The time complexity of an algorithm is typically described using Big O notation, which provides an asymptotic upper bound on the growth rate of a function. The “N” in “O N” represents the input size, and it can be any positive integer value.

O(1) – Constant Time Complexity

When an algorithm has a constant time complexity, denoted as O(1), it means that the runtime does not depend on the input size. Regardless of whether there are 10 or 10,000 elements, the algorithm will execute in constant time.


  • Accessing an element in an array by index
  • Performing basic arithmetic operations

O(N) – Linear Time Complexity

An algorithm with linear time complexity, denoted as O(N), means that the runtime grows linearly with respect to the input size. As the input size increases, so does the execution time proportionally.


  • Iterating through each element in an array or list
  • Finding a specific element in an unsorted array

O(N^2) – Quadratic Time Complexity

Quadratic time complexity, represented as O(N^2), indicates that the runtime grows quadratically with the input size. As the input size increases, the execution time increases exponentially.


  • Performing a nested loop where each iteration depends on the size of the input
  • Sorting an array using bubble sort or selection sort algorithms

O(log N) – Logarithmic Time Complexity

An algorithm with logarithmic time complexity, denoted as O(log N), means that the runtime grows logarithmically as the input size increases. This type of complexity is common in algorithms that divide and conquer problems by halving the search space at each step.


  • Binary search in a sorted array or binary search tree
  • Merge sort or quicksort algorithms


In summary, when we refer to “O N” in data structures, we are discussing time complexity and how it relates to the growth rate of algorithm runtimes. Understanding time complexity is crucial for analyzing and optimizing algorithms to ensure efficient program execution.

By using HTML styling elements like bold text, underlined text,


  • for lists, and proper subheaders (


    , etc.), we can make our content visually engaging and organized. These elements help break down complex information into digestible sections, making it easier for readers to follow along.

Discord Server - Web Server - Private Server - DNS Server - Object-Oriented Programming - Scripting - Data Types - Data Structures

Privacy Policy