Re: [algogeeks] Re: amazon question

2011-02-11 Thread Gajendra Dadheech
hi,

I think we can use a stack here...

start from left of string(0 to n)
 till we don't get a ')' we will keep on pushin the elements on the
stack...
if we encounter a '0' we will pop elements till ')' if this count is 2
everytime except the last time then this is a mirror tree else not

i think this algorithm should work...


Thanks and regards,
Gajendra Dadheech
Software Engineer-I (RD)

MediaTek India Technology
Work: 120-4343900(Ext. 276)
Mobile: +91-9540646145
-
Be the change you want to see in the world -Mohandas Gandhi



On Sun, Feb 6, 2011 at 9:41 PM, jalaj jaiswal jalaj.jaiswa...@gmail.comwrote:

 @ bittu and bharath

 the tree is given in form of string





 On Sun, Feb 6, 2011 at 6:55 PM, Bharath M R catchmrbhar...@gmail.comwrote:

 bool visit(node temp1, node temp2)
 {
 if(temp1.left==null  temp2.right==null)
  return true;
 else if((temp1.left==null  temp2.right!=null) || (temp1.left!=null
  temp2.right==null))
  return false;
 else
  return visit(temp1.left,temp2.right);

-- do the same for temp1.right and temp2.left
 }

 Just check whether root. left and root.right are not null and pass it the
 visit function.




  --
 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.




 --
 With Regards,
 *Jalaj Jaiswal* (+919019947895)
 Final Year Undergraduate,
 IIIT ALLAHABAD

   --
 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.



Re: [algogeeks] numbers

2011-02-11 Thread Gajendra Dadheech
Hi,

I think you can run a loop over array and in each iteration count the number
of 1's by masking with 1 and shifting the number. if number does not end
with zero then keep on counting ... else restart the count in next number
 in each iteration compare the count with previous count..


Thanks and regards,
Gajendra Dadheech
Software Engineer-I (RD)

MediaTek India Technology
Work: 120-4343900(Ext. 276)
Mobile: +91-9540646145
-
Be the change you want to see in the world -Mohandas Gandhi



On Thu, Feb 10, 2011 at 2:32 PM, jalaj jaiswal jalaj.jaiswa...@gmail.comwrote:


 There is very long array of ints, and you are given pointer to base addr of
 this array.. each int is 16bit representation... you need to return the
 pointer to tht bit inside array where longest sequence of 1s start

 take this simple example:
 Array = {15,7,2,1,0,23}
 ,0111,0010,0001,,10111
 ^
 Result: Pointer should point to 1st bit of number 15.


 another example : ,0111,0011,1110,,10111
_
 third index from starting is
 the answer i.e i=2 , if i start from 0 as it has maximum 1's(5)
 --
 With Regards,
 *Jalaj Jaiswal* (+919019947895)
 Software developer, Cisco Systems
 Final Year Undergraduate,
 IIIT ALLAHABAD

  --
 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.



Re: [algogeeks] Re: one more from amazon

2011-02-08 Thread Gajendra Dadheech
@shashank
i think there are some duplicate outputs by this algorithm (112,211)...

Thanks and regards,
Gajendra Dadheech



On Mon, Feb 7, 2011 at 2:29 PM, bittu shashank7andr...@gmail.com wrote:

 @gajendra

 i found that its basically combination problem
 we have to print all combination of all number  in given range that
 can compose a given number

 Examples:
 For n = 1, the program should print following:
 1

 For n = 2, the program should print following:
 1 1
 2

 For n = 3, the program should print following:
 1 1 1
 1 2
 2 1
 3

 For n = 4, the program should print following:
 1 1 1 1
 1 1 2
 1 2 1
 1 3
 2 1 1
 2 2
 3 1

 and so on …

 Algorithm:
 At first position we can have three numbers 1 or 2 or 3.
 First put 1 at first position and recursively call for n-1.
 Then put 2 at first position and recursively call for n-2.
 Then put 3 at first position and recursively call for n-3.
 If n becomes 0 then we have formed a combination that compose n, so
 print the current combination

 You Can Find generalized Code here You Can make it Customize acc. to
 your recq.

 http://codepad.org/uw2K9a2c

 Thanks  Rergards
 Shashank Mani   The best way to escape from a problem is to solve
 it.

 --
 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.



Re: [algogeeks] Re: Amazon interview quesiton

2011-02-06 Thread Gajendra Dadheech
I gues jalaj's solun works perfect.



Thanks and regards,
Gajendra Dadheech




On Sun, Feb 6, 2011 at 4:06 PM, jalaj jalaj.jaiswa...@gmail.com wrote:

 use a stack for this
 {
 //let preorder traversal of a tree be in a array t
 for(i = t.length; i-1; i--){

 if(t(i) == L){
 stack.push(t[i]);
 }else{
 leftChild = s.pop(); // will return null if stack is empty
 rightChild = s.pop(); // will return null if stack is empty
 node = new Node(leftChild, rightChild);
 stack.push(node);
 }

 }

 root = stack.pop(); // get the root from the stack;
 }

 On Feb 6, 3:03 pm, algoseeker newton.anu...@gmail.com wrote:
  I also encountered this question yesterday. This is my solution which i
  tested for a few sample cases.
 
  https://github.com/algoseeker/Interview/blob/master/Node.java
 
  I maintained a pointer to the Node where there should be creation of a
 new
  node. If the node created is left child, shift the pointer to new node
  created. If this new Node's right child gets created, shift the pointer
 to
  the parent of this Node.

 --
 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.



Re: [algogeeks] Microsoft

2011-02-06 Thread Gajendra Dadheech
algo fails for following input set
20,18,1,7,2

Thanks and regards,
Gajendra Dadheech




On Sun, Feb 6, 2011 at 6:32 PM, coolfrog$
dixit.coolfrog.div...@gmail.comwrote:

 @Decipher
 Microsoft is coming in over college.. can you Give some more question which
 are recently asked ...in MS test...
 @everone.. do share question of MS if some body has given the recently this
 Test..

 Algorithm:
 1. maintain min_diff so far
 2. maintain max_element so far
  complexity is O(n) , and space == O(1)
 #includestdio.h
 #includeconio.h
 #includestdlib.h
 int minDiff(int arr[], int arr_size)
 {
   int min_diff = abs(arr[1] - arr[0]);
   int max_element = arr[0];
   int i;
   for(i = 1; i  arr_size; i++)
   {
 if(abs(arr[i] - max_element)  min_diff)
   min_diff = abs(arr[i] - max_element);
 if(arr[i]  max_element)
  max_element = arr[i];
   }
   return min_diff;
 }


 int main()
 {
   int arr[] = {5, 13, 7, 0, 10,20,1,15,4,19};
   printf(Maximum difference is %d,  minDiff(arr, 10));
   getchar();
   return 0;

 }

 On Sun, Feb 6, 2011 at 3:37 PM, Abhijit K Rao abhijitkrao...@gmail.comwrote:

 How about , using a sorting algorithm like Quick sort and return diff of
 last and the before last element.

 Best Regards
 Abhijit



 On Sun, Feb 6, 2011 at 3:29 PM, Decipher ankurseth...@gmail.com wrote:


 Algorithm to find the two numbers whose difference is minimum among the
 set of numbers.

 For example the sequence is 5, 13, 7, 0, 10, 20, 1, 15, 4, 19

 The algorithm should return min diff = 20-19 = 1.

 Constraint - Time Complexity O(N)  Space is not a constraint [upto
 O(3N)]


  --
 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.




 --
 *Divesh*
 (¨`·.·´¨) Always
   `·.¸(¨`·.·´¨ ) Keep
   (¨`·.·´¨)¸.·´Smiling!
`·.¸.·´ Life can give u 100's of reason 2cry,but u can give life 1000's

 of reasons 2Smile

  --
 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.



[algogeeks] one more from amazon

2011-02-06 Thread Gajendra Dadheech
Write a function to print all unique partitions on n tht are of size m. eg:
n=10, m=4. it should print 7 1 1 1, 6 2 1 1, 5 3 1 1, 3 3 2 2,, so on



Thanks and regards,
Gajendra Dadheech
hi

-- 
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] o/p

2011-02-06 Thread Gajendra Dadheech
i think it will be 34...

Thanks and regards,
Gajendra Dadheech




On Sun, Feb 6, 2011 at 10:15 PM, jalaj jaiswal jalaj.jaiswa...@gmail.comwrote:

 @ranjane
 the value of i will not change as ++ptr will execute first.
 but i wonder if a char pointer can be used to store integer address... will
 it be an error ?


 On Sun, Feb 6, 2011 at 10:09 PM, ranjane ranjane...@gmail.com wrote:

 what s the o/p of the followin pgm?

 main()
 {
 int i=300;
 char *ptr;
 ptr=i;
 *++ptr=2;
 printf(%d,i);
 }

 --
 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.




 --
 With Regards,
 *Jalaj Jaiswal* (+919019947895)
 Final Year Undergraduate,
 IIIT ALLAHABAD

   --
 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.



Re: [algogeeks] one more from amazon

2011-02-06 Thread Gajendra Dadheech
Can someone explain the logic behind this


Thanks and regards,
Gajendra Dadheech




On Mon, Feb 7, 2011 at 7:10 AM, Sreeprasad Govindankutty 
sreeprasad...@gmail.com wrote:

 If duplicate values are allowed  ::

 import java.io.BufferedReader;
 import java.io.InputStreamReader;

 public class PartionNumber {

 public static void main(String[] args) {
 System.out.println(Enter the number);
 InputStreamReader ifn = new InputStreamReader(System.in);
 BufferedReader buf = new BufferedReader(ifn);
 try{
 String n =buf.readLine();
 int number = Integer.parseInt(n);
 int i=-1;
 functionPartion(number,i);
 System.out.println(0 +number);
 }catch(Exception e){
  e.printStackTrace();
 }

 }

 private static void  functionPartion(int number,int a) {
   a=a+1;
  if(number!=0){
  System.out.println(number+   +a);
  functionPartion(number-1, a);

  }
 }

 }




 Thanks and many regards,
 Sreeprasad




 On Sun, Feb 6, 2011 at 7:29 PM, Wei.QI qiw...@gmail.com wrote:

  public static ArrayListArrayListInteger Partition(int val, int start,
 int size) {

   ArrayListArrayListInteger r = new ArrayListArrayListInteger();

   if (start * size  val) {
return null;
   }

   if(size == 1)
   {
r.add(new ArrayListInteger());
r.get(0).add(val);
return r;
   }

   for (int i = start; i = val/size; i++) {
ArrayListArrayListInteger tr = Partition(val - i, i, size - 1);
if (tr != null) {
 for (int j = 0; j  tr.size(); j++) {
  ArrayListInteger subr = tr.get(j);
  subr.add(i);
 }
 r.addAll(tr);
}
   }
   return r;

  }

 On Sun, Feb 6, 2011 at 7:51 AM, Gajendra Dadheech gajju3...@gmail.comwrote:

 Write a function to print all unique partitions on n tht are of size m.
 eg: n=10, m=4. it should print 7 1 1 1, 6 2 1 1, 5 3 1 1, 3 3 2 2,, so on



 Thanks and regards,
 Gajendra Dadheech
 hi

 --
 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.


  --
 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.



Re: [algogeeks] what will be the output

2011-02-05 Thread Gajendra Dadheech
@priya u seems to be a beginner in c programming...
I would suggest u to go through Dennis richie.

Thanks and regards,
Gajendra Dadheech



On Sat, Feb 5, 2011 at 2:53 PM, Manmeet Singh mans.aus...@gmail.com wrote:

 because u not thinking of operator precedence :P :P


 On Sat, Feb 5, 2011 at 2:52 PM, priya mehta priya.mehta...@gmail.comwrote:

 why is this happening?



 On Sat, Feb 5, 2011 at 2:51 PM, Manmeet Singh mans.aus...@gmail.comwrote:

 8, 32, 96

 On Sat, Feb 5, 2011 at 2:46 PM, priya mehta priya.mehta...@gmail.comwrote:

 #include stdio.h
   #define PrintInt(expr) printf(%s : %d\n,#expr,(expr))





   *int* FiveTimes(*int* a)
   {
   *int* t;





   t *=* a**2 *+* a;





   *return* t;
   }

   *int* main()
   {
   *int* a *=* 1, b *=* 2,c *=* 3;





   PrintInt(FiveTimes(a));
   PrintInt(FiveTimes(b));





   PrintInt(FiveTimes(c));
   *return* 0;
   }

  --
 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.comalgogeeks%2bunsubscr...@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.comalgogeeks%2bunsubscr...@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.comalgogeeks%2bunsubscr...@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.comalgogeeks%2bunsubscr...@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.



Re: [algogeeks]

2011-02-05 Thread Gajendra Dadheech
20,1 this would be output

Thanks and regards,
Gajendra Dadheech
Software Engineer-I (RD)

MediaTek India Technology
Work: 120-4343900(Ext. 276)
Mobile: +91-9540646145
-
Be the change you want to see in the world -Mohandas Gandhi



On Sat, Feb 5, 2011 at 6:11 PM, vaibhav agrawal agrvaib...@gmail.comwrote:

 @ankit: how x is 20?


 On Sat, Feb 5, 2011 at 4:46 PM, ankit sablok ankit4...@gmail.com wrote:

 x is 20 for sure and y i m guessing to be 1 comma operator and 0 used for
 octal constnts


 On Sat, Feb 5, 2011 at 3:01 PM, radha krishnan 
 radhakrishnance...@gmail.com wrote:

 guess the output

 main()
 {
 int x=(1,024),y;
 y=1,024;
 printf(%d %d,x,y);
 }

 --
 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.comalgogeeks%2bunsubscr...@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.comalgogeeks%2bunsubscr...@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.comalgogeeks%2bunsubscr...@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.



Re: [algogeeks]

2011-02-05 Thread Gajendra Dadheech
x would be 20 as when we put zero in front of any number then this is taken
as octel number and value of 024 in decimal would be 20

Thanks and regards,
Gajendra Dadheech




On Sat, Feb 5, 2011 at 6:30 PM, Gajendra Dadheech gajju3...@gmail.comwrote:

 20,1 this would be output

 Thanks and regards,
 Gajendra Dadheech
 Software Engineer-I (RD)
 
 MediaTek India Technology
 Work: 120-4343900(Ext. 276)
 Mobile: +91-9540646145
 -
 Be the change you want to see in the world -Mohandas Gandhi




 On Sat, Feb 5, 2011 at 6:11 PM, vaibhav agrawal agrvaib...@gmail.comwrote:

 @ankit: how x is 20?


 On Sat, Feb 5, 2011 at 4:46 PM, ankit sablok ankit4...@gmail.com wrote:

 x is 20 for sure and y i m guessing to be 1 comma operator and 0 used for
 octal constnts


 On Sat, Feb 5, 2011 at 3:01 PM, radha krishnan 
 radhakrishnance...@gmail.com wrote:

 guess the output

 main()
 {
 int x=(1,024),y;
 y=1,024;
 printf(%d %d,x,y);
 }

 --
 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.comalgogeeks%2bunsubscr...@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.comalgogeeks%2bunsubscr...@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.comalgogeeks%2bunsubscr...@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.



[algogeeks] Good question

2011-02-05 Thread Gajendra Dadheech
Calculate size of a data type without using sizeof and without declaring any
variable of it


Thanks and regards,
Gajendra Dadheech

-- 
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] Amazon interview quesiton

2011-02-05 Thread Gajendra Dadheech
A special type of tree is given, where all leaf are marked with L and others
are marked with N. every node can have 0 or at most 2 nodes. Trees preorder
is given, create tree from that traversal.



Thanks and regards,
Gajendra Dadheech

-- 
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: minimum no. of clicks

2011-02-02 Thread Gajendra Dadheech
hi,
I suppose this could be solved in O(n) time if we use hash table. although
the space complexity will increase

Thanks and regards,
Gajendra Dadheech




On Thu, Feb 3, 2011 at 12:47 AM, Dave dave_and_da...@juno.com wrote:

 @Srikar: You need to read what I said more carefully. An O(n log n)
 algorithm was proposed. I merely pointed out that it could not be
 optimal, since a trivial algorithm is O(n). I didn't say anything
 about the trivial algorithm being optimal or the solution to the
 problem.

 Dave

 On Feb 2, 12:33 pm, Srikar srikar2...@gmail.com wrote:
  hey dave! what do you mean naively clicking  O(n)? Can you explain the
  exact algo?
 
  If you read the question properly, you should realize that it requires
 the
  minimum clicks.
  Naively clicking is not going to give you minimum clicks.
 
 
 
  On Wed, Feb 2, 2011 at 3:21 AM, Dave dave_and_da...@juno.com wrote:
   @Srikar: Isn't it sort of silly to propose an O(n log n) algorithm
   when just naively clicking on the digits in order gives an O(n)
   algorithm?
 
   Dave
 
   On Feb 1, 12:04 pm, Srikar srikar2...@gmail.com wrote:
Could I sort it? Oh you mentioned that the original array could be
destroyed.
 
In that case,
 
1) Sort the array - O(nlogn)
2) loop through the array. if contiguous elements are same remove all
 of
them in one click else remove only that element. - O(n)
 
Time - O(nlogn)
space - O(1)
 
On Tue, Feb 1, 2011 at 7:23 PM, snehal jain learner@gmail.com
   wrote:
 You are given an array A of length N. You have to destroy it, given
 that you have the power to remove any continuous chunk of same
 numbers
 with 1 click. Thus the order in which you remove chunk matters. For
 example given {1, 2, 3, 1} normally it will take you 4 clicks to
 remove but if you first remove 2 making array {1, 3, 1} then 3
 making
 it {1, 1} and then you can remove this continuous chunk of similar
 number in one click, thus completing the task in 3 clicks. How to
 find
 minimum number of clicks required? Another example is {1, 2, 3, 2,
 1}
 which can be destroyed in 3 clicks
 
 --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 algogeeks%2Bunsubscribe@googlegroups­.com
   algogeeks%2Bunsubscribe@googlegroups­.com
 .
 For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.-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 algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 algogeeks%2Bunsubscribe@googlegroups­.com
   .
   For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.- 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 algogeeks@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.



-- 
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] Puzzle to Puzzle you Part _ 1

2011-02-02 Thread Gajendra Dadheech
These are quite old puzzles buddy. He take 10 cards from the pile and
reverse them. SOLVED

Thanks and regards,
Gajendra Dadheech



On Thu, Feb 3, 2011 at 9:02 AM, Ricky rajeevpo...@gmail.com wrote:

 Hi,

 I have come up with one interesting puzzle so I thought of discussing
 with you guys:

 A blind man is given deck of 52 cards with 10 card facing up and rest
 are facing down. He need to create two piles not necessarily of same
 height in order to have same number of up cards in both.

 I would publish the solution one I got some good replies..

 BTW: I will publish some more puzzles once I found that members are
 liking these puzzles..

 Thanks!!

 --
 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.comalgogeeks%2bunsubscr...@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.