When should we consider constants at runtime

Suppose I have two algorithms A()and B()for which the algorithm A()accepts exactly O(3n^2)while the algorithm B()accepts O(n^2). Although both algorithms work in quadratic time, can we say that algorithm B is faster than?

I understand that we ignore constants when analyzing the running time of an algorithm, but I want to ask about this case when we need to consider constants when analyzing algorithms.

thank

+4
source share
2 answers

You can see this SO answer .

From this answer:

- big-O , . ; .

, Big O, B .

+2

, .

A , , , , ( , , , ), .

+2

Source: https://habr.com/ru/post/1657550/


All Articles