Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
47 views

03 Useful Formulae - Data Structures For Coding Interviews in C#

This document provides useful formulae for calculating time complexity, including common summation, logarithmic, and other asymptotic notations. It lists formulas for calculating the summations of constants, integers, squares, and powers. It also covers logarithmic expressions and their equivalents. General tips are given that iterating over a list c times generally yields O(n) time, problems where the problem space is halved each time are often O(logn), and singly nested loops typically result in quadratic time.

Uploaded by

Farmer M
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views

03 Useful Formulae - Data Structures For Coding Interviews in C#

This document provides useful formulae for calculating time complexity, including common summation, logarithmic, and other asymptotic notations. It lists formulas for calculating the summations of constants, integers, squares, and powers. It also covers logarithmic expressions and their equivalents. General tips are given that iterating over a list c times generally yields O(n) time, problems where the problem space is halved each time are often O(logn), and singly nested loops typically result in quadratic time.

Uploaded by

Farmer M
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

06/11/2021, 12:16 Useful Formulae - Data Structures for Coding Interviews in C#

Useful Formulae
Study some mathematical formulae that would make calculating time complexity easier!

We'll cover the following

• Formulas
• General tips

Formulas#
Here is a list of handy formulas, which can be helpful when calculating
the time complexity of an algorithm:
(/learn)

Summation Equation

(∑i=1
n
c) = c + c + c + ⋯ + c cn

n(n+1)
(∑i=1
n
i) = 1 + 2 + 3 + ⋯ + n 2

n 2
(∑i=1 i )=1+4+9+⋯+ n(n+1)(2n+1)
n2 6

n
(∑i=0 ri ) = r0 + r1 + r2 + ⋯ (rn+1
​ −1)

+ rn r−1

n
∑i=0 2i = 20 + 21 + ... + 2n 2n+1 − 1

https://www.educative.io/courses/data-structures-interviews-cs/xVlqk4xQyVJ 1/3
06/11/2021, 12:16 Useful Formulae - Data Structures for Coding Interviews in C#

Here are some of the formulas dealing with logarithmic expressions:

Logarithmic Expressions Equivalent Expression

log (a ∗ b) log (a) + log (b)

log (a / b) log (a) − log (b)

log an n log a

n
∑i=1 log i = log 1 + log
2 + ... + log n log n!
= log(1.2...n)

General tips#
1. Every time a list or array gets iterated over c × length times, it is
most likely in O(n) time.
2. When you see a problem where the number of elements in the
problem space gets halved each time, that will most likely be in
O(logn) runtime.
3. Whenever you have a singly nested loop, the problem is most likely in
quadratic time.

Back Next

Other Common Asymptotic Notations … Common Complexity Scenarios

Mark as Completed

Report an Issue

https://www.educative.io/courses/data-structures-interviews-cs/xVlqk4xQyVJ 2/3
06/11/2021, 12:16 Useful Formulae - Data Structures for Coding Interviews in C#

https://www.educative.io/courses/data-structures-interviews-cs/xVlqk4xQyVJ 3/3

You might also like