@sarath: I did not get u .Could u please explain it with the example. On 10 September 2011 03:39, sarath prasath <[email protected]> wrote:
> consider this approach.. > first reverse the entire array... > so it will be.. 4,2,14,23,3,5,6,7,9 > and u want to shift k times right so > u have to cut the array as n-k and reverse both the sides u ll get it.. > so in ur scenario we are reversing upto the element 5 in array and > reversing the remaining elements.. > hope the complexity is of o(n).. > > > > On Sat, Sep 10, 2011 at 3:17 PM, kumar raja <[email protected]>wrote: > >> U have used c[3] extra array.It is already known solution. so it is using >> O(k) space .i want the solution with constant space.. >> >> >> On 10 September 2011 02:08, Ishan Aggarwal <[email protected] >> > wrote: >> >>> Solution :- >>> >>> >>> >>> void main(){int a[9]= {9,7,6,5,3,23,14,2,4} ;int n = 3;int c[3];int i;int k >>> =0;for ( i=0;i<3;i++) >>> c[i]= a[i];for(i=3;i<9;i++) >>> a[i-3] =a[i];for(i=9-3;i<9;i++) >>> a[i] = c[k++];for(i=0;i<9;i++)printf >>> <http://www.opengroup.org/onlinepubs/009695399/functions/printf.html>("\n%d",a[i]);} >>> >>> >>> On Sat, Sep 10, 2011 at 2:09 PM, kumar raja <[email protected]>wrote: >>> >>>> Given an array of 'n' values you need to circular shift it 'k' times >>>> towards left. >>>> >>>> Input : 9 7 6 5 3 23 14 2 4 >>>> output : 5 3 23 14 2 4 9 7 6 >>>> >>>> n=9 , k= 3 >>>> >>>> constraints : Time complexity O(n) >>>> Space complexity O(1) >>>> >>>> The solutions with O(kn) time complexity and >>>> O(n) complexity with O(k) space complexity are already available. >>>> >>>> I want the O(n) solution with constant space.. >>>> -- >>>> Regards >>>> Kumar Raja >>>> M.Tech(SIT) >>>> IIT Kharagpur, >>>> [email protected] >>>> 7797137043. >>>> 09491690115. >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Algorithm Geeks" group. >>>> To post to this group, send email to [email protected]. >>>> To unsubscribe from this group, send email to >>>> [email protected]. >>>> For more options, visit this group at >>>> http://groups.google.com/group/algogeeks?hl=en. >>>> >>> >>> >>> >>> -- >>> Kind Regards >>> Ishan Aggarwal >>> [image: Aricent Group] >>> Presidency Tower-A, M.G.Road,Sector-14 >>> Gurgaon,Haryana.122015 INDIA >>> Phone : +91-9654602663 >>> [email protected] <[email protected]> >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Algorithm Geeks" group. >>> To post to this group, send email to [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]. >>> For more options, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >>> >> >> >> >> -- >> Regards >> Kumar Raja >> M.Tech(SIT) >> IIT Kharagpur, >> [email protected] >> 7797137043. >> 09491690115. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Regards Kumar Raja M.Tech(SIT) IIT Kharagpur, [email protected] 7797137043. 09491690115. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
