Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

big O help -_-

$
0
0
need help with big o notion. wht i understant you can tell how fast algorithm is running by using big O.

so my question is can any one tell me if i have the anwser right or wrong. if right or wrong can you please explain as much as you can.

1) this algorithm is running O(n) or n?
for(int i = 0; i < n; i++)
{ ... }


2) O(10)?
for(int i = 0; i < 10; i++){ ... }


3) o(n)??
int n = array[i].length;
for(int i = 0; i < n; i++)
if(array[i] == 3)
{
...
}


4) ?
for(int i = 10; i > 0; i--)
{
...
}


5) O(n*m)? n = 1st array size | m = 2nd array size
for(int i = 0; i < n; i++)
{
for(int x = 0; x < m; x++)
{
 
}
}


6)O(n*m)?? n=array.length | m=array[y].length
for(int y = 0; y < array.length; y++)
		{
			for(int x = 0; x < array[y].length; x++)
			{
....
			}
		}


are there any more usefull case?

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>