Skip to content

Tarik Billa

  • Web Development
    • html
    • vue.js
    • laravel
    • css
    • javascript
    • jquery
    • node.js
    • php
    • asp.net
  • Programming
    • python
    • java
    • c
    • c++
    • c#
  • git
  • android

big-o

Is log(n!) = Θ(n·log(n))?

October 5, 2022 by Tarik

Remember that log(n!) = log(1) + log(2) + … + log(n-1) + log(n) You can get the upper bound by log(1) + log(2) + … + log(n) <= log(n) + log(n) + … + log(n) = n*log(n) And you can get the lower bound by doing a similar thing after throwing away the first half … Read more

Categories algorithm Tags algorithm, big-o, complexity-theory, math, recursion Leave a comment

Big-O for Eight Year Olds? [duplicate]

September 28, 2022 by Tarik

One way of thinking about it is this: O(N^2) means for every element, you’re doing something with every other element, such as comparing them. Bubble sort is an example of this. O(N log N) means for every element, you’re doing something that only needs to look at log N of the elements. This is usually … Read more

Categories algorithm Tags algorithm, big-o, metrics, theory Leave a comment

Are there any O(1/n) algorithms?

September 25, 2022 by Tarik

This question isn’t as silly as it might seem to some. At least theoretically, something such as O(1/n) is completely sensible when we take the mathematical definition of the Big O notation: Now you can easily substitute g(x) for 1/x … it’s obvious that the above definition still holds for some f. For the purpose … Read more

Categories theory Tags big-o, complexity-theory, theory Leave a comment

Computational complexity of Fibonacci Sequence

September 23, 2022 by Tarik

You model the time function to calculate Fib(n) as sum of time to calculate Fib(n-1) plus the time to calculate Fib(n-2) plus the time to add them together (O(1)). This is assuming that repeated evaluations of the same Fib(n) take the same time – i.e. no memoization is used. T(n<=1) = O(1) T(n) = T(n-1) … Read more

Categories time-complexity Tags big-o, complexity-theory, fibonacci, time-complexity Leave a comment

List of Big-O for PHP functions

September 23, 2022 by Tarik

Since it doesn’t seem like anyone has done this before I thought it’d be good idea to have it for reference somewhere. I’ve gone though and either via benchmark or code-skimming to characterize the array_* functions. I’ve tried to put the more interesting Big-O near the top. This list is not complete. Note: All the … Read more

Categories php Tags algorithm, arrays, big-o, performance, php Leave a comment

Determining complexity for recursive functions (Big O notation)

September 22, 2022 by Tarik

The time complexity, in Big O notation, for each function: int recursiveFun1(int n) { if (n <= 0) return 1; else return 1 + recursiveFun1(n-1); } This function is being called recursively n times before reaching the base case so its O(n), often called linear. int recursiveFun2(int n) { if (n <= 0) return 1; … Read more

Categories recursion Tags big-o, complexity-theory, recursion Leave a comment

Difference between Big-O and Little-O Notation

September 20, 2022 by Tarik

f ∈ O(g) says, essentially For at least one choice of a constant k > 0, you can find a constant a such that the inequality 0 <= f(x) <= k g(x) holds for all x > a. Note that O(g) is the set of all functions for which this condition holds. f ∈ o(g) … Read more

Categories algorithm Tags algorithm, asymptotic-complexity, big-o, little-o, time-complexity Leave a comment

What is the difference between Θ(n) and O(n)?

September 16, 2022 by Tarik

Short explanation: If an algorithm is of Θ(g(n)), it means that the running time of the algorithm as n (input size) gets larger is proportional to g(n). If an algorithm is of O(g(n)), it means that the running time of the algorithm as n gets larger is at most proportional to g(n). Normally, even when … Read more

Categories time-complexity Tags big-o, notation, time-complexity Leave a comment

What is Constant Amortized Time?

September 14, 2022 by Tarik

Amortised time explained in simple terms: If you do an operation say a million times, you don’t really care about the worst-case or the best-case of that operation – what you care about is how much time is taken in total when you repeat the operation a million times. So it doesn’t matter if the … Read more

Categories algorithm Tags algorithm, big-o, complexity-theory Leave a comment

How can building a heap be O(n) time complexity?

September 7, 2022 by Tarik

I think there are several questions buried in this topic: How do you implement buildHeap so it runs in O(n) time? How do you show that buildHeap runs in O(n) time when implemented correctly? Why doesn’t that same logic work to make heap sort run in O(n) time rather than O(n log n)? How do … Read more

Categories algorithm Tags algorithm, big-o, complexity-theory, construction, heap Leave a comment
Older posts
Newer posts
← Previous Page1 … Page11 Page12 Page13 Next →

Tarik Billa

Software Engineer
tarikbilla@gmail.com
+8801884414000
  • Reuse a hash in YAMLApril 17, 2024
  • Dockerfile: how to redirect the output of a RUN command to a variable?April 16, 2024
  • How to cd to a directory with spaces in the directory name?April 16, 2024
  • Maximum MIME type length when storing the type in a databaseApril 16, 2024
  • What is the difference between Unit, Integration, Regression and Acceptance Testing?April 16, 2024
© 2026 Tarik Billa