[algogeeks] Adobe 2010 Written Test C Development

2010-12-21 Thread bittu
Write a function getBits that gives bits from a given position p of a
given number n.

Diff between typedef and #define?


Suggest DS for polynomials. Write C program to add two polynomials.

Regards
Shashank

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



Re: [algogeeks] Adobe Interview Question

2010-12-21 Thread dinesh bansal
If we rewrite question in terms of Probability, call to foo2() depends on
two events:
1. (E1) A  B, probablity 75%.
2. (E2) C  D, again probability 75%.

Probability (E) = Prob(E1) * Prob(E2) = 75/100 * 75/100 * 5000 = 2812.50
times.

Correct me if wrong.
- Dinesh Bansal

On Wed, Dec 15, 2010 at 12:36 AM, bittu shashank7andr...@gmail.com wrote:


 void foo1()
 {
  if(AB)
Then {_/* */}
  else
   if(CD)
 then foo2()
 }

 How many time foo2() would get called given
 AB 25% of the times and CD 75% of the times and foo1() is called
 5000 times

 although i had diff...solution..but i wants to confirm wid others..so
 hav a look

 Regards
 Shashank Mani
 BIT Mesra

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




-- 
Dinesh Bansal
The Law of Win says, Let's not do it your way or my way; let's do it the
best way.

-- 
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: Adobe Interview Question

2010-12-21 Thread bittu
@ashish. u r getting wrong if  else makes complete unit so if 1
fails other executes..no doubt in these..its not tough as much as u
taking it


what ii think some guys r right  i got same solution..i don't thinsg
to xplain  becoz, kathir,ankur has xplained same...  answer will be

2812


Thanks  Regards
Shashank Mani Narayan  Don't B Evil U can Earn While U Learn
Birla Institue of Technology,Mesra
Computer Science  Engineering
Cell +91-9740852296

-- 
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: Adobe 2010 Written Test C Development

2010-12-21 Thread juver++
1. int getBits(int n, int p) { return (n  p)  1; }
2. use internet
3. depends, may be linked list of terms or array of coefficients.

-- 
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] HP Question

2010-12-21 Thread bittu


Which one is the efficient sorting technique for arranging the books
in a library?

a) Bubble Sort
b) Selection Sort
c) Insertion Sort
d) Heap Sort


Regards
Shashank

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




Re: [algogeeks] Re: celebrity twitters

2010-12-21 Thread bhupendra dubey
let S be the set containing n people
int i=0,j=n-1;
while(i!=j)
{
  *ask S[i] if he knows S[j]*/
if(YES)
i++;//if yes then S[i] cant be the celebrity take him
out of the equation
   else
j--; //if no then S[j] cant be the celebrity so let him
pass
}

S[i]  or S[j] gives the celebrity in the set;

Complexity:
(max no of  times  i can be incremented)+(max no of times j can be
decremented)=n
no of questions=n
so O(n)

Bhupendra Dubey

DELHI COLLEGE OF  ENGINEERING

On Tue, Dec 21, 2010 at 9:26 AM, sharat sharath.channaha...@gmail.comwrote:

 It can be thought of as a binary tree
 Assume n=8.

 At first level all 8 people are present, i.e leaves of the tree. 1
 asks 2 if 2 knows 1, 3 asks 4 if 4 knows 3 etc ..
 If 2 knows 1, then 1 goes to next level, else 2. Thus n/2 questions
 are asked at level 1 and the height will be log(n). The total
 questions asked will n.

 1   2   3   4   5   6   7   8
   145  8
1 5  8
  5   8
8
 On Dec 19, 4:25 pm, Senthilnathan Maadasamy
 senthilnathan.maadas...@gmail.com wrote:
  Note that there cannot be more than one celebrity in the group.
 
  Here is an O(n) solution:
 
   Choose a random candidate x as a possible celebrity.
   Let S be the set of remaining n-1 candidates.
 
   While (S is not empty)
   Remove another candidate y from S and ask if y follows x.
   If y follows x, y is not a celebrity.
   If y does not follow x, x is not a celebrity and hence
 let
  y be the new x.
 
After this, we are left with only one possible celebrity x.  We
 still
  need to verify if x is actually a celebrity.
Check if the remaining n-1 candidates follow x.
  If yes, x is a celebrity.
  If no, there is no celebrity in the group.

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




-- 
bhupendra dubey

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



Re: [algogeeks] Re: fibonacci problem

2010-12-21 Thread Shalini Sah
Thnx a lot !

On Tue, Dec 21, 2010 at 1:18 AM, Dave dave_and_da...@juno.com wrote:

 @Shalini: You can find a table of Fibonacci numbers at
 http://en.wikipedia.org/wiki/Fibonacci_number#List_of_Fibonacci_numbers.
 You will notice that every third number in the sequence is even, and
 that there are only 11 even ones less than 4 million. So grab some
 paper and a pencil or your calculator and add them up.

 Dave

 On Dec 20, 9:06 am, Shalini Sah shalinisah.luv4cod...@gmail.com
 wrote:
  Each new term in the Fibonacci sequence is generated by adding the
 previous
  two terms. By starting with 1 and 2, the first 10 terms will be:
 
  1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
 
  Find the sum of all the even-valued terms in the sequence which do not
  exceed four million. I'm just a beginner..plz help.

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



-- 
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: bits groups

2010-12-21 Thread bittu
Convert the given number in to binary  and stored into every bit into
array
now compare the a[i]==0 if true then print that value that is nithing
but zero else number doesn't has zero in its binary form.

e.g code is given below

int binary_zero(int n)
{

for(int i=0;iarraylength;i++)
{
a[i]=n%2;
if(ai[i]==0)
true;//take action
count_zero++

else
false//take action..
count_one++;

n=n/2;
}


}


Regards
Shashank Mani
Birla Istitue of Technology,Mesra
Computer Science Engg.
Cell No.+91-9740852296

-- 
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: bits groups

2010-12-21 Thread bittu
hey in last program i forget to take a variable that the position of
one  so that we can print zero groups


shashank

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



Re: [algogeeks] Re: bits groups

2010-12-21 Thread shubham singh
u can see topcoder and codechef tutorials may help

-- 
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] smallest cycle

2010-12-21 Thread snehal jain
The question is to find the length of the smallest cycle in a
bipartite graph G=(V,E) (V - vertices, E - edges).

Required time complexity: O(|V|^2)

A given graph is bipartite iff it has no odd length cycles.

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



Re: [algogeeks] Re: Adobe Interview Question

2010-12-21 Thread Ashish Goel
Dear Shashank


What will get executed if AB and CD, then will foo2 get executed? NO
In worst cast(when AB and CD happens at same time i.e.25%), the foo2 fn
will get executed 50% i.e. 2500 times

Don't get me wrong, but closed mind is one of the reason people get
rejected.

Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652


On Tue, Dec 21, 2010 at 5:31 PM, bittu shashank7andr...@gmail.com wrote:

 @ashish. u r getting wrong if  else makes complete unit so if 1
 fails other executes..no doubt in these..its not tough as much as u
 taking it


 what ii think some guys r right  i got same solution..i don't thinsg
 to xplain  becoz, kathir,ankur has xplained same...  answer will be

 2812


 Thanks  Regards
 Shashank Mani Narayan  Don't B Evil U can Earn While U Learn
 Birla Institue of Technology,Mesra
 Computer Science  Engineering
 Cell +91-9740852296

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



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



Re: [algogeeks] HP Question

2010-12-21 Thread Ankur Khurana
insertion sort in IMHO

On Tue, Dec 21, 2010 at 5:44 PM, bittu shashank7andr...@gmail.com wrote:


 Which one is the efficient sorting technique for arranging the books
 in a library?

 a) Bubble Sort
 b) Selection Sort
 c) Insertion Sort
 d) Heap Sort


 Regards
 Shashank

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



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



Re: [algogeeks] smallest cycle

2010-12-21 Thread Chi
Fleury algorithm. 

- Ursprüngliche Mitteilung -
 The question is to find the length of the smallest cycle in a
 bipartite graph G=(V,E) (V - vertices, E - edges).
 
 Required time complexity: O(|V|^2)
 
 A given graph is bipartite iff it has no odd length cycles.
 
 -- 
 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.
 

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



Re: [algogeeks] HP Question

2010-12-21 Thread bhupendra dubey
insertion sort

On Tue, Dec 21, 2010 at 6:49 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote:

 insertion sort in IMHO

 On Tue, Dec 21, 2010 at 5:44 PM, bittu shashank7andr...@gmail.com wrote:
 
 
  Which one is the efficient sorting technique for arranging the books
  in a library?
 
  a) Bubble Sort
  b) Selection Sort
  c) Insertion Sort
  d) Heap Sort
 
 
  Regards
  Shashank
 
  --
  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.
 
 

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




-- 
bhupendra dubey

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



Re: [algogeeks] Re: Adobe Interview Question

2010-12-21 Thread Ankur Khurana
ashish , nobody is fighting here , but are u sure you are clear on
your probability concepts ? independent events do multiply .
what is the probability that when we toss three coins , we get all three heads ?

On Tue, Dec 21, 2010 at 6:45 PM, Ashish Goel ashg...@gmail.com wrote:
 Dear Shashank

 What will get executed if AB and CD, then will foo2 get executed? NO
 In worst cast(when AB and CD happens at same time i.e.25%), the foo2 fn
 will get executed 50% i.e. 2500 times
 Don't get me wrong, but closed mind is one of the reason people get
 rejected.
 Best Regards
 Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652


 On Tue, Dec 21, 2010 at 5:31 PM, bittu shashank7andr...@gmail.com wrote:

 @ashish. u r getting wrong if  else makes complete unit so if 1
 fails other executes..no doubt in these..its not tough as much as u
 taking it


 what ii think some guys r right  i got same solution..i don't thinsg
 to xplain  becoz, kathir,ankur has xplained same...  answer will be

 2812


 Thanks  Regards
 Shashank Mani Narayan  Don't B Evil U can Earn While U Learn
 Birla Institue of Technology,Mesra
 Computer Science  Engineering
 Cell +91-9740852296

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


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


-- 
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] shortest distance

2010-12-21 Thread snehal jain
Given a chessboard in which it is not known how the black and white
boxes are arranged but it is sure that there will 32 black squares and
32 white squares. You have to find the least possible distance between
any two squares of same colour.

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



Re: [algogeeks] Re: Adobe Interview Question

2010-12-21 Thread Ashish Goel
this is not probability purely...there is an else in between :)
why don't you write the program and test it out yourself :)




Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652


On Tue, Dec 21, 2010 at 6:52 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote:

 ashish , nobody is fighting here , but are u sure you are clear on
 your probability concepts ? independent events do multiply .
 what is the probability that when we toss three coins , we get all three
 heads ?

 On Tue, Dec 21, 2010 at 6:45 PM, Ashish Goel ashg...@gmail.com wrote:
  Dear Shashank
 
  What will get executed if AB and CD, then will foo2 get executed? NO
  In worst cast(when AB and CD happens at same time i.e.25%), the foo2 fn
  will get executed 50% i.e. 2500 times
  Don't get me wrong, but closed mind is one of the reason people get
  rejected.
  Best Regards
  Ashish Goel
  Think positive and find fuel in failure
  +919985813081
  +919966006652
 
 
  On Tue, Dec 21, 2010 at 5:31 PM, bittu shashank7andr...@gmail.com
 wrote:
 
  @ashish. u r getting wrong if  else makes complete unit so if 1
  fails other executes..no doubt in these..its not tough as much as u
  taking it
 
 
  what ii think some guys r right  i got same solution..i don't thinsg
  to xplain  becoz, kathir,ankur has xplained same...  answer will be
 
  2812
 
 
  Thanks  Regards
  Shashank Mani Narayan  Don't B Evil U can Earn While U Learn
  Birla Institue of Technology,Mesra
  Computer Science  Engineering
  Cell +91-9740852296
 
  --
  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.
 
 
  --
  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.
 

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



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



Re: [algogeeks] Re: Adobe Interview Question

2010-12-21 Thread Ankur Khurana
can you provide the test cases ?
between ,
btw answer my question abt the tosses. plus closed mind argument goes
both ways. i have tried to explain.
if you dont want to understand , it is nobody's prob.wont comment
further on this topic.

On Tue, Dec 21, 2010 at 6:55 PM, Ashish Goel ashg...@gmail.com wrote:
 this is not probability purely...there is an else in between :)
 why don't you write the program and test it out yourself :)



 Best Regards
 Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652


 On Tue, Dec 21, 2010 at 6:52 PM, Ankur Khurana ankur.kkhur...@gmail.com
 wrote:

 ashish , nobody is fighting here , but are u sure you are clear on
 your probability concepts ? independent events do multiply .
 what is the probability that when we toss three coins , we get all three
 heads ?

 On Tue, Dec 21, 2010 at 6:45 PM, Ashish Goel ashg...@gmail.com wrote:
  Dear Shashank
 
  What will get executed if AB and CD, then will foo2 get executed? NO
  In worst cast(when AB and CD happens at same time i.e.25%), the foo2
  fn
  will get executed 50% i.e. 2500 times
  Don't get me wrong, but closed mind is one of the reason people get
  rejected.
  Best Regards
  Ashish Goel
  Think positive and find fuel in failure
  +919985813081
  +919966006652
 
 
  On Tue, Dec 21, 2010 at 5:31 PM, bittu shashank7andr...@gmail.com
  wrote:
 
  @ashish. u r getting wrong if  else makes complete unit so if 1
  fails other executes..no doubt in these..its not tough as much as u
  taking it
 
 
  what ii think some guys r right  i got same solution..i don't thinsg
  to xplain  becoz, kathir,ankur has xplained same...  answer will be
 
  2812
 
 
  Thanks  Regards
  Shashank Mani Narayan  Don't B Evil U can Earn While U Learn
  Birla Institue of Technology,Mesra
  Computer Science  Engineering
  Cell +91-9740852296
 
  --
  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.
 
 
  --
  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.
 

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


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


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



Re: [algogeeks] Re: Adobe Interview Question

2010-12-21 Thread Ashish Goel
test

a] AB, CD
b] AB, CD
c] A=B, CD,
d] AB, CD
e] AB, CD
f] A=B, CD
g] A=B, C=D


AB is 25% means the case could be a or d 25% in both cases CD does not
get executed as if condition is satisfied
and CD is 75% means case could be a or b or c. in case a foo2 will not get
executed but in b,c it will.
in worst case when AB, CD for 25%(as this is worst case), foo2 will not
get executed.This implies that other than this there are 50% cases where CD
(case b,c)

I hope it is clear now. At this juncture i do not need to refresh my
fundamentals for probability, if need arise i will :)



Best Regards
Ashish Goel
Principle Architect, PMP

Think positive and find fuel in failure
+919985813081
+919966006652


On Tue, Dec 21, 2010 at 7:00 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote:

 can you provide the test cases ?
 between ,
 btw answer my question abt the tosses. plus closed mind argument goes
 both ways. i have tried to explain.
 if you dont want to understand , it is nobody's prob.wont comment
 further on this topic.

 On Tue, Dec 21, 2010 at 6:55 PM, Ashish Goel ashg...@gmail.com wrote:
  this is not probability purely...there is an else in between :)
  why don't you write the program and test it out yourself :)
 
 
 
  Best Regards
  Ashish Goel
  Think positive and find fuel in failure
  +919985813081
  +919966006652
 
 
  On Tue, Dec 21, 2010 at 6:52 PM, Ankur Khurana ankur.kkhur...@gmail.com
 
  wrote:
 
  ashish , nobody is fighting here , but are u sure you are clear on
  your probability concepts ? independent events do multiply .
  what is the probability that when we toss three coins , we get all three
  heads ?
 
  On Tue, Dec 21, 2010 at 6:45 PM, Ashish Goel ashg...@gmail.com wrote:
   Dear Shashank
  
   What will get executed if AB and CD, then will foo2 get executed? NO
   In worst cast(when AB and CD happens at same time i.e.25%), the foo2
   fn
   will get executed 50% i.e. 2500 times
   Don't get me wrong, but closed mind is one of the reason people get
   rejected.
   Best Regards
   Ashish Goel
   Think positive and find fuel in failure
   +919985813081
   +919966006652
  
  
   On Tue, Dec 21, 2010 at 5:31 PM, bittu shashank7andr...@gmail.com
   wrote:
  
   @ashish. u r getting wrong if  else makes complete unit so if 1
   fails other executes..no doubt in these..its not tough as much as u
   taking it
  
  
   what ii think some guys r right  i got same solution..i don't thinsg
   to xplain  becoz, kathir,ankur has xplained same...  answer will be
  
   2812
  
  
   Thanks  Regards
   Shashank Mani Narayan  Don't B Evil U can Earn While U Learn
   Birla Institue of Technology,Mesra
   Computer Science  Engineering
   Cell +91-9740852296
  
   --
   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.
  
  
   --
   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.
  
 
  --
  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.
 
 
  --
  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.
 

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



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

Re: [algogeeks] Re: Adobe Interview Question

2010-12-21 Thread Ankur Khurana
CD was 75%. no ?

On Tue, Dec 21, 2010 at 7:16 PM, Ashish Goel ashg...@gmail.com wrote:
 test
 a] AB, CD
 b] AB, CD
 c] A=B, CD,
 d] AB, CD
 e] AB, CD
 f] A=B, CD
 g] A=B, C=D

 AB is 25% means the case could be a or d 25% in both cases CD does not
 get executed as if condition is satisfied
 and CD is 75% means case could be a or b or c. in case a foo2 will not get
 executed but in b,c it will.
 in worst case when AB, CD for 25%(as this is worst case), foo2 will not
 get executed.This implies that other than this there are 50% cases where CD
 (case b,c)
 I hope it is clear now. At this juncture i do not need to refresh my
 fundamentals for probability, if need arise i will :)


 Best Regards
 Ashish Goel
 Principle Architect, PMP
 Think positive and find fuel in failure
 +919985813081
 +919966006652


 On Tue, Dec 21, 2010 at 7:00 PM, Ankur Khurana ankur.kkhur...@gmail.com
 wrote:

 can you provide the test cases ?
 between ,
 btw answer my question abt the tosses. plus closed mind argument goes
 both ways. i have tried to explain.
 if you dont want to understand , it is nobody's prob.wont comment
 further on this topic.

 On Tue, Dec 21, 2010 at 6:55 PM, Ashish Goel ashg...@gmail.com wrote:
  this is not probability purely...there is an else in between :)
  why don't you write the program and test it out yourself :)
 
 
 
  Best Regards
  Ashish Goel
  Think positive and find fuel in failure
  +919985813081
  +919966006652
 
 
  On Tue, Dec 21, 2010 at 6:52 PM, Ankur Khurana
  ankur.kkhur...@gmail.com
  wrote:
 
  ashish , nobody is fighting here , but are u sure you are clear on
  your probability concepts ? independent events do multiply .
  what is the probability that when we toss three coins , we get all
  three
  heads ?
 
  On Tue, Dec 21, 2010 at 6:45 PM, Ashish Goel ashg...@gmail.com wrote:
   Dear Shashank
  
   What will get executed if AB and CD, then will foo2 get executed?
   NO
   In worst cast(when AB and CD happens at same time i.e.25%), the
   foo2
   fn
   will get executed 50% i.e. 2500 times
   Don't get me wrong, but closed mind is one of the reason people get
   rejected.
   Best Regards
   Ashish Goel
   Think positive and find fuel in failure
   +919985813081
   +919966006652
  
  
   On Tue, Dec 21, 2010 at 5:31 PM, bittu shashank7andr...@gmail.com
   wrote:
  
   @ashish. u r getting wrong if  else makes complete unit so if 1
   fails other executes..no doubt in these..its not tough as much as u
   taking it
  
  
   what ii think some guys r right  i got same solution..i don't
   thinsg
   to xplain  becoz, kathir,ankur has xplained same...  answer will be
  
   2812
  
  
   Thanks  Regards
   Shashank Mani Narayan  Don't B Evil U can Earn While U Learn
   Birla Institue of Technology,Mesra
   Computer Science  Engineering
   Cell +91-9740852296
  
   --
   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.
  
  
   --
   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.
  
 
  --
  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.
 
 
  --
  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.
 

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


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


-- 
You 

[algogeeks] Find the element with more than n/k occurrences

2010-12-21 Thread snehal jain
You are given an (unsorted) set of n integers. Given some k (1  k =
n), you are required to find and return the element of the set that
has more than n/k occurrences. Return None otherwise.

Required (best known) time complexity: O(n log k)

I thought of something... Lets scan each element one by one. I also
maintain a vector of sets. Initially the vector contain one empty set.

Now, as I go through the given elements, I try to insert the element
in the sets in the vector. If the element is not inserted (in case the
set already has a element of that value), i make a new set of that
element and insert it in the vector. At the end, I can see all the
elements in the set number n/k and above and we can get the result. I
think it runs in nlogK cause inserting a element in a set is logK time
(assuming a element on an average comes K times in the set).

For e.g.

say the set is 1,2,3,1,1,5,2,2

i start with a vector  {}  hving one empty set.

so it goes like {1}
{1,2}
{1,2,3}
{1,2,3},{1} ... since new 1 is not inserted in the 1st set
{1,2,3},{1},{1}
{1,2,3,5},{1},{1}
{1,2,3,5},{1,5},{1}
{1,2,3,5},{1,5,2},{1}
{1,2,3,5},{1,5,2},{1,2}

Hence all elements with occurrence 3 times or more are 1 and 2 ,...as
they belng to third set.

give ur comments

-- 
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] Maximum points on a straight line

2010-12-21 Thread snehal jain
You are given a set of 'n' points on a two dimensional plane. Now,
draw a straight line such that it can pass through maximum number of
points. Return the maximum number of points.

-- 
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: shortest distance

2010-12-21 Thread Dave
Hint: If the colors are not arranged as in a normal chess board, then
there will be at least two adjacent squares that have the same color.

Dave

On Dec 21, 7:25 am, snehal jain learner@gmail.com wrote:
 Given a chessboard in which it is not known how the black and white
 boxes are arranged but it is sure that there will 32 black squares and
 32 white squares. You have to find the least possible distance between
 any two squares of same colour.

-- 
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] random function

2010-12-21 Thread snehal jain
How do you write your own random function?

-- 
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: Maximum points on a straight line

2010-12-21 Thread Dave
Answered at http://groups.google.com/group/algogeeks/msg/d329dda12b332dd1.

Dave

On Dec 21, 8:24 am, snehal jain learner@gmail.com wrote:
 You are given a set of 'n' points on a two dimensional plane. Now,
 draw a straight line such that it can pass through maximum number of
 points. Return the maximum number of points.

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



Re: [algogeeks] Find the element with more than n/k occurrences

2010-12-21 Thread Saurabh Koar
Use count sort logic.It will be O(n). Bt space complexity matters there.

-- 
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: bits groups

2010-12-21 Thread rajessge...@yahoo.com
no need to store in array

the function can look like this

int fun(int n)
{
int i=0,count=0;
boolean set=false;
while(isizeof(n)*8)
{
if(n^1==1)
{
if(set==false)
{
count++;
set=true;
}
}
else
set=false;
n=n1;
}






On Dec 21, 6:07 pm, shubham singh shubhamsisodia0...@gmail.com
wrote:
 u can see topcoder and codechef tutorials may help

-- 
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: HP Question

2010-12-21 Thread rajessge...@yahoo.com
can u explain why and how

On Dec 21, 6:22 pm, bhupendra dubey bhupendra@gmail.com wrote:
 insertion sort

 On Tue, Dec 21, 2010 at 6:49 PM, Ankur Khurana 
 ankur.kkhur...@gmail.comwrote:









  insertion sort in IMHO

  On Tue, Dec 21, 2010 at 5:44 PM, bittu shashank7andr...@gmail.com wrote:

   Which one is the efficient sorting technique for arranging the books
   in a library?

   a) Bubble Sort
   b) Selection Sort
   c) Insertion Sort
   d) Heap Sort

   Regards
   Shashank

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

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

 --
 bhupendra dubey

-- 
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: maximize result

2010-12-21 Thread Prims
@juver

I didnt get the approach.Could you please explain for the below
expression.

3 + 6 * 7 + 3 * 2




On Dec 20, 10:46 pm, juver++ avpostni...@gmail.com wrote:
 Keep 2D arrray. For each segment (i, j) calculate min and max value for the
 subexpression.
 To do this, iterate k over (i, j), check operation at k-th position and
 choose the best one.

-- 
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] array partition

2010-12-21 Thread snehal jain
There is an array, how will you partition that into two parts so that
the sum of both the sub set is minimum

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



Re: [algogeeks] Re: maximize result

2010-12-21 Thread Saurabh Koar
@Prims:

It looks something like this:
take an array num to store:3 6 7 3 2 (sequentially as it is)
Take another array op : + * + * (sequentially as it is)
Now make a 5X5 2-D array maxResult
where maxResult[i][j] means maximum value of the subexpression form
num[i] to num[j]
Here n=5;
so u have to calculate maxResult[0][n-1]

now maxResult[i][i] will be num[i]

DP is something like this:

int calMax(i,j)
{
   if there is an entry in maxResult[i][j] then return it
   otherwise
   {
max= -(infinity)
for(k=i;kj;k++)
{
   t1=calMax(i,k);
   t2=calMax(k+1,j);
   val=t1 op_k t2;
   if(valmax)
   max=val;
}
maxresult[i][j]=val;
return maxresult[i][j];


   }
}

call
int final_max_val=calMax(0,n-1);

@juver++: Notify me if I am missing something.

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



Re: [algogeeks] Re: HP Question

2010-12-21 Thread Anuj Kumar
please whats the primary key for books in the library?

On 12/21/10, rajessge...@yahoo.com rajessge...@yahoo.com wrote:
 can u explain why and how

 On Dec 21, 6:22 pm, bhupendra dubey bhupendra@gmail.com wrote:
 insertion sort

 On Tue, Dec 21, 2010 at 6:49 PM, Ankur Khurana
 ankur.kkhur...@gmail.comwrote:









  insertion sort in IMHO

  On Tue, Dec 21, 2010 at 5:44 PM, bittu shashank7andr...@gmail.com
  wrote:

   Which one is the efficient sorting technique for arranging the books
   in a library?

   a) Bubble Sort
   b) Selection Sort
   c) Insertion Sort
   d) Heap Sort

   Regards
   Shashank

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

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

 --
 bhupendra dubey

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




-- 
Anuj Kumar
Third Year Undergraduate,
Dept. of Computer Science and Engineering
NIT Durgapur

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



Re: [algogeeks] Re: maximize result

2010-12-21 Thread juver++
Result for the max[i,j] depends not only on max[k, l] but min[k,l]. E.g. for 
/ operation maximum result is achived - division of max number by min 
number.

-- 
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: array partition

2010-12-21 Thread juver++
I think you mean absolute diffrence bewteen two sums is minimal. It's a DP 
problem.

-- 
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: Find the element with more than n/k occurrences

2010-12-21 Thread juver++
Sort the array and then process it in O(n) time.

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



Re: [algogeeks] Re: maximize result

2010-12-21 Thread Saurabh Koar
It is given in the question Given an expression E of n numbers with
*, + operations.So,I dont think that min array is required is
required in this case.

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



Re: [algogeeks] Re: HP Question

2010-12-21 Thread Srinivas Iyengar
I would use Insertion sort if the Library gurantees Insertion in O(1).
Practically, I do that in Library push a book somewhere in middle.
Then the recurrence so obtained is : T(n) = T(n-1) + O(1) which gives O(n)
time complexity.

PS: It also speaks about Lateral thinking and whatever they call it. Out of
the Box thinking :P

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



Re: [algogeeks] Re: maximize result

2010-12-21 Thread juver++
Yes, for {+,*} operations set Max state is enough.

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



Re: [algogeeks] Re: fibonacci problem

2010-12-21 Thread Lego Haryanto
Sounds like Project Euler ... problem 2, to be precise.

On Tue, Dec 21, 2010 at 4:31 AM, Shalini Sah 
shalinisah.luv4cod...@gmail.com wrote:

 Thnx a lot !


 On Tue, Dec 21, 2010 at 1:18 AM, Dave dave_and_da...@juno.com wrote:

 @Shalini: You can find a table of Fibonacci numbers at
 http://en.wikipedia.org/wiki/Fibonacci_number#List_of_Fibonacci_numbers.
 You will notice that every third number in the sequence is even, and
 that there are only 11 even ones less than 4 million. So grab some
 paper and a pencil or your calculator and add them up.

 Dave

 On Dec 20, 9:06 am, Shalini Sah shalinisah.luv4cod...@gmail.com
 wrote:
  Each new term in the Fibonacci sequence is generated by adding the
 previous
  two terms. By starting with 1 and 2, the first 10 terms will be:
 
  1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
 
  Find the sum of all the even-valued terms in the sequence which do not
  exceed four million. I'm just a beginner..plz help.

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


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




-- 
Fear of the LORD is the beginning of knowledge (Proverbs 1:7)

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



Re: [algogeeks] Re: spy in the city

2010-12-21 Thread janak
O(N) if everybody knows everybody.
O(N^2) if there is no such condition. (i.e. Ask for each person to
everybody.)


On Mon, Dec 20, 2010 at 9:43 PM, Bhavesh Chauhan chauhan.bhave...@gmail.com
 wrote:

 Every question can eliminate 1 person so you can identify the spy in N-1
 questions.

 Bhavesh



 On 19 December 2010 23:46, Dave dave_and_da...@juno.com wrote:

 Here is an algorithm:

 spy = 1
 for i = 2 to N do
if person[spy] knows person[i]
then person[i] is not the spy.
else if person[i] knows person[spy]
then person[spy] is not the spy, set spy = i
end if
 end for
 for i = 1 to spy-1 do
if (person[spy] does not know person[i]) or (person[i] knows
 person[spy])
then there is no spy, set spy = undefined, break
end if
 end for

 If there is a spy, you find him in at least 2*N - 2 questions and at
 most 4*N - 4 questions.

 Dave

 On Dec 19, 8:01 am, snehal jain learner@gmail.com wrote:
  There is a city of N people. The government learnt that some
  unfriendly nation planted a spy there. A spy possesses unique
  characteristics: he knows everybody in the city, but nobody knows him.
 
  You are a counteragent sent by the government to catch the spy. You
  may ask the people in the city only one question: Do you know the
  person X? You may ask as many people as you wish, and one person may
  be asked as many times as you wish. All the people, including the spy,
  always answer honestly.
 
  How many questions you need to find out who is the spy?

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


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


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



Re: [algogeeks] HP Question

2010-12-21 Thread Nikhil Agarwal
IMHO

1.When books are nearly sorted : Insertion sort and can be incorporated with
Shell sort technique @ O(n^1.5) provided number of books are in '000s
2.If number of books are huge in millons so its Heap sort will be better and
taking the burden of coding build heap @ O(N) is justified.This gives
O(NlogN)


On Tue, Dec 21, 2010 at 6:49 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote:

 insertion sort in IMHO

 On Tue, Dec 21, 2010 at 5:44 PM, bittu shashank7andr...@gmail.com wrote:
 
 
  Which one is the efficient sorting technique for arranging the books
  in a library?
 
  a) Bubble Sort
  b) Selection Sort
  c) Insertion Sort
  d) Heap Sort
 
 
  Regards
  Shashank
 
  --
  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.
 
 

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




-- 
Thanks  Regards
Nikhil Agarwal
Senior Undergraduate
Computer Science  Engineering,
National Institute Of Technology, Durgapur,India
http://tech-nikk.blogspot.com
http://beta.freshersworld.com/communities/nitd

-- 
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: Amazon Interview Question about Linked Lists

2010-12-21 Thread siva viknesh
ya through down pointer we can print..coz each time i m making fwd as
NULL

On Dec 20, 2:33 pm, Rishi Agrawal rishi.b.agra...@gmail.com wrote:
 See inline ..

 On Sat, Dec 18, 2010 at 12:09 PM, siva viknesh sivavikne...@gmail.comwrote:



   Given a linked list structure where every node represents a linked list
  and contains two pointers of its type:
  (i) pointer to next node in the main list.
  (ii) pointer to a linked list where this node is head.

  Write a C function to flatten the list into a single linked list.

  Eg.

  If the given linked list is
   1 -- 5 -- 7 -- 10
   |       |      |
   2     6     8
   |       |
   3     9
   |
   4

  then convert it to

   1 - 2 - 3 - 4 - 5 - 6 - 9 - 7 - 8 -10

  My solution - not tested :

  struct node
  {

    int data;

    struct node *fwd; //pointer to next node in the main list.

    struct node *down; //pointer to a linked list where this node is head.

  }*head,*temp,*temp2;

  temp=head;
  while(temp-fwd!=NULL)

  {
      temp2=temp-fwd;

      while(temp-down!=NULL)
      {

          temp=temp-down;
      }

      temp-down=temp2;

 // how will the code access the flattened linked list by down or by fwd ? In
 this case there in no particular pointer by which the code can access the
 linked list. Try to write a function to print the flattened linked list.



      temp-fwd=NULL;

      temp=temp2;

  }

  plz notify me if anything...other solutions and optimizations are welcome

  --
  Regards,
  $iva

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

 --
 Regards,
 Rishi Agrawal

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



Re: [algogeeks] Find the element with more than n/k occurrences

2010-12-21 Thread Nikhil Agarwal
There can be a simple check.

For any element to occur n/k times or more .It has occur atleast once in
every subset of (n/k)+1 size.So we take a window of n/k+1 size and set the
hash of every number equal to 1.These are the only probable elements which
can occur n/k times or more.
We move the window by n/k+1 step and increase the count of only those
elements which occured in the first window.The element which has occured at
least once in all the windows will be occuring atleast n/k times.

Complexity: Total windows: =k, window size is (n/k)+1.Gives O(k*n/k)=O(n)
time and space complexity = O((n/k)+1).

On Tue, Dec 21, 2010 at 10:02 PM, Saurabh Koar saurabhkoar...@gmail.comwrote:

 Use count sort logic.It will be O(n). Bt space complexity matters there.

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




-- 
Thanks  Regards
Nikhil Agarwal
Senior Undergraduate
Computer Science  Engineering,
National Institute Of Technology, Durgapur,India
http://tech-nikk.blogspot.com
http://beta.freshersworld.com/communities/nitd

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



Re: [algogeeks] Re: FINDSR in spoj

2010-12-21 Thread Algoose chase
Brute force :
Have 2 pointers one pointing to last character and other pointing to the
first occurrence of last character. compare the chars at the corresponding
positions and decrement both pointers. when the latter hits -1 increment the
counter and reset it to its original value. if the comparison fails at any
point reset the counter to 1 and find the position of next occurrence of
the  last char in the input string and repeat the process until both the
index reduce to 0.

@Bharath
you need to read a list of input strings terminated by * before processing
the strings.
testcase : aaabbbcccddaaabbbcccd

On Tue, Dec 7, 2010 at 12:18 PM, bharath kannan bharathgo...@gmail.comwrote:

 I tried solving that prob..here's my code

 #includeiostream
 #includestring
 using namespace std;
 main()
 {
  string s;
  cins;
  while(1)
  {
  if(s.size()==1  s[0]=='*')
break;
  int length=1,curr=0,start=0,count=1;
  for(int i=1;is.size();i++)
  {
 if(s[i]!=s[curr]  s[i]!=s[start])
 {
   curr=0;
   count=1;
   length=i+1;
 }
 else if(s[i]!=s[start]  s[i]==s[curr])
 {
   curr++;
 }
 else if(s[i]==s[start]  s[i]!=s[curr])
 {
   length=i;
   curr=0;
   count=1;
   i=i-1;
 }
 else if(s[i]==s[start]  s[i]==s[curr])
 {
if(i%length==0)
{
 count++;
 curr++;
}
else
 curr++;
 }
  }
  if(s[s.size()-1]==s[length-1])
  coutcount\n;
  else
  cout1\n;
  cins;
 }
 }

 I am getting WA..anyone pls tel a testcase where the above code
 fails..pls..

 Thanks in advance..


 On Mon, Dec 6, 2010 at 5:44 PM, alexsolo asp...@gmail.com wrote:

 http://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm

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


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


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



Re: [algogeeks] array partition

2010-12-21 Thread Nikhil Agarwal
@saurabh Sum of all the elements of subset.

On Tue, Dec 21, 2010 at 11:42 PM, Saurabh Koar saurabhkoar...@gmail.comwrote:

 sum of both the sub set is minimum  means

 sum of subset1+sum of subset = constant(=sum of the total array)
 When one decreases the other increases.

 Plzz give an example.

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




-- 
Thanks  Regards
Nikhil Agarwal
Senior Undergraduate
Computer Science  Engineering,
National Institute Of Technology, Durgapur,India
http://tech-nikk.blogspot.com
http://beta.freshersworld.com/communities/nitd

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



Re: [algogeeks] Re: subsorted array

2010-12-21 Thread mohit ranjan
@Bhupendra

Thanks for pointing it out

actually, it should be
3.now first element in A[0]..A[j-1] greater than min is 7(index 1) and *LAST
* element in
   A[k+1]A[n] less than max is 1(index 9)


if you look at code, it was proper
for( i = e+1; i  n; i++)
  {
if(arr[i]  max)
  e = i;
  }



PS: min and max are 5 and 17


A guy called lovocas asked same question in forum


Mohit



On Mon, Dec 20, 2010 at 7:43 PM, bhupendra dubey bhupendra@gmail.comwrote:

 @mohit
 suppose the input array is {4,7,8,6,5,11,13,17,0,1,2,3}

 1.first step of Ur algorithm gives j=2,k=9  (index of 8 and 1)
 2.in the second step min and max comes out to be 5 and 13
 3.now first element in A[0]..A[j-1] greater than min is 7(index 1) and
 first element in
A[k+1]A[n] less than max is 1(index 9)

 so final answer accordingly is A[1]..A[9]

 but clearly for the given input it shud be the whole array itself not
 any sub-array
 please clarify if iam wrong


 Thanx

 On Mon, Dec 20, 2010 at 10:45 AM, awesomeandroid 
 priyaranjan@gmail.com wrote:

 i have posted this problem along with solution to my blog check :

 http://code-forum.blogspot.com/2010/12/find-minimum-length-unsorted-subarray.html

 On Dec 18, 10:57 pm, snehal jain learner@gmail.com wrote:
  Given an unsorted array arr[0..n-1] of size n, find the minimum length
  subarray arr[s..e] such that sorting this subarray makes the whole
  array sorted.

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




 --
 bhupendra dubey

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


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



Re: [algogeeks] Re: Minimum Triplet Distance

2010-12-21 Thread Nikhil Agarwal
@Swapnil I got a counter example for my approach.By O(8) i mean O(c) c: a
constant leading to O(1).

On Tue, Dec 21, 2010 at 2:10 AM, Saurabh Koar saurabhkoar...@gmail.comwrote:

 @yq: Can u plzz inform what was ur approach/logic while deriving the
 condition that index will be increased of that array which contains
 minimum of three elements to get the desired ans?
 It will be very helpful.Thanks in advance.

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




-- 
Thanks  Regards
Nikhil Agarwal
Senior Undergraduate
Computer Science  Engineering,
National Institute Of Technology, Durgapur,India
http://tech-nikk.blogspot.com
http://beta.freshersworld.com/communities/nitd

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



Re: [algogeeks] bits groups

2010-12-21 Thread Terence

zero_group(N) {
  c=1-(N1);   // For even N, zero groups is one more than 1 groups.
  while(N) {
d = (N(-N));  // Get the least significiant bit.
N = N+d;  // Clear the last 1-group bits
c++;   // inc counter.
  }
  return c;
}

For more bit manipulations, refer to 
http://www-graphics.stanford.edu/~seander/bithacks.html.



On 2010-12-21 12:26, AEKME wrote:

How do you count the number of zero group bits in a number? group bits
is any consecutive zero or one bits, for example, 2 is represented
as 010 has two zero bits groups the least
significant bit and the group starts after one.

Also, I am in a bad need for algorithms on bits manipulation if any
one has a reference, please share



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



Re: [algogeeks] Amazon Interview Question about Linked Lists

2010-12-21 Thread Nikhil Agarwal
@Saurabh You used an extra pointer compared to shiva's code ,you can avoid
that. :)

On Mon, Dec 20, 2010 at 8:24 PM, Saurabh Koar saurabhkoar...@gmail.comwrote:

 @Rishi:I think Shiva's code is also fine.U can access the list easily
 by using down pointer in his code.
 Because he is assigning temp-down=temp2 and then he is making
 temp-fwd=NULL.

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




-- 
Thanks  Regards
Nikhil Agarwal
Senior Undergraduate
Computer Science  Engineering,
National Institute Of Technology, Durgapur,India
http://tech-nikk.blogspot.com
http://beta.freshersworld.com/communities/nitd

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



Re: [algogeeks] fibonacci problem

2010-12-21 Thread Nikhil Agarwal
You need to keep generating Fibonacci numbers until you meet the
condition.Check for even valued term by using  TERM%2==0 and sum
up.Fibonacci series grows exponentially so n wont be very high.Take care
that it doesn't overflow integer range.


On Mon, Dec 20, 2010 at 8:36 PM, Shalini Sah 
shalinisah.luv4cod...@gmail.com wrote:

 Each new term in the Fibonacci sequence is generated by adding the previous
 two terms. By starting with 1 and 2, the first 10 terms will be:

 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...

 Find the sum of all the even-valued terms in the sequence which do not
 exceed four million. I'm just a beginner..plz help.

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




-- 
Thanks  Regards
Nikhil Agarwal
Senior Undergraduate
Computer Science  Engineering,
National Institute Of Technology, Durgapur,India
http://tech-nikk.blogspot.com
http://beta.freshersworld.com/communities/nitd

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



Re: [algogeeks] array partition

2010-12-21 Thread Devil Wang
*Hi,*
*
*
*I wonder that if the element of the array contains negative integer?
*
On Wed, Dec 22, 2010 at 1:25 AM, snehal jain learner@gmail.com wrote:

 There is an array, how will you partition that into two parts so that
 the sum of both the sub set is minimum

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




-- 

**
*

Best Regards,

Devil Wang

*

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



Re: [algogeeks] Amazon Interview Question about Linked Lists

2010-12-21 Thread Saurabh Koar
@Nikhil: ya..rt

-- 
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: Adobe 2010 Written Test C Development

2010-12-21 Thread awesomeandroid
hi shashank,
for sparse polynomial addition we prefer use of linked list.for more
detailed
explanation
http://code-forum.blogspot.com/2010/11/polynomial-addition.html

for getbits function
http://code-forum.blogspot.com/2010/11/getbits-function-in-c.html
visit these links and post your comment if any problem or some
optimization required.

On Dec 21, 4:52 pm, bittu shashank7andr...@gmail.com wrote:
 Write a function getBits that gives bits from a given position p of a
 given number n.

 Diff between typedef and #define?

 Suggest DS for polynomials. Write C program to add two polynomials.

 Regards
 Shashank

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



Re: [algogeeks] Find the element with more than n/k occurrences

2010-12-21 Thread Saurabh Koar
@Nikhil: What if the array is 1 2 3 4 9 6 6 6 5 and k=3 ?

-- 
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] sort

2010-12-21 Thread snehal jain
Given an array having 16000 unique integers, each lying within the
range 12, how do u sort it. U can load only 1000 numbers at a
time in memory

-- 
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] median

2010-12-21 Thread snehal jain
You have n machines contains n integer. How will you find the median
of n^2 element. Only 2n number can be loaded in the memory

-- 
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] palindrome

2010-12-21 Thread snehal jain
Algorithms to check if binary representation of a number is palindrome
or not

-- 
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] 1s and 0s

2010-12-21 Thread snehal jain
I want to see if all the ones in a number appear on the right side of
the number and all zeros appear on the left, how can I do this most
efficiently? (i.e. 0111 is true but 100010 is false)

-- 
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: Amazon Interview Question about Linked Lists

2010-12-21 Thread bittu
Xcellent Shiva..keep goin on..\



Best Regards
Shashank Mani Narayan
BIT Mesra

-- 
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] number

2010-12-21 Thread snehal jain
If you are given a number as a parameter, write a function that would
put commas after every third digit from the right

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



Re: [algogeeks] palindrome

2010-12-21 Thread mohan@ismu
if x is a  32 bit number
if((x0x)==((x16)0x)))
   x's  bit pattern is a polyndrome

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



Re: [algogeeks] bits groups

2010-12-21 Thread Saurabh Koar
@Terence: I think the above fails for 0X.Correct me if I m wrong.

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



Re: [algogeeks] sort

2010-12-21 Thread Saurabh Koar
See External Sort at Wiki.

-- 
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] complete tree

2010-12-21 Thread snehal jain
If there are two structs, TreeNode and Tree. TreeNode contains 3
elements, data, lChild and rChile. Tree contains 2 elements, int size
and TreeNode *root. The tree is a complete tree. So how to find a
O(logN) approach to insert a new node

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



Re: [algogeeks] number

2010-12-21 Thread mo...@ismu
void main(int arg,char *argc)
{
char *s=argc[1];
int count=0,i;
for(i=strlen(s)-1;i=0;i--)
{
count++;
printf(%c,s[i]);
if(count==3)
{
count=0;
putchar(',');
}
}
}

-- 
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] sorting is done based on string sorting

2010-12-21 Thread snehal jain
How to output the number in a sorted way in which The sorting is done
based on string sorting and not on numerical

(Eg:121 comes before 2 because the Most Significant Digit is 1 in 121
which is less than 2)
disp(int low, int high);
disp(5, 1113);
Required Output is:
10
100
1000
11
12
.
.
19
101
102

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



Re: [algogeeks] complete tree

2010-12-21 Thread Saurabh Koar
Find the first node whose left child is NULL or Right child is NULL
using BFS.(As the tree is complete,all nodes before this will have two
children).Insert at that node.

-- 
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] Sun Calling Me..i need help..

2010-12-21 Thread bittu
hi  guys,
 does anyone has experince with Sun Microsystem
interview rounds..if yes let me no..ASAP


Thanks  Regards
Shashank Mani Narayan Dont B evil U Can earn While U Learn
Cell No- +91-9740852296

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



Re: [algogeeks] Sun Calling Me..i need help..

2010-12-21 Thread cr.a...@gmail.com
uhhh... but isn't Sun dead?
Anil


On Wed, Dec 22, 2010 at 12:38 PM, bittu shashank7andr...@gmail.com wrote:

 hi  guys,
 does anyone has experince with Sun Microsystem
 interview rounds..if yes let me no..ASAP


 Thanks  Regards
 Shashank Mani Narayan Dont B evil U Can earn While U Learn
 Cell No- +91-9740852296

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



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



Re: [algogeeks] complete tree

2010-12-21 Thread mo...@ismu
it takes O(n) and also O(n)extra space(queue)

On Wed, Dec 22, 2010 at 12:37 PM, Saurabh Koar saurabhkoar...@gmail.comwrote:

 Find the first node whose left child is NULL or Right child is NULL
 using BFS.(As the tree is complete,all nodes before this will have two
 children).Insert at that node.

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



-- 
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] linkedlist+hash

2010-12-21 Thread snehal jain
How could a linked list and a hash table be combined to allow someone
to run through the list from item to item while still maintaining the
ability to access an individual element in O(1) time

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



Re: [algogeeks] complete tree

2010-12-21 Thread yq Zhang
since you know the size, you know exactly the path to the new node.

Sent from Nexus one
On Dec 21, 2010 11:10 PM, mo...@ismu mohan...@gmail.com wrote:

 it takes O(n) and also O(n)extra space(queue)


 On Wed, Dec 22, 2010 at 12:37 PM, Saurabh Koar saurabhkoar...@gmail.com
wrote:

 Find the first node whose left child is NULL or Right child is NULL
 using BFS.(As the tree is complete,all nodes before this will have two
 children).Insert at that node.

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


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

-- 
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: sorting is done based on string sorting

2010-12-21 Thread juver++
It's a lexicographical sorting. Use radix sort (MSB).
Or convert your numbers into a strings and use standard sorting routine. 
Also you may code your own comparator.

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



Re: [algogeeks] 1s and 0s

2010-12-21 Thread Ankur Khurana
I hope the code is self explainatory.


int main()
{
//num is the number
int prev =1, next=1,count=0;
while(num)
{
if(count1)
{
print false
break;
}
prev=next;
next=num%10;
num=num/10;
  if(next!=prev)
 count++;
}

if(count=1)
print true
}

-- 
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: complete tree

2010-12-21 Thread juver++
It depends on the structure of the tree. Is it binary search tree? What is 
the expected position of placing particular node in the tree?
Cause the tree is complete, we know that its height is log n

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



Re: [algogeeks] Sun Calling Me..i need help..

2010-12-21 Thread Ankur Khurana
may be he is talking oracle .

On Wed, Dec 22, 2010 at 12:40 PM, cr.a...@gmail.com cr.a...@gmail.com wrote:
 uhhh... but isn't Sun dead?
 Anil


 On Wed, Dec 22, 2010 at 12:38 PM, bittu shashank7andr...@gmail.com wrote:

 hi  guys,
                 does anyone has experince with Sun Microsystem
 interview rounds..if yes let me no..ASAP


 Thanks  Regards
 Shashank Mani Narayan Dont B evil U Can earn While U Learn
 Cell No- +91-9740852296

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


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


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



Re: [algogeeks] linkedlist+hash

2010-12-21 Thread Ankur Khurana
stroe the pointers in the hash table. it will do i suppose.

On Wed, Dec 22, 2010 at 12:36 PM, snehal jain learner@gmail.com wrote:
 How could a linked list and a hash table be combined to allow someone
 to run through the list from item to item while still maintaining the
 ability to access an individual element in O(1) time

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



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



Re: [algogeeks] 1s and 0s

2010-12-21 Thread mo...@ismu
count the no of bits  lets say n
then answer becomes  2^n-1

-- 
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: 1s and 0s

2010-12-21 Thread juver++
Use bits manipulation tricks. There is a way to remove a group of 
consecutive 1's from the right: A = n  (n - 1). Then check A==0.

-- 
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] probability

2010-12-21 Thread snehal jain
You are in duel with two other gunmen. First guy shoot with 100%
accuracy, second person shoot with 50% accuracy and you shoot with 33%
accuracy. Everyone will get a chance to shoot in every round and
shooting will start from the guy with worst accuracy. What will you
shoot in first round?

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



Re: [algogeeks] linkedlist+hash

2010-12-21 Thread snehal jain
then access will not be O(1).. it will be on O(n) int he worst case when all
the nodes are hash to same location

On Wed, Dec 22, 2010 at 12:50 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote:

 stroe the pointers in the hash table. it will do i suppose.

 On Wed, Dec 22, 2010 at 12:36 PM, snehal jain learner@gmail.com
 wrote:
  How could a linked list and a hash table be combined to allow someone
  to run through the list from item to item while still maintaining the
  ability to access an individual element in O(1) time
 
  --
  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.
 
 

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



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



Re: [algogeeks] linkedlist+hash

2010-12-21 Thread juver++
And what? Hash table provides O(1) expected time for access elements. We 
should not speak about worst case if you should use hash table.

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



Re: [algogeeks] Re: 1s and 0s

2010-12-21 Thread snehal jain
@above
nice approach :)

On Wed, Dec 22, 2010 at 1:06 PM, juver++ avpostni...@gmail.com wrote:

 Use bits manipulation tricks.
 1. There is a way to remove a group of consecutive 1's from the right: A =
 n  (n + 1). Then check if A==0 then OK.
 2. Second approach: B=n+1, check if B  (B-1) (this checks if B is a power
 of 2, so it contains only 1 set bit) is zero then OK.

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


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