Re: [algogeeks] Facebook interview question.

2012-01-08 Thread Piyush Grover
Hi Atul

Yes, I posted it earlier but couldn't keep track of it, thanks for the
link. I still have a doubt, does it give all the maximal subsets
or all the subsets. I couldn't get it from the algo posted by Lucifer.

On Mon, Jan 9, 2012 at 9:45 AM, atul anand  wrote:

> @Piyush :
> you are re-posting same problem which you had posted on 5 dec 2011.
>
> check this link :-
>
>
> http://groups.google.com/group/algogeeks/browse_thread/thread/8a58ea05c96f811b/ee74f8a4d7b68561?lnk=gst&q=Maximal+possible+subsets+Algorithm#ee74f8a4d7b68561
>
>
> On Mon, Jan 9, 2012 at 3:27 AM, Piyush Grover 
> wrote:
>
>> Given a set S, find all the maximal subsets whose sum <= k. For example,
>> if S = {1, 2, 3, 4, 5} and k = 7
>> Output is: {1, 2, 3} {1, 2, 4} {1, 5} {2, 5} {3, 4}
>>
>> Hint:
>> - Output doesn't contain any set which is a subset of other.
>> - If X = {1, 2, 3} is one of the solution then all the subsets of X {1}
>> {2} {3} {1, 2} {1, 3} {2, 3} are omitted.
>> - Lexicographic ordering may be used to solve it
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

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



Re: [algogeeks] c output ??

2012-01-08 Thread atul anand
take care when ever you use %d and %f

%d is not flexible in handling float varibaledo not expect it to
typecast itself.
reason could be , you are trying to fit large data type i.e float to  the
int whose range is less.

whereas in second case float can incorporate int type , so automatic
typecasting is done.

On Mon, Jan 9, 2012 at 10:17 AM, HARSHIT PAHUJA wrote:

> *#include
> int main()
> {
> float f=25.25;
> printf("%d\n",f);
> long int x=90;
> printf("%f",x);
> return 0;
> }
> *
>
> above program gives output
> *0
> 25.25*
>
> shudn it be :
> *25
> 90.*
>  ??
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

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



[algogeeks] c output ??

2012-01-08 Thread HARSHIT PAHUJA
*#include
int main()
{
float f=25.25;
printf("%d\n",f);
long int x=90;
printf("%f",x);
return 0;
}
*

above program gives output
*0
25.25*

shudn it be :
*25
90.*
 ??

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



Re: [algogeeks] Facebook interview question.

2012-01-08 Thread atul anand
@Piyush :
you are re-posting same problem which you had posted on 5 dec 2011.

check this link :-

http://groups.google.com/group/algogeeks/browse_thread/thread/8a58ea05c96f811b/ee74f8a4d7b68561?lnk=gst&q=Maximal+possible+subsets+Algorithm#ee74f8a4d7b68561


On Mon, Jan 9, 2012 at 3:27 AM, Piyush Grover wrote:

> Given a set S, find all the maximal subsets whose sum <= k. For example,
> if S = {1, 2, 3, 4, 5} and k = 7
> Output is: {1, 2, 3} {1, 2, 4} {1, 5} {2, 5} {3, 4}
>
> Hint:
> - Output doesn't contain any set which is a subset of other.
> - If X = {1, 2, 3} is one of the solution then all the subsets of X {1}
> {2} {3} {1, 2} {1, 3} {2, 3} are omitted.
> - Lexicographic ordering may be used to solve it
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

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



[algogeeks] Facebook interview question.

2012-01-08 Thread Piyush Grover
Given a set S, find all the maximal subsets whose sum <= k. For example, if
S = {1, 2, 3, 4, 5} and k = 7
Output is: {1, 2, 3} {1, 2, 4} {1, 5} {2, 5} {3, 4}

Hint:
- Output doesn't contain any set which is a subset of other.
- If X = {1, 2, 3} is one of the solution then all the subsets of X {1} {2}
{3} {1, 2} {1, 3} {2, 3} are omitted.
- Lexicographic ordering may be used to solve it

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



Re: [algogeeks] Re: check Similar array

2012-01-08 Thread SAMM
But the Previous post is not the correct solution as it is similar to
hash table of storing the frequency counts ..


I was thinking a some Statictical Approach here . We are dealing with
some points which scattered in a space and we need to find that the
points are at same points or not . That mean that we need to find
whether the points are at the same distance from the center or suppose
the Mean . This Dispersion can be measured using Standard Deviation.

May be Standard Deviation is the Correct way of proceding .. Just a thought .


On 1/9/12, SAMM  wrote:
> @All
>
> Sry for late reply .. I was offline for sometime .
>
>
> Just wanted to brief why I had come up of having a cummulative sum of
> each elements of the array . As I mentioned the Frequency distribution
> of the numbers ..
> I meant that to the frequency the elements of the array starting from
> 1 to element Positive element N or from -1 to Negative Element to
> Negative N .
>
> For Example :--
>
> Array :- [ 2 , 3 ,3 , 5 , 4 ]
>
> I would have a piles starting from 1 to max(array) here 5 .
>
> So after a,
>  2 <=> 1+2
>  3 <=>1+2+3
>  3 <=>1+2+3
>  5 <=> 1 +2 +3+4+5
>  4 <=> 1+2+3+4
>
> Now track the count of every numbers .
>
> There are 5 one's , 5 two's , 3 three's , 2 fours and 1 five.
>
> So our next task is to check for this counts WITH the other array .
> And this should work of both +ve and -ve element array .
>
> Initially I was adding them up but it failed , but this would suffice I
> guess ..
> The only Concern is Space here  , But in order to get something need
> to compromise sometime else .
>
> On 1/8/12, sravanreddy001  wrote:
>> @shashank:  your approach fails for (2,0,0,0) & (1,1,1,1)
>>
>> but.. from any of the above approaches seen, we couldn't be 100% sure of
>> the solution,
>> but, from shashank's approach, the probability of finding correct
>> soultion
>> can be improved by using some random prime numbers.
>> (running tests for more than one prime number)
>>
>> and for any other approaches, a mathematical proof is needed to support
>> the
>> answer.
>>
>> (better accuracy over time is the trade off in the seen examples)
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/algogeeks/-/z-3GHpDXLFoJ.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>
>
> --
> Somnath Singh
>


-- 
Somnath Singh

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



Re: [algogeeks] Re: check Similar array

2012-01-08 Thread SAMM
@All

Sry for late reply .. I was offline for sometime .


Just wanted to brief why I had come up of having a cummulative sum of
each elements of the array . As I mentioned the Frequency distribution
of the numbers ..
I meant that to the frequency the elements of the array starting from
1 to element Positive element N or from -1 to Negative Element to
Negative N .

For Example :--

Array :- [ 2 , 3 ,3 , 5 , 4 ]

I would have a piles starting from 1 to max(array) here 5 .

So after a,
 2 <=> 1+2
 3 <=>1+2+3
 3 <=>1+2+3
 5 <=> 1 +2 +3+4+5
 4 <=> 1+2+3+4

Now track the count of every numbers .

There are 5 one's , 5 two's , 3 three's , 2 fours and 1 five.

So our next task is to check for this counts WITH the other array .
And this should work of both +ve and -ve element array .

Initially I was adding them up but it failed , but this would suffice I guess ..
The only Concern is Space here  , But in order to get something need
to compromise sometime else .

On 1/8/12, sravanreddy001  wrote:
> @shashank:  your approach fails for (2,0,0,0) & (1,1,1,1)
>
> but.. from any of the above approaches seen, we couldn't be 100% sure of
> the solution,
> but, from shashank's approach, the probability of finding correct soultion
> can be improved by using some random prime numbers.
> (running tests for more than one prime number)
>
> and for any other approaches, a mathematical proof is needed to support the
> answer.
>
> (better accuracy over time is the trade off in the seen examples)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/algogeeks/-/z-3GHpDXLFoJ.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
Somnath Singh

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



Re: [algogeeks] Re: extracting vector (digitization) from an ECG image

2012-01-08 Thread SAMM
1 month back  I wrote C++ code using Magick++ to zoom a image without
distorting the Pixels . In that Code we can extact the Pixel
attributes which are the Combination of Red , Blue and Green and Alpha
attributes(Contributes to Picture Transparancy So , not present in
Every Image ). But RBG combination is present in every image . Each
attributes contribute to 1 byte (32 bits ) .

Every 4bytes/3 bytes Constitute a single pixel depending alpha
attribute is present or not in the pic .


If u want to get Quantize the image then u have to read the Pixel's
Property starting from (0,0) to (M,N) , where MxN is the dimension of
the image .

This Attibutes are representated in 2D array and is sufficient to
serve ur purpose . And I this is Offcourse Supported for Java except
for TIFF and JPEG 2000(plugin required separately) .


There are many plugins also available for extracting this attributes .
Some plug in enables you to read the Image and and and it will return
you the starting address of the index (0,0) Corner left of the Image .
And from there u can read the Bytes to get the attributes depending
the picture support the Tranparency Property(alpha attribute).


On 1/8/12, sravanreddy001  wrote:
> @Deepak: Digitization of the image doesn't have a algorithmic approach,
> (unless you need to compress it)
>
> But, i see that you are asking for a way to convert the image (jpg) into a
> memory representation.
> I am not sure of matlab, but, using java (images API) you have to read the
> data into digital form (format needed for the neutal network)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/algogeeks/-/OdrIp1J5tbsJ.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
Somnath Singh

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



[algogeeks] Re: extracting vector (digitization) from an ECG image

2012-01-08 Thread sravanreddy001
@Deepak: Digitization of the image doesn't have a algorithmic approach, 
(unless you need to compress it)

But, i see that you are asking for a way to convert the image (jpg) into a 
memory representation.
I am not sure of matlab, but, using java (images API) you have to read the 
data into digital form (format needed for the neutal network)

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



Re: [algogeeks] Binary Search Problem

2012-01-08 Thread sravanreddy001
@atul:
+1, i too thought the same
this comes handly esp, when the derived datatypes are used with a range 
limitations.

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



Re: [algogeeks] Binary Search Problem

2012-01-08 Thread Sanjay Rajpal
@Atul : got it. thanx :)
*
Sanjay Kumar
B.Tech Final Year
Department of Computer Engineering
National Institute of Technology Kurukshetra
Kurukshetra - 136119
Haryana, India
Contact: +91-8053566286
*



On Sun, Jan 8, 2012 at 3:27 AM, atul anand  wrote:

> @Sanjay: suppose Max_INT range is 300
>
> now suppose
>
> end=300 and start =2
>
> now using (start+end)/2 i.e *302*/2 but 302 goes out of range for and
> interger type as assumed...
>
> but if we use  start + (end-start)/2 THEN  2 + (300-2)/2  , i.e 2+ *298*/2
> here 298 < 300 hence it within int_Max range which was assumed 300..
>
>
>
> On Sun, Jan 8, 2012 at 4:41 PM, Sanjay Rajpal wrote:
>
>> actually book pages are images.
>>
>> My question is why second statement may result in overflow ?
>> *
>>
>> Sanjay Kumar
>> B.Tech Final Year
>> Department of Computer Engineering
>> National Institute of Technology Kurukshetra
>> Kurukshetra - 136119
>> Haryana, India
>> Contact: +91-8053566286, +91-9729683720
>> *
>>
>>
>>
>> On Sun, Jan 8, 2012 at 3:07 AM, saurabh singh wrote:
>>
>>>  not clear what you are trying to ask...can you quote exactly from the
>>> book?
>>> Saurabh Singh
>>> B.Tech (Computer Science)
>>> MNNIT
>>> blog:geekinessthecoolway.blogspot.com
>>>
>>>
>>>
>>> On Sun, Jan 8, 2012 at 4:34 PM, Sanjay Rajpal  wrote:
>>>
 In binary search,

 mid = start + (end-start)/2 is used to avoid overflow, as said by a
 book.

 why can't we use mid = (start + end)/2, it says this statement may
 result in overflow ?
 *
 Sanjay Kumar
 B.Tech Final Year
 Department of Computer Engineering
 National Institute of Technology Kurukshetra
 Kurukshetra - 136119
 Haryana, India
 Contact: +91-8053566286
 *

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

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

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



Re: [algogeeks] Binary Search Problem

2012-01-08 Thread atul anand
@Sanjay: suppose Max_INT range is 300

now suppose

end=300 and start =2

now using (start+end)/2 i.e *302*/2 but 302 goes out of range for and
interger type as assumed...

but if we use  start + (end-start)/2 THEN  2 + (300-2)/2  , i.e 2+ *298*/2
here 298 < 300 hence it within int_Max range which was assumed 300..



On Sun, Jan 8, 2012 at 4:41 PM, Sanjay Rajpal  wrote:

> actually book pages are images.
>
> My question is why second statement may result in overflow ?
> *
>
> Sanjay Kumar
> B.Tech Final Year
> Department of Computer Engineering
> National Institute of Technology Kurukshetra
> Kurukshetra - 136119
> Haryana, India
> Contact: +91-8053566286, +91-9729683720
> *
>
>
>
> On Sun, Jan 8, 2012 at 3:07 AM, saurabh singh  wrote:
>
>>  not clear what you are trying to ask...can you quote exactly from the
>> book?
>> Saurabh Singh
>> B.Tech (Computer Science)
>> MNNIT
>> blog:geekinessthecoolway.blogspot.com
>>
>>
>>
>> On Sun, Jan 8, 2012 at 4:34 PM, Sanjay Rajpal  wrote:
>>
>>> In binary search,
>>>
>>> mid = start + (end-start)/2 is used to avoid overflow, as said by a book.
>>>
>>> why can't we use mid = (start + end)/2, it says this statement may
>>> result in overflow ?
>>> *
>>> Sanjay Kumar
>>> B.Tech Final Year
>>> Department of Computer Engineering
>>> National Institute of Technology Kurukshetra
>>> Kurukshetra - 136119
>>> Haryana, India
>>> Contact: +91-8053566286
>>> *
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

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



Re: [algogeeks] Binary Search Problem

2012-01-08 Thread Sanjay Rajpal
actually book pages are images.

My question is why second statement may result in overflow ?
*
Sanjay Kumar
B.Tech Final Year
Department of Computer Engineering
National Institute of Technology Kurukshetra
Kurukshetra - 136119
Haryana, India
Contact: +91-8053566286, +91-9729683720
*



On Sun, Jan 8, 2012 at 3:07 AM, saurabh singh  wrote:

>  not clear what you are trying to ask...can you quote exactly from the
> book?
> Saurabh Singh
> B.Tech (Computer Science)
> MNNIT
> blog:geekinessthecoolway.blogspot.com
>
>
>
> On Sun, Jan 8, 2012 at 4:34 PM, Sanjay Rajpal  wrote:
>
>> In binary search,
>>
>> mid = start + (end-start)/2 is used to avoid overflow, as said by a book.
>>
>> why can't we use mid = (start + end)/2, it says this statement may result
>> in overflow ?
>> *
>> Sanjay Kumar
>> B.Tech Final Year
>> Department of Computer Engineering
>> National Institute of Technology Kurukshetra
>> Kurukshetra - 136119
>> Haryana, India
>> Contact: +91-8053566286
>> *
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

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



Re: [algogeeks] Binary Search Problem

2012-01-08 Thread saurabh singh
 not clear what you are trying to ask...can you quote exactly from the book?
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Sun, Jan 8, 2012 at 4:34 PM, Sanjay Rajpal  wrote:

> In binary search,
>
> mid = start + (end-start)/2 is used to avoid overflow, as said by a book.
>
> why can't we use mid = (start + end)/2, it says this statement may result
> in overflow ?
> *
> Sanjay Kumar
> B.Tech Final Year
> Department of Computer Engineering
> National Institute of Technology Kurukshetra
> Kurukshetra - 136119
> Haryana, India
> Contact: +91-8053566286
> *
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

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



[algogeeks] Binary Search Problem

2012-01-08 Thread Sanjay Rajpal
In binary search,

mid = start + (end-start)/2 is used to avoid overflow, as said by a book.

why can't we use mid = (start + end)/2, it says this statement may result
in overflow ?
*
Sanjay Kumar
B.Tech Final Year
Department of Computer Engineering
National Institute of Technology Kurukshetra
Kurukshetra - 136119
Haryana, India
Contact: +91-8053566286
*

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



Re: [algogeeks] Heaviest Increasing Subsequence:Suggest Algo

2012-01-08 Thread atul anand
isnt it is similar to finding longest subsequence , here deciding factor is
the weight of the
subsequence , so
W(old) < W(new) ..update new sequence found.

On Sun, Jan 8, 2012 at 10:16 AM, kumar rajat  wrote:

> Hi
> Can any1 suggest a algo for heaviest increasing subsequence of a given
> array?
> (HIS is the LIS when weights are included for each element in the
> array)
>
> 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 algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

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



Re: [algogeeks] Re: Maximal possible subsets Algorithm

2012-01-08 Thread atul anand
@Lucifer : got it ..nice and clear :) :).


On Sun, Jan 8, 2012 at 10:05 AM, Lucifer  wrote:

> @atul..
>
> The table is used to record the state of subsets not print them.. (I
> am assuming that's what u meant)..Hence keeping that in mind, yes it
> captures all subsets... Now once A[N, K] is 1 that means there are
> some subsets whose sum will be equal to K. Hence, to find all such
> subsets we will backtrack accordingly...
>
> --
> A[i,j] -> Whether using first 'i' items a sum of 'j' can be made.. A
> value of 0/1 indicates whether its possible or not...
>
> Now there are 2 ways we can make a subset having sum j..
> 1) Consider that W[i] is part of the subset, then A[ i - 1, j - W[i] ]
> should be 1.
>// Hence while generating the subsets if A[i -1, j - W[i] ] = A[i,
> j] =1 , then W[i] will be part of subset... Point to be noted - the
> part of "that subset" which will be generated using the path whose
> intermediate nodes are (A[i, j] , A[i-1, j - W[i]])
>
> 2) Say 'i'th element doesn't contribute to the subset. Hence for A[i,
> j] to be 1, A[i-1, j] should be 1.
>// Hence when A[i-1, j] = A[i, j] = 1, then W[i] won't be a part
> of the subset...  Point to be noted - the part of "that subset" which
> will be generated using the path whose intermediate nodes are (A[i,
> j] , A[i-1, j])
>
> -
>
>
> On Jan 7, 11:37 pm, atul anand  wrote:
> > @Lucifer :
> >
> > for W[]={1,3,2,1,2}  and Wmax=4.
> > this array will be formed.
> >
> > 0
> >
> > 1
> >
> > 2
> >
> > 3
> >
> > 4
> >
> > 0
> >
> > 1
> >
> > 0
> >
> > 0
> >
> > 0
> >
> > 0
> >
> > 1
> >
> > 1
> >
> > 1
> >
> > 0
> >
> > 0
> >
> > 0
> >
> > 3
> >
> > 1
> >
> > 1
> >
> > 0
> >
> > 1
> >
> > 1
> >
> > 2
> >
> > 1
> >
> > 1
> >
> > 1
> >
> > 1
> >
> > 1
> >
> > 1
> >
> > 1
> >
> > 1
> >
> > 1
> >
> > 1
> >
> > 1
> >
> > 2
> >
> > 1
> >
> > 1
> >
> > 1
> >
> > 1
> >
> > 1
> >
> > is it printing all subset ?? if yes then may be i am not getting it..
> >
> > btw one query :-
> >
> > b) if A[N -1 , K] = 1,
> >  b1) then *W[N] doesn't belong to the subset* , continue
> > recursively ( goto step a).
> >
> > why???
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

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



Re: [algogeeks] Heaviest Increasing Subsequence:Suggest Algo

2012-01-08 Thread shady
banned,
trying to cheat, aye ?
no more replies on this topic, until Wednesday

On Sun, Jan 8, 2012 at 10:16 AM, kumar rajat  wrote:

> Hi
> Can any1 suggest a algo for heaviest increasing subsequence of a given
> array?
> (HIS is the LIS when weights are included for each element in the
> array)
>
> 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 algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

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