It means that the thing in question (usually running time) scales in a manner that is consistent with the logarithm of its input size.
Big-O notation doesn’t mean an exact equation, but rather a bound. For instance, the output of the following functions is all O(n):
f(x) = 3x g(x) = 0.5x m(x) = x + 5
Because as you increase x, their outputs all increase linearly – if there’s a 6:1 ratio between f(n)
and g(n)
, there will also be approximately a 6:1 ratio between f(10*n)
and g(10*n)
and so on.
As for whether O(n)
or O(log n)
is better, consider: if n = 1000
, then log n = 3
(for log-base-10). Which would you rather have your algorithm take to run: 1000 seconds, or 3 seconds?
Related Posts:
- What is the big-O of the function (log n)^k
- Big O, how do you calculate/approximate it?
- Is log(n!) = Θ(n·log(n))?
- How to calculate big-theta
- Which is better: O(n log n) or O(n^2)
- What is O(log* N)?
- Why is O(n) better than O( nlog(n) )?
- Are there any real O(n^n) algorithms?
- What does O(log n) mean exactly?
- What does O(log n) mean exactly?
- What is the difference between tree depth and height?
- Time complexity of a Priority Queue in C++
- Example of O(n!)?
- O(n log n) vs O(n) — practical differences in time complexity
- Big-oh vs big-theta
- Trie complexity and searching
- Exactly how many comparisons does merge sort make?
- What is the time complexity of while loops?
- Intuitive explanation for why QuickSort is n log n?
- How to calculate time complexity of backtracking algorithm?
- Hash table runtime complexity (insert, search and delete)
- Difference between Big-O and Little-O Notation
- Difference between Big-Theta and Big O notation in simple language
- How are the following functions O(N^3)?
- In a triangulated isometric grid, what triangle is a given point in?
- What is a loop invariant?
- What is a loop invariant?
- how to calculate binary search complexity
- When is it practical to use Depth-First Search (DFS) vs Breadth-First Search (BFS)? [closed]
- What is Sliding Window Algorithm? Examples?
- Quicksort with Python
- how to implement quick sort algorithm in C++
- Python: maximum recursion depth exceeded while calling a Python object
- Understanding Time complexity calculation for Dijkstra Algorithm
- Why is the time complexity of both DFS and BFS O( V + E )
- What is stability in sorting algorithms and why is it important?
- Breadth First Search time complexity analysis
- Counting the sum of every nodes’ neighbors’ degrees?
- Time Complexity of the Kruskal Algorithm?
- Determining complexity for recursive functions (Big O notation)
- Quick Sort Vs Merge Sort
- Polynomial time and exponential time
- Insertion Sort vs. Selection Sort
- Difference and advantages between dijkstra & A star
- Best Case for Bubble Sort
- When will the worst case of Merge Sort occur?
- Performing Breadth First Search recursively
- Is Quicksort in-place or not?
- longest increasing subsequence(O(nlogn))
- HashMap get/put complexity
- When should I use Kruskal as opposed to Prim (and vice versa)?
- Shortest possible depth of a leaf in decision tree (comparison sorting algorithm)
- Python Weighted Random [duplicate]
- What’s a good algorithm to generate a maze?
- Intuition for perceptron weight update rule
- Easy: Solve T(n)=T(n-1)+n by Iteration Method
- What is tail call optimization?
- PacMan: what kinds of heuristics are mainly used?
- Quicksort vs heapsort
- Best case time complexity for selection sort
- What does this definition of contiguous subsequences mean?
- Is complexity O(log(n)) equivalent to O(sqrt(n))?
- How to find maximum spanning tree?
- Algorithm to return all combinations of k elements from n
- Merge sort time and space complexity
- Why lookup in a Binary Search Tree is O(log(n))?
- Calculate distance between two latitude-longitude points? (Haversine formula)
- Shuffle a deck of cards in Java
- Median of Medians in Java
- What is a loop invariant?
- What is the difference between an Abstract Data Type(ADT) and a Data Structure?
- Quickselect time complexity explained
- What is the proper equivalent of “while(true)” in plain C?
- Bellman-Ford vs Dijkstra: Under what circumstances is Bellman-Ford better?
- Asymptotic Notation – does n (log n) (log n) simplify?
- Big Oh for (n log n)
- How to calculate an angle from three points?
- How to solve: T(n) = T(n/2) + T(n/4) + T(n/8) + (n)
- Is there an O(n) integer sorting algorithm?
- An example of Best Case Scenario for Quick Sort (Need someone to check if my answer is correct)
- how to write a recurrence relation for a given piece of code
- Why is merge sort worst case run time O (n log n)?
- Why is merge sort worst case run time O (n log n)?
- Which algorithm is faster O(N) or O(2N)?
- What is the time and space complexity of a breadth first and depth first tree traversal?
- Create your own MD5 collisions
- A tool for calculating the big-O time complexity of Java code? [closed]
- Image Segmentation using Mean Shift explained
- Finding the median of an unsorted array
- What is the difference between bucket sort and radix sort?
- Time complexity of nested for-loop
- Finding all possible combinations of numbers to reach a given sum
- Sorting an array in C?
- Is Dijkstra’s algorithm for directed or undirected graphs?
- How to determine if a point is in a 2D triangle?
- Modular multiplicative inverse function in Python
- Minesweeper solving algorithm
- Big O Complexity in Binary Search Tree(BST)
- About bubble sort vs merge sort
- Running time of algorithm A is at least O(n²) – Why is it meaningless?