java - Big Oh-Notation Q -


i've got big o notation of o(n^2 + n + n), want make sure, o(n^2) correct? for-loop goes through of n for-loop same inside first one, 2 separate for-loops go through of n.

generally, in big-o notation consider fastest growing term of n. although if comparing 2 similar performing algorithms other terms may matter. eg: if algorithm has n operation , other has 2n operations although both of them o(n) still later perform poorer former.

hence in case algorithm's big o notation o(n^2).


Comments