complexity theory - Step Count in Algorithm -


what step count algorithm in terms of n ?

sequentialsearch(a,x,n) {     i=n;     [0]=x;     while(a [i]!= x)         = i-1     return } 

please mention count each step here.thanks!

i hope looking for:

while (a[i] != x) = i-1; 

worst case: scan whole array, a[n] a[0] = o(n)

mean case: scan half array o(n/2) = o(n)

complexity o(n)


Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -