Derive in details the complexity of the following code fragments in terms
of the Big-O notation:
1)
for i = 1 to n do
for j = 1 to n do
x = 2 * y
z = x--
2)
for i = 1 to n do
j = n
while j != 1 do
x++
j = j / 2
3)
i = 1
while i != n do
i++
4)
for i = 1 to n do
if i == 1 or i == n or i == 3 do
for j = 1 to n do
x++
Provide the corresponding big-O notation for the following functions:
n^2 + 3n - 7
5n^3 - 3n^2 + 8n - 2
lg(n) - 2 + 3n
nlg(n) - n + 3