141 views

1 Answer

1 votes
1 votes

its obviously A.

case 1 : keep a counter and when it reaches the position k . print the value of kth element. which takes O(k).

case 2: since its difficult to find kth element from the end.you have to keep a counter that counts total number of elements. than find (n-k+1) position than goto that position. O(n) + O(n-k+1) = O(n).

Related questions

0 votes
0 votes
0 answers
2
HeadShot asked Aug 12, 2018
452 views
Option B ? Following is a function Mystery() which takes a list and sorts it. Line 1and Line 2 are left blank intentionally.
0 votes
0 votes
0 answers
3
HeadShot asked Aug 12, 2018
467 views