avatarjb stevenard

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

1043

Abstract

ty O(n) if, during its execution, it requires it to go through each input element.</p><p id="6349"><b>O(n log (n)) linear complexity:</b></p><p id="45b3">uses the same approach as logarithmic complexity, except it does so on each element of input n.</p><p id="0aff"><b>O(n²) — Quadratic/Squared execution time:</b></p><p id="2562">An algorithm whose execution time is directly proportional to the square of the input data set size is said to be of O(n²) complexity.</p><p id="6af9"><b>O(k^n) — Exponential execution time:</b></p><p id="0854">An algorithm whose execution time is growing exponentially is growing k times for every increase of n.</p><p id="8e8b"><b>Clearly, the shorter the execution time, the more efficient an algorithm.</b></p><p id="956d">Also, we use this notation for space complexity to determine the necessity of extra memory.</p><p id="0092">Suppose an algorithm requires no extra or a fixed number of additional memory, not depending on the size of the input values. In that case, it will be O(1) in space complexity.<

Options

/p><p id="5bdf">Suppose an algorithm requires the same quantity of extra memory of the input values. In that case, it will be O(n) in space complexity.</p><p id="a590">And so on.</p><p id="12b6"><a href="https://readmedium.com/learn-data-structures-and-algorithms-with-swift-5-6-d9f36a4027dd">Book</a> | <a href="https://readmedium.com/array-ad561d6f4a58">Arrays >></a></p><div id="3ac7" class="link-block"> <a href="https://medium.com/@jbstevenard/membership"> <div> <div> <h2>Join Medium with my referral link - jb stevenard</h2> <div><h3>Read every story from jb stevenard (and thousands of other writers on Medium). Your membership fee directly supports jb…</h3></div> <div><p>medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*LLOFX6T9gg6rcgut)"></div> </div> </div> </a> </div></article></body>

Big-O notation

The Big-O notation is a notation used to talk about the long-term growth rates of functions. It is often used for algorithms analysis, to talk about the execution of an algorithm or related concepts such as the complexity of space.

O(1) — Constant execution time:

An algorithm is of O(1) complexity if it requires constant execution time. The execution time is the same regardless of the size of the input values. Who says constancy also Says O(1).

O(log n) — Logarithmic execution time:

Simply a logarithmic trend is the opposite of an exponential trend. Where an exponential trend will multiply over time, the logarithmic trend will divide.

O(n) — Linear execution tim:

We say of an algorithm that it is of complexity O(n) if, during its execution, it requires it to go through each input element.

O(n log (n)) linear complexity:

uses the same approach as logarithmic complexity, except it does so on each element of input n.

O(n²) — Quadratic/Squared execution time:

An algorithm whose execution time is directly proportional to the square of the input data set size is said to be of O(n²) complexity.

O(k^n) — Exponential execution time:

An algorithm whose execution time is growing exponentially is growing k times for every increase of n.

Clearly, the shorter the execution time, the more efficient an algorithm.

Also, we use this notation for space complexity to determine the necessity of extra memory.

Suppose an algorithm requires no extra or a fixed number of additional memory, not depending on the size of the input values. In that case, it will be O(1) in space complexity.

Suppose an algorithm requires the same quantity of extra memory of the input values. In that case, it will be O(n) in space complexity.

And so on.

Book | Arrays >>

Algorithms
Coding
Programming
Interview
Data Structure Algorithm
Recommended from ReadMedium