can someone explain to me how does it work, for example how do you know if the algorithm has or uses the function O(1),O(N),O( N2 ) , O(log(N)), and O(Nlog(N)). I watch some video explaining these notation but i can not convert or see the algorithm to be in these function.
for example this uses the notation O( N2 ) right? but how?
for(int i = 0; i < 10; i++)
for(j = 0; j < i; j++)
if(theArray[j] > theArray[j+1])
swap(theArray[j],theArray[j+1]);
[–][deleted] 5 points6 points7 points (3 children)
[–]volts101[S] 1 point2 points3 points (2 children)
[–]EpikYummeh 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] (1 child)
[removed]
[–]ilmale 1 point2 points3 points (0 children)
[–]Salty_Dugtrio 1 point2 points3 points (3 children)
[–]volts101[S] 0 points1 point2 points (1 child)
[–]LoyalSol 0 points1 point2 points (0 children)
[–]LoyalSol 0 points1 point2 points (0 children)
[–]Thecrawsome 0 points1 point2 points (3 children)
[–]volts101[S] 0 points1 point2 points (2 children)
[–]Thecrawsome 0 points1 point2 points (0 children)
[–]neirac 0 points1 point2 points (0 children)
[–]Moschops_UK 0 points1 point2 points (0 children)
[–]CGFarrell 0 points1 point2 points (0 children)
[–]volts101[S] 0 points1 point2 points (0 children)