Re: [algogeeks] Circular Left shift

2011-09-10 Thread Rohit jalan
 this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Regards :
ROHIT JALAN
B.E. Graduate,
Computer Science Department,
RVCE, Bangalore

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Circular Left shift

2011-09-10 Thread Rohit jalan
This can also be done:


for( i=0; ik;i++)
{
b[i]=a[i];
}

for (;in;i++)
{
a[i-k]=a[i];
}
while((i-k)n)
{
a[i-k]=b[i];
}

But extra array is used here.

On Sat, Sep 10, 2011 at 5:30 PM, Rohit jalan jalanha...@gmail.com wrote:


 How is this one ??


 int a[9]={9,7,6,5,3,23,14,2,4}
 n=9
 int *p,*q;
 p=a;
 for(q=a;in;q++,i++);
 ReverseArray(p,q)

 p=a[0];
 q=a[n-1-k]
 ReverseArray(p,q)

 p=a[n-k];
 q=a[n-1]
 ReverseArray(p,q)

 void ReverseArray(int *l,int *r)
 {
 int temp;
 while(lr)
 {
 temp=*l;
 *l=*r;
 *r=temp
 l++;
 r--;
 }
 }


 Thanks  Regards,
 -Rohit


 On Sat, Sep 10, 2011 at 5:24 PM, bharatkumar bagana 
 bagana.bharatku...@gmail.com wrote:

 swap k elements form 1 to k and n-k to n respectively...
 ex: k=3
temp=k;

 int a[9]= {9,7,6,5,3,23,14,2,4} ; has become {14,2,4,5,3,23,9,7,6};


 now swap first k elements with k+1 to 2k elements ...now k=2k+1 , do this 
 step again up to (kn-temp)...
 at last {5,3,23,14,2,4,9,7,6,} ;


 Time :O(n) and space O(1).



 On Sat, Sep 10, 2011 at 7:15 AM, kumar raja rajkumar.cs...@gmail.comwrote:

 @sarath:
 I did not get u .Could u please explain it with the example.


 On 10 September 2011 03:39, sarath prasath prasathsar...@gmail.comwrote:

 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 
 rajkumar.cs...@gmail.comwrote:

 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 
 ishan.aggarwal.1...@gmail.com 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;i3;i++)
 c[i]= a[i];for(i=3;i9;i++)
 a[i-3] =a[i];for(i=9-3;i9;i++)
 a[i] = c[k++];for(i=0;i9;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 rajkumar.cs...@gmail.com
  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,
 10it60...@iitkgp.ac.in
 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 algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 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
 ishan2.aggar...@aricent.com puneet.ar...@aricent.com

  --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Regards
 Kumar Raja
 M.Tech(SIT)
 IIT Kharagpur,
 10it60...@iitkgp.ac.in
 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 algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 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 algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Regards
 Kumar Raja
 M.Tech(SIT)
 IIT Kharagpur,
 10it60...@iitkgp.ac.in
 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 algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --

 **Please do not print this e

Re: [algogeeks] Circular Left shift

2011-09-10 Thread Rohit jalan
@BharathKumar: extremely sorry dude .. will not do this again .. Can you
forgive me ? :p
On Sep 10, 2011 12:09 PM, bharatkumar bagana bagana.bharatku...@gmail.com
wrote:
 @rohit : why don't u have a look at the older posts before replying some
 thing ...ok .. I'm sorry if u are hurt ..
 what is the time complexity and space complexity of u'r older post ..

 On Sat, Sep 10, 2011 at 8:03 AM, Rohit jalan jalanha...@gmail.com wrote:

 This can also be done:


 for( i=0; ik;i++)
 {
 b[i]=a[i];
 }

 for (;in;i++)
 {
 a[i-k]=a[i];
 }
 while((i-k)n)
 {
 a[i-k]=b[i];
 }

 But extra array is used here.


 On Sat, Sep 10, 2011 at 5:30 PM, Rohit jalan jalanha...@gmail.com
wrote:


 How is this one ??


 int a[9]={9,7,6,5,3,23,14,2,4}
 n=9
 int *p,*q;
 p=a;
 for(q=a;in;q++,i++);
 ReverseArray(p,q)

 p=a[0];
 q=a[n-1-k]
 ReverseArray(p,q)

 p=a[n-k];
 q=a[n-1]
 ReverseArray(p,q)

 void ReverseArray(int *l,int *r)
 {
 int temp;
 while(lr)
 {
 temp=*l;
 *l=*r;
 *r=temp
 l++;
 r--;
 }
 }


 Thanks  Regards,
 -Rohit


 On Sat, Sep 10, 2011 at 5:24 PM, bharatkumar bagana 
 bagana.bharatku...@gmail.com wrote:

 swap k elements form 1 to k and n-k to n respectively...
 ex: k=3
 temp=k;

 int a[9]= {9,7,6,5,3,23,14,2,4} ; has become {14,2,4,5,3,23,9,7,6};



 now swap first k elements with k+1 to 2k elements ...now k=2k+1 , do
this step again up to (kn-temp)...
 at last {5,3,23,14,2,4,9,7,6,} ;



 Time :O(n) and space O(1).



 On Sat, Sep 10, 2011 at 7:15 AM, kumar raja rajkumar.cs...@gmail.com
wrote:

 @sarath:
 I did not get u .Could u please explain it with the example.


 On 10 September 2011 03:39, sarath prasath prasathsar...@gmail.com
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 rajkumar.cs...@gmail.com
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 
 ishan.aggarwal.1...@gmail.com 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;i3;i++)
 c[i]= a[i];for(i=3;i9;i++)
 a[i-3] =a[i];for(i=9-3;i9;i++)
 a[i] = c[k++];for(i=0;i9;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 
 rajkumar.cs...@gmail.com 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,
 10it60...@iitkgp.ac.in
 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 algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 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
 ishan2.aggar...@aricent.com puneet.ar...@aricent.com

 --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Regards
 Kumar Raja
 M.Tech(SIT)
 IIT Kharagpur,
 10it60...@iitkgp.ac.in
 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 algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 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 algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Regards
 Kumar Raja
 M.Tech(SIT)
 IIT Kharagpur,
 10it60...@iitkgp.ac.in
 7797137043.
 09491690115.

 --
 You

[algogeeks] Kth largest element

2011-09-08 Thread Rohit jalan
How to find out Kth largest element in an array ?

-- 
Thanks  Regards :
ROHIT JALAN

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Kth largest element

2011-09-08 Thread Rohit jalan
@Brijesh: Can you help me with a code ? or atleast pseudo code ?  How are
you going to keep on inserting the elements ?

Thanks  Regards,
-Rohit

On Thu, Sep 8, 2011 at 10:38 PM, Brijesh brijeshupadhyay...@gmail.comwrote:

 make a max heap of size K , and keep inserting all the elements in it.. and
 at last the root will be the k-th largest element ! O(nlonk)


 On Thursday, 8 September 2011 22:32:52 UTC+5:30, Sandeep Chugh wrote:

 wat abt creating a max heap?  and then deleting root element k-1 times..
 after then root contains kth largest element

 On Thu, Sep 8, 2011 at 10:28 PM, Piyush Kapoor pkje...@gmail.com wrote:

 use max heap ,it will take n + k*logn


 On Thu, Sep 8, 2011 at 10:25 PM, Rohit jalan jalan...@gmail.com wrote:

 How to find out Kth largest element in an array ?

 --
 Thanks  Regards :
 ROHIT JALAN

  --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algo...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+...@googlegroups.com**.

 For more options, visit this group at http://groups.google.com/**
 group/algogeeks?hl=en http://groups.google.com/group/algogeeks?hl=en.




 --
 *Regards,*
 *Piyush Kapoor,*
 *2nd year,CSE
 IT-BHU*

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algo...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+...@googlegroups.com**.

 For more options, visit this group at http://groups.google.com/**
 group/algogeeks?hl=en http://groups.google.com/group/algogeeks?hl=en.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/algogeeks/-/XYeQcjZW-isJ.

 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Regards :
ROHIT JALAN
B.E. Graduate,
Computer Science Department,
RVCE, Bangalore

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Kth largest element

2011-09-08 Thread Rohit jalan
Okay. We can do it with min Heap.

1) Build a Min Heap MH of the first k elements (arr[0] to arr[k-1]) of the
given array. O(k)
2) For each element, after the kth element (arr[k] to arr[n-1]), compare it
with root of MH.
a) If the element is greater than the root then make it root and call heapify
http://www.personal.kent.edu/%7Ermuhamma/Algorithms/MyAlgorithms/Sorting/heapSort.htmfor
MH
b) Else ignore it.
O((n-k)*logk)
3) Finally, MH has k largest elements and root of the MH is the kth largest
element.

Thanks  Regards,
-Rohit

On Thu, Sep 8, 2011 at 11:20 PM, praveen raj praveen0...@gmail.com wrote:

 @brijesh...Tht would...be... O(klogn)

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Regards :
ROHIT JALAN
B.E. Graduate,
Computer Science Department,
RVCE, Bangalore

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: loop in link list

2011-08-31 Thread Rohit jalan
Hi All,

Find below the function to detect a loop in a linked list and the point from
where loop occurs.

#includestdio.h
#includestdlib.h

/* Link list node */
struct node
{
int data;
struct node* next;
};

/* Function to remove loop. Used by detectAndRemoveLoop() */
void LoopPoint(struct node *, struct node *);

/* This function detects and removes loop in the list
  If loop was there in the list then it returns 1,
  otherwise returns 0 */
int detectLoop(struct node *list)
{
struct node  *slow_p = list, *fast_p = list;

while (slow_p  fast_p  fast_p-next)
{
slow_p = slow_p-next;
fast_p  = fast_p-next-next;

/* If slow_p and fast_p meet at some point then there
   is a loop */
if (slow_p == fast_p)
{
LoopPoint(slow_p, list);

/* Return 1 to indicate that loop is found */
return 1;
}
}

/* Return 0 to indeciate that ther is no loop*/
return 0;
}

/* Function to find loop point.
 loop_node -- Pointer to one of the loop nodes
 head --  Pointer to the start node of the linked list */
void removeLoop(struct node *loop_node, struct node *head)
{
   struct node *ptr1;
   struct node *ptr2;

   /* Set a pointer to the beging of the Linked List and
  move it one by one to find the first node which is
  part of the Linked List */
   ptr1 = head;
   while(1)
   {
 /* Now start a pointer from loop_node and check if it ever
   reaches ptr2 */
 ptr2 = loop_node;
 while(ptr2-next != loop_node  ptr2-next != ptr1)
 {
 ptr2 = ptr2-next;
 }

 /* If ptr2 reahced ptr1 then there is a loop. So break the
loop */
 if(ptr2-next == ptr1)
break;

 /* If ptr2 did't reach ptr1 then try the next node after ptr1 */
 else
   ptr1 = ptr1-next;
   }

/* ptr1-data is a point where loop occurs.*/

/* to remove loop*/

ptr2-next=NULL
}


On Thu, Sep 1, 2011 at 9:12 AM, Don dondod...@gmail.com wrote:

 @Rahul
 The problem is to determine if there is a loop. That means there might
 not be. And if there isn't, you really shouldn't dump core.
 Don

 On Aug 31, 10:17 pm, Siddhartha Banerjee thefourrup...@gmail.com
 wrote:
  how can head2-next be null in a linked list witha loop???
  i mean it would just go around in circles right???

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Regards :
ROHIT JALAN
B.E. Graduate,
Computer Science Department,
RVCE, Bangalore

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] merging of two sorted arrays

2011-08-04 Thread Rohit jalan
Consider two array a[] and b[].
Suppose Number of elements  in  a[] are n and number of elements in b[] are
m. a[] can accomodate m+n elements.

MergeInPlace(int a[], int b[],int n,int m)
{
   int i=n-1;
  int j=m-1;
  int k=n+m-1;
  while(i0  j0)
   {
 if(a[i]=b[j])
 a[k--]=a[i--]
 else
 a[k--]=b[j--]
}

while(j0)
 {
   a[k--]=b[j--]
 }
}


On Thu, Aug 4, 2011 at 10:46 PM, Kamakshii Aggarwal
kamakshi...@gmail.comwrote:


 how can  two sorted arrays be merged inplace?
 --
 Regards,
 Kamakshi
 kamakshi...@gmail.com

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Regards :
ROHIT JALAN
B.E. Graduate,
Computer Science Department,
RVCE, Bangalore

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks]

2011-08-04 Thread Rohit jalan
Merge Sort

On Thu, Aug 4, 2011 at 11:09 PM, parag khanna khanna.para...@gmail.comwrote:

 Which is fastest sorting method?

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Regards :
ROHIT JALAN
B.E. Graduate,
Computer Science Department,
RVCE, Bangalore

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks]

2011-08-04 Thread Rohit jalan
What is the time complexity of radix sort ?

On Thu, Aug 4, 2011 at 11:12 PM, parag khanna khanna.para...@gmail.comwrote:

 i think its Radix sort




  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Regards :
ROHIT JALAN
B.E. Graduate,
Computer Science Department,
RVCE, Bangalore

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Google Interview Question

2011-08-01 Thread Rohit jalan
Here is the recursive algo:

Rearrange(A,p,q)
1. if p is not equal to q do the following
2. r ← (p+q)/2
3. Exchange A[(p+r)/2..r] ←→ A[(p+q)/2 +1 ..(r+q)/2].
4. Rearrange(A,p,r)
5. Rearrange(A,r+1,q)
6. return



On Mon, Aug 1, 2011 at 1:45 PM, Abhishek Gupta gupta.abh...@gmail.comwrote:

 A is an array of size 2n such that first n elements are integers in any
 order and last n elements are characters.
 i.e. A={i1 i2 i3 in c1 c2 c3... cn}
 then we have to rearrange the elements such that final array is
 A ={ i1 c1 i2 c2 .. in cn}


 Example :
 input : A ={ 5,1,4,d,r,a};
 output : A= {5,d,1,r,4,a};

 --
 Abhishek Gupta
 MCA
 NIT Calicut
 Kerela

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Regards :
ROHIT JALAN
B.E. Graduate,
Computer Science Department,
RVCE, Bangalore

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Structure

2011-08-01 Thread Rohit jalan
Here, you are declaring a variable for structure.

*top is a variable of struct node.

struct node
{
int d;
struct node *next;
}*top=NULL;

The above is equivalent to:
*struct node
{
int d;
struct node *next;
}

struct node *top=NULL;


*
On Mon, Aug 1, 2011 at 11:27 PM, Priyanka pril...@gmail.com wrote:

 struct node
 {
 int d;
 struct node *next;
 }*top=NULL;

 wat s it mean?

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Regards :
ROHIT JALAN
B.E. Graduate,
Computer Science Department,
RVCE, Bangalore

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Amazon

2011-07-30 Thread Rohit jalan
BODMAS rule.

Brackets are of higher priority.

64/4*4 = 16*4 =64

64/(4*4)=64/16=4

On Sat, Jul 30, 2011 at 1:28 PM, arvind kumar arvindk...@gmail.com wrote:

 @coool:y is that so..does braces matter here??

 On 7/30/11, coool !! coool4...@gmail.com wrote:
  its 64...
 
  if u want to get 4 as output change the macro definition to   #define
 sqr(x)
   (x*x)
 
  --
  You received this message because you are subscribed to the Google Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  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 algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Regards :
ROHIT JALAN
B.E. Graduate,
Computer Science Department,
RVCE, Bangalore

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] SDET- Amazon

2011-07-29 Thread Rohit jalan
Hi All,

Anyone having an idea about the Amazon interview questions for the position
SDET(Software Development Engineer in Test) ??

-- 
Regards :
ROHIT JALAN

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Question

2011-07-25 Thread Rohit jalan
Can you explain this ??

On Mon, Jul 25, 2011 at 10:29 PM, shady sinv...@gmail.com wrote:

 easy guys...

 @sagar nice question, if there had been an option for incomplete info, i
 would have gone with that... but it made me think thoroughly :)  80 min. is
 answer

 @aashish we are forming new group for apti kind of questions...


 On Mon, Jul 25, 2011 at 10:23 PM, AASHISH SUMAN aashish.barn...@gmail.com
  wrote:


 @sagar :: this group is for programming concepts not for apti.. if u
 wana to post some apti or reasoning question post here..
 http://www.facebook.com/groups/150933398312351?ap=1
  --
 *WITH BEST REGARDS :

 AASHISH SUMAN
 MCA FINAL YEAR
 *
 *NIT DURGAPUR*
 *+91-9547969906*

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 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 algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Regards :
ROHIT JALAN
B.E. Graduate,
Computer Science Department,
RVCE, Bangalore

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.