[algogeeks] Re: do this: two numbers with min diff

2010-09-23 Thread balashankar sundar
try for this {100,6,101,11}

On Sep 23, 7:40 pm, Nishant Agarwal nishant.agarwa...@gmail.com
wrote:
 int minDiff(int arr[], int arr_size)
 {
   int min_diff = arr[1] - arr[0];
   int max_element = arr[0];
   int i;
   for(i = 1; i  arr_size; i++)
   {
     if(arr[i] - max_element  min_diff)
       min_diff = arr[i] - max_element;
     if(arr[i]  max_element)
          max_element = arr[i];
   }
   return min_diff;

 }

 On Mon, Sep 20, 2010 at 10:38 AM, Srinivas 
 lavudyasrinivas0...@gmail.comwrote:





  2 nos with min diff
  given an array of size n. find 2 numbers from array whose difference
  is least in O(n) w/o
  using xtra space( i mean constant space)

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

 --
  :-)
 *
 Nishant Agarwal
 Computer Science and Engineering
 NIT Allahabad
 *- Hide quoted text -

 - Show quoted text -

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@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] Re: Binary tree to LL

2010-08-27 Thread balashankar sundar
head=new node;//head node to list,T is root to the tree
join=head;//global variable


inorder(T)
{
if(T==0)
return;
inorder(t-l);
join-l=T;
join=join-l;
inorder(T-r);
}

head=head-l;
end;

On Aug 26, 10:57 pm, Rahul rv.wi...@gmail.com wrote:
 how to rearrange the pointers ??

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@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.