Kinjal Sonpal wrote:

> 1> What is the complexity of the following code segment?
> for( i = 0; i <  n; i++ )
>  for( j = 0; j < i; j++)
>   B[i][j] = A[j][i];
> 
> ( a) O(N * log N)
> ( b) None of the above.
> ( c) O(N * N)
> ( d) O(N)
> 
> My answer : (c)


No. I think it's  O(n)<O(Algo)< O(n*n). If the inner loop looks like
for( j = 0; j < n; j++), then it would be O(n*n). Exact value may be in form of 
a series or factorial. I can't guess better than that.

> 
> 2> What is the order of time required to initialise, insert an
> element and delete an element from a statck implemented using an
> array?
> 
> ( a) 1 - n - n
> ( b) 1 - 1 - 1
> ( c) 1 - n - 1
> ( d) n - n - n
> 
> My answer : (b)


I guess it's correct if insertion is push and deletion in pop.


> 
> 3> What is the order of time required to initialise, insert an
> element and delete an element from a queue implemented using a
> wrap-around array?
> 
> ( a) 1 - n - n
> ( b) 1 - 1 - 1
> ( c) n - n - n
> ( d) 1 - n - 1
> 
> My answer : (b)

What's a wrap around array? Is it like circular linked list?

And I think you have put an entry of LIH list with a name of LIP. Check your 
addressbook.. It's going to irritate some people.

  Shridhar


_______________________________________________
linux-india-help mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/linux-india-help

Reply via email to