what do you mean by complexity of a algorithm in layman’s term. How can one find it?
total expense per operation, evaluated over a sequence of operations.
and how is it calculated? what does O(n) & nO(n) means?
This is known as the Big-O notation.
O(1) means in constant time - independent of the number of items,
O(N) means in proportion to the number of items,
O(log N) means a time proportional to log(N).
Basically any ‘O’ notation means an operation will take time up to a maximum of k*f(N)
k is a constant multiplier and f() is a function that depends on N.
O(N) means that your algorithm will take on the order of n operations to insert an item. e.g. looping through the list once (or a constant number of times such as twice or only looping through half).
O(N2) means that for every insert, it takes N2 operations. i.e. 1 operation for 1 item, 4 operations for 2 items, 9 operations for 3 items and so on.
Note : Here N refers to the size of input.
Other Links : Read here for further explanation.