big o - Big-O: How do you know what algorithm to give for a specific time complexity? -


So when someone asks you to give an O (n) or o (alglin) algorithm to calculate something, then Do you know what to answer? The only way to be able to answer this type of question is that instead of thinking about something on the spot, knowing the complex complications of different algorithms in advance. Am I right to handle it?

There are simple cases:

list - O (n)

Single binary or tree operation - O (log n) (meaning, enclosing n elements in the tree is n log n)

hashtable operation - O (1)

NP is the whole problem (here you need some experience to develop intuition) - Exponential time in general (a skilled hunitistics can be applied in the practice of many problems)

Graph of Elg Rhythm and depending on the nature of the density graph complexity f (E, V) with e edges and top of the TV. E + V for good DFS / BFS

Almost every algorithm can be divided into sets of (or similar) small blocks. Blocks like A-B-B are reconnected, such that complexity is multiplied, when blocks like A-B-B follow each other, complexity is maximized (complexity A, complexity B )


Comments