[algogeeks] Discussion on unique-elements-in-an-array

2010-12-18 Thread awesomeandroid
what is the range of numbers.if the array has numbers between 1 to n
then there can be o(n) solution.

Regards
Priyaranjan
http://code-forum.blogspot.com/

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

2010-12-18 Thread bittu
can we find Pythagorean triples in an unsorted array in write program
so that have minimum time complexity.


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.



[algogeeks] Amazon Question

2010-12-18 Thread bittu
Given an n by n matrix with zeros and ones, find the largest sub-
matrix full of ones in linear time.  I was told that a solution with
O(n) time complexity exists. If there are n^2 elements in a n X n
matrix how does a linear solution exist?


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.



[algogeeks] Google Technical Round

2010-12-18 Thread bittu
Write a program to print the matrix in spiral form..

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] Answer This

2010-12-18 Thread Wladimir Tavares
I knew this problem with black and white hats.



Wladimir Araujo Tavares
http://www.si.ufc.br/~wladimir http://www.si.ufc.br/%7Ewladimir/
Fiz uma faculdade! Só não fiz a segunda porque acabaram os tijolos.




On Fri, Dec 17, 2010 at 8:41 AM, Amir hossein Shahriari 
amir.hossein.shahri...@gmail.com wrote:

 @aditya: the problem you mentioned is not like this one
 if i'm a green eyed there is no reason to kill myself on the second day if
 no one kills himself on the 1st day
 actually in your solution there is no difference between blue eyed people
 and green eyed people so a blue eyed might kill himself as well

 the solution is 20 but they all kill themselves in the 20th day:
 every green eyed person can count 19 green eyed
 every blue eyed person can count 20 green eyed in the village
 so at the 20th day each green eyed knows that the reason no green eyed has
 yet committed suicide in the first 19 days was that they could all count 19
 other green eyed people so he must be a green eyed and kills himself

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

2010-12-18 Thread siva viknesh
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;
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.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Array Transform

2010-12-18 Thread ankit sablok
Can any body provide me a program for the following question

thanx in advance

http://www.codechef.com/problems/ARRAYTRM/

I am applying brute forc here and getting TLE everytime help me out
with the problem thanx 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.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Amazon Interview Question

2010-12-18 Thread saravana kumar
It can be done easily by counting sort
On Wed, Dec 15, 2010 at 5:36 AM, Soumya Prasad Ukil
ukil.sou...@gmail.comwrote:

 Have a look : http://geeksforgeeks.org/?p=1488


 On 15 December 2010 05:19, Saurabh Koar saurabhkoar...@gmail.com wrote:

 @ Bittu:

 Lets analyze your code with iterations:

 the array contains  1 3 3 1 2 3 5 2 3
 count contains   0 2 2 4 0 1 0 0 0

 now 1st iteration:
 i=8,7,6 the inner loop will nt be executed;

 i=5; so j=0 only; as count[5]=1;
 Now arr[pos](i.e array[0])=5

 i=4; the inner loop fails

 i=3; so j=0 to 3 as count[3]=4
 Now array[1]=array[2]=array[3]=array[4]=3

 i=2; so j=0 to 1 as count[2]=2
 so array[5]=array[6]=2

 and likewise array[7]=array[8]=1

 so the final array 5 3 3 3 3 2 2 1 1

 It doesnt match with the desired output.

 Correct me if I m missing something.



 On 12/15/10, bittu shashank7andr...@gmail.com wrote:
  @ankur,saurabh,soumya..
 
  ya ankur i forget to remove range from dare also no need to find
  range  for this..\
 
  put size-1 intead of range so that malloc will alocate the memory to
  all  elements in array ..no hope its fine...
 
 
  what i did is that
  i took counter array  thta cvontains the  no of times particular
  elements  comes
  then i have sort d array in reverse  order...  prints accoding to
  count array..thats it... and the last line  of actual question says..
 
  ..in case of a tie  print the number which occurred first ..i
  don't think d way i hav solved dis..
 
  still please let me no..if m wrong..
 
  Regards
  Shashank Mani Narayan  Don't b evil U can earn while u Learn
  Computer Science  enginerring
  BIrla Institute of Technology,Mesra
  Cell 9166674831
 
  --
  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.




 --
 regards,
 soumya prasad ukil

 --
 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] Google Technical Round

2010-12-18 Thread jaladhi dave
Can you give an example, to clarify certain 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] spoj problem PIE

2010-12-18 Thread keyankarthi
i get correct answer for test cases i tried.. still WA
spoj.pl/problems/PIE

here is my code


#includeiostream
#includevector
#includestdio.h
#includealgorithm
#includemath.h
using namespace std;
vectorunsigned long long int v;
double bin(unsigned long long int n,unsigned long long int req)
{
unsigned long long int hi,lo,x,tmp,count=0,i;
lo=v.front();
hi=v.back();
if(n==1)
return((double)v[0]/(double)req);
while(lohi)
{
count=0;
x=lo+(hi-lo)/2;
for(i=n-1;i=0  v[i]=x;i--)
{
tmp=v[i]/x;
count+=tmp;
}
if(count=req)
lo=x+1;
else
hi=x-1;
}
return lo-1;
}
int main()
{
unsigned long long int pi,tmp,tot,i,t;
scanf(%lld,t);
while(t--){
scanf(%lld %lld,pi,tot);
tot++;
for(i=0;ipi;i++)
{
scanf(%lld,tmp);
v.push_back(tmp*tmp);
}
sort(v.begin(),v.end());
printf(%0.4lf\n,((M_PI*bin(pi,tot;
v.clear();
}
}


help me out... :-)

-- 
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] Google Technical Round

2010-12-18 Thread DIPANKAR DUTTA
refer careercup.com

On 12/18/10, jaladhi dave jaladhi.k.d...@gmail.com wrote:
 Can you give an example, to clarify certain 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.




-- 
DIPANKAR DUTTA
M-TECH,Computer Science  Engg.
EC Dept,IIT ROORKEE
Uttarakhand , India – 247667
---
website:http://people.iitr.ernet.in/shp/09535009/Website/index.html
ph no-09045809987
Lab: 286454
email:dipan...@iitr.ernet.in email%3adipan...@iitr.ernet.in

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

2010-12-18 Thread snehal jain
Given an expression E of n numbers with *, + operations and no
precedence among the operators, identify the set of parenthesis which
maximize the results for E.

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

2010-12-18 Thread snehal jain
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.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] ants in a row

2010-12-18 Thread snehal jain
You have a set of ants moving on an horizontal segment of length n.
Each ant can randomically move either right or left. When an ant takes
a direction, she stays in that direction until she either drops out of
the segment or it bumps with another ant. In this case, the ant
changes her direction. Can you formalize the system and describe what
will happen after t iterations?

-- 
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] celebrity twitters

2010-12-18 Thread snehal jain
In a n twitter set, a celebrity is defined as someone who is followed
by everyone, but who follows no one. You need to identify the
celebrities by asking to twitters the question: do you know person
x? The answer will be yes/no. Find the celebrity by asking only O(n)
questions.

-- 
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] Adobe Quest....

2010-12-18 Thread bittu
Write an Efficient C Program to Reverse Bits of a 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.



Re: [algogeeks] Adobe Quest....

2010-12-18 Thread Ankur Khurana
you mean reverse or make 1 to 0 or 0 to 1 ?

On Sun, Dec 19, 2010 at 12:52 AM, bittu shashank7andr...@gmail.com wrote:
 Write an Efficient C Program to Reverse Bits of a 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.



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

2010-12-18 Thread surendra
unsigned int reverseBits(unsigned int num)
{
unsigned int count = sizeof(num) * 8 - 1;
unsigned int reverse_num = num;

num = 1;
while(num)
{
   reverse_num = 1;
   reverse_num |= num  1;
   num = 1;
   count--;
}
reverse_num = count;
return reverse_num;
}

int main()
{
unsigned int x = 1;
printf(%u, reverseBits(x));
getchar();
}


On Dec 18, 11:28 am, Ankur Khurana ankur.kkhur...@gmail.com wrote:
 you mean reverse or make 1 to 0 or 0 to 1 ?







 On Sun, Dec 19, 2010 at 12:52 AM, bittu shashank7andr...@gmail.com wrote:
  Write an Efficient C Program to Reverse Bits of a 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 
  athttp://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: Adobe Quest....

2010-12-18 Thread Dave
For 32-bit integers:

x = ((x  16)  0X) | ((x  0X)  16);
x = ((x   8)  0X00FF00FF) | ((x  0X00FF00FF)   8);
x = ((x   4)  0X0F0F0F0F) | ((x  0X0F0F0F0F)   4);
x = ((x   2)  0X) | ((x  0X)   2);
x = ((x   1)  0X) | ((x  0X)   1);

x is now the binary reversal of its original value.

Dave

On Dec 18, 1:28 pm, Ankur Khurana ankur.kkhur...@gmail.com wrote:
 you mean reverse or make 1 to 0 or 0 to 1 ?



 On Sun, Dec 19, 2010 at 12:52 AM, bittu shashank7andr...@gmail.com wrote:
  Write an Efficient C Program to Reverse Bits of a 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 
  athttp://groups.google.com/group/algogeeks?hl=en.- Hide quoted text -

 - Show quoted text -

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

2010-12-18 Thread Gene
There is a great list of bit manipulation hacks that has been around
and added to for years.  See for example:

http://www-graphics.stanford.edu/~seander/bithacks.html


On Dec 18, 2:22 pm, bittu shashank7andr...@gmail.com wrote:
 Write an Efficient C Program to Reverse Bits of a 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: subsorted array

2010-12-18 Thread Dan
On Dec 18, 9:57 am, 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.


Sounds like a simple homework problem to me.:-)

-- 
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] celebrity twitters

2010-12-18 Thread sharad kumar
consider it as a directed graph and sink is the celebrity.do dfs to find
sink...

On Sat, Dec 18, 2010 at 11:30 PM, snehal jain learner@gmail.com wrote:

 In a n twitter set, a celebrity is defined as someone who is followed
 by everyone, but who follows no one. You need to identify the
 celebrities by asking to twitters the question: do you know person
 x? The answer will be yes/no. Find the celebrity by asking only O(n)
 questions.

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




-- 
yezhu malai vaasa venkataramana Govinda Govinda

-- 
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: ants in a row

2010-12-18 Thread Gene
Well, since you are talking about iterations, it must be that you mean the 
segment has (n+1) stations where each ants can be, and they take steps of 
size 1 at each iteration.  I'm going to assume no two ants moving in the 
same direction can occupy the same station on the segment.

Then you can formalize this situation as a state machine with 4^(n + 1) 
states.  It takes this number of states because each station can contain 
nothing, an ant moving right, an ant moving left, and a pair of ants (one 
going left, one right) that have just collided.  You can think of the states 
as labeled with (n+1) pairs of bits (LR)_i.  Bit L (or R) is 1 iff and only 
if station i contains an ant moving left (or right).

This machine is deterministic.  Once you (randomly or otherwise) choose the 
initial locations of the ants and their initial directions, you have chosen 
the start state.  After that, the evolution of the machine is fully 
determined.  If you think about it for a while you'll also see the state 
machine graph is a DAG, and the final state of every path in the dag is a 
single sink corresponding to no ants at all on the segment.  I'll let you 
figure out how to prove this.

-- 
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] Answer This

2010-12-18 Thread Puneet Ginoria
@Terence : I think this could be the best reason

On Fri, Dec 17, 2010 at 1:58 PM, Terence technic@gmail.com wrote:

  I think nobody dies on the first 19 days and everyone dies on the 20th
 day.
 (I have no difference with other green-eyes. Why I have to suicide ealier?
 : )

 Given: a) there was at least one green-eyed among them,
 we could get the following conclusions:
 1) If there is exactly 1 green-eye,  he committed suicide on the first day.

 2) If there is exactly 2 green-eye,  they all committed suicide on the
 second day.
 ...
 n) If there is exactly N green-eye,  they all committed suicide on the N'th
 day.

 1) is obvious. (No one else he saw is green-eye)
 For n), each of the N green-eyed persons saw (N-1) green-eye persons.
 If there were only (N-1) green-eyed persons, they had committed suicide on
 the (N-1) th day, according to the previous conclusion.
 So no suicides on the first (N-1) days means there were more green-eyed
 persons, ie. he is one of them.
 Each of the N green-eyed persons realized this on the N'th day, and
 commited suicide.



 On 2010-12-17 15:34, Iqbal Nouyed wrote:

 I think Aditya is correct,

 1) it never says nobody dies on the first 19 days, just says by the 20th
 day all the green eyed commit suicide.
 2) God said that, He also assured them that there was at least one
 green-eyed among them.


 Cheers.


 On Fri, Dec 17, 2010 at 1:30 PM, Krishna Narasimhan 
 krishna.n...@gmail.com wrote:

 Aditya,

  1) Nobody dies on the first 19 days everyone dies on the 20th day.
 2) Even if it wasnt the case, why should he die just because nobody else
 did? Is there any condition on THERE SHOULD BE ATLEAST ONE GREEN EYED GUY?


 On Fri, Dec 17, 2010 at 12:52 PM, Aditya Agrawal adit6...@gmail.comwrote:

 20 green eys ppl ..
 At the end of first day person realize no body dies so he is the one with
 green eye's so he commit sucide ...
 Similarly on second  day .. hence forth 20 people commit suicide in 20
 days ..


 On Fri, Dec 17, 2010 at 11:05 AM, punnu punnu.gino...@gmail.com wrote:

 In an ancient village, there were some green-eyed and blue-eyed
 persons. One fine day,
 God instructed them, the day on which you come to know that you are a
 green-eyed,
 you should commit suicide ... He also assured them that there was at
 least one green-eyed
 among them. Well, all the villagers were very intelligent and strict
 followers of
 God. But, no one knew color of his own eyes! They didn't have mirrors.
 They
 couldn't even communicate with each other. All that they could do is
 to see color
 of other's eyes. It happened that on 20th day, all the green-eyed
 people committed
 suicide. So, how many green-eyed were 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.


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




  --
 
 I dare do all that may become a man; Who dares do more, is none - Macbeth,
 twelfh night!
 Regards
Krishna
  --
  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.

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

Re: [algogeeks] maximize result

2010-12-18 Thread Pranav Agarwal
I am not sure about this but a quick thought on the question:

If we give plus a higher precedence than multiplication, then we get a
higher result.
For eg:

3 + 6 * 7 + 3 * 2

BODMAS = 51

But giving plus a higher precedence will imply 180

Unable to think of any counter examples. Give if any, otherwise a simple
greedy approach is to parenthesize all the plus together and then
parenthesize through the multiplication.

For the above example:  (3+6)*(7+3)*2

Pranav

On Sat, Dec 18, 2010 at 11:15 PM, snehal jain learner@gmail.com wrote:

 Given an expression E of n numbers with *, + operations and no
 precedence among the operators, identify the set of parenthesis which
 maximize the results for E.

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