Re: [algogeeks] Re: Largest contigious subarray with average greather than k

2012-11-26 Thread Rahul Kumar Patle
gt; int max_so_far = 0, max_ending_here = 0, avg = 0, s = -1, e = -1, ts,
>>> te, tsum;
>>>  boolean flag = false;
>>>
>>> for (int i = 0; i < a.length; i++) {
>>>
>>>  if (max_ending_here == 0)
>>>  s = e = i;
>>>
>>> max_ending_here = max_ending_here + a[i];
>>>
>>> if (max_ending_here < 0) {
>>>  max_ending_here = 0;
>>> s = e = -1;
>>> }
>>>  if (max_so_far < max_ending_here) {
>>>  max_so_far = max_ending_here;
>>>
>>> e = i;
>>> }
>>>
>>> }
>>>
>>> if (avgGreater(max_so_far, s, e, k)){
>>> System.out.println("Result subarray start index:" + s
>>>  + " End index:" + e);
>>> return max_so_far;
>>>  }
>>> /*This will generate two sequence use optimal time complexity of this
>>> algo is O(n)
>>>  *
>>>  *
>>>  */
>>>  if (s >= 0 && !avgGreater(max_so_far, s, e, k)) {
>>>  max_ending_here = max_so_far;
>>> ts = s;
>>> te = e;
>>>
>>> while (ts < te) {
>>>
>>> max_ending_here -= a[ts];
>>> if (avgGreater(max_ending_here, ts+1, te, k)) {
>>>  ts++;
>>> System.out.println("Result subarray start index:" + ts
>>> + " End index:" + te);
>>>  break;
>>> }
>>> ts++;
>>> }
>>>  ts = s;
>>> te = e;
>>> max_ending_here = max_so_far;
>>>  while (ts < te) {
>>>
>>> max_ending_here -= a[te];
>>> if (avgGreater(max_ending_here, ts, te-1, k)) {
>>>  te--;
>>> System.out.println("Result subarray start index:" + ts
>>> + " End index:" + te);
>>>  break;
>>> }
>>> te--;
>>> }
>>>
>>> }
>>>
>>> return max_so_far;
>>> }
>>>
>>> static boolean avgGreater(int sum, int s, int e, float k) {
>>> float t= (float) (sum / (e - s + 1));
>>>  return t>=k? true : false;
>>> }
>>>
>>>  public static void main(String[] args) {
>>>
>>> int[] a = { 100, 10, -1, -1, 4, -1, 7, 2, 8 };
>>>  System.out.println(maxAvgSum(a, 5));
>>> }
>>> }
>>>
>>>
>>> On Wed, Nov 21, 2012 at 10:07 PM, Sachin Chitale <
>>> sachinchital...@gmail.com> wrote:
>>>
>>>> Hello,
>>>>
>>>> Algorithm-->
>>>> 1. Find out start and end index of contiguous subarray which has max
>>>> sum O(n)
>>>> 2.Once u have start and end index calculate avg if it satisfies the
>>>> condition then done O(n)
>>>>   2.1 other wise run a loop through start to end index and remove
>>>> trailing elements by increasing start
>>>>  2.2 simultaneously check avg..this will lead to proper subarray.
>>>> 3. In similar fashion start reducing end valuse keeping start
>>>> constant.do it sub steps of 2...
>>>>
>>>> compare result of 2 and 3 and choose d best one...
>>>> give me some time to write code
>>>>
>>>>
>>>> On Wed, Nov 21, 2012 at 12:29 AM, Koup  wrote:
>>>>
>>>>> To be correct I need the longest subarray that has an average greater
>>>>> than k but my main problem here is to find the longest one. Thank you !
>>>>>
>>>>> --
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Regards,
>>>> Sachin Chitale
>>>> Application Engineer SCJP, SCWCD
>>>> Contact# : +91 8086284349, 9892159511
>>>> Oracle Corporation
>>>>
>>>
>>>
>>>
>>> --
>>> Regards,
>>> Sachin Chitale
>>> Application Engineer SCJP, SCWCD
>>> Contact# : +91 8086284349, 9892159511
>>> Oracle Corporation
>>>
>>> --
>>>
>>>
>>>
>>
>>  --
>>
>>
>>
>
>
>
> --
> Regards,
> Sachin Chitale
> Application Engineer SCJP, SCWCD
> Contact# : +91 8086284349, 9892159511
> Oracle Corporation
>
> --
>
>
>



-- 
Thanks and Regards:
Rahul Kumar Patle
M.Tech, School of Information Technology
Indian Institute of Technology, Kharagpur-721302,
India<http://www.iitkgp.ac.in/>
Mobile No: +91-8798049298, +91-9424738542
Alternate Email: rahulkumarpa...@hotmail.com
[image: Linkedin]<http://www.linkedin.com/profile/view?id=106245716&trk=tab_pro>
[image: Twitter] <https://twitter.com/rahulkumarpatle>
<https://www.facebook.com/rkpatle>

-- 




Re: [algogeeks] Re: Output

2012-11-25 Thread Rahul Kumar Patle
@pandey : here you are shifting 1 to right by 4 bit (as rushiraj said
correctly)
which becomes 0.1, then you are doing negation which becomes
11...0(mask)
now do you and operation
mask & 56  = 40
mask & 64 = 64
mask & 127 = 111
you can notice that only 5th lsb (effective value 16) is zero which is
present in 56 and 127 but not in 64
so 64 remains the same but 56 and 127 got reduced by 16.


On Sat, Nov 24, 2012 at 8:36 PM, Dave  wrote:

> @Rajesh: In binary, mask = 111...10 (with 4-byte ints, this is 27
> 1-bits followed by 5 0-bits). The logical product of num with mask zeros
> out the low order 5 bits while retaining the high order 27 bits. Thus, res
> is num truncated to the largest multiple of 32 that does not exceed num. 56
> = (1*32 + 24) goes to 1*32 = 32, 64 (=2*32 + 0) stays at 2*32 = 64, and 127
> (=3*32 + 31) goes to 3*32 = 96.
>
> Dave
>
> On Saturday, November 24, 2012 2:45:24 AM UTC-6, rajesh pandey wrote:
>
>> void dosomething(int num)
>> {
>> int mask=~(1<<5-1);
>> int res=num&mask;
>>  printf("%d",res);
>> }
>> int main()
>> {
>> dosomething(56);
>>  dosomething(64);
>> dosomething(127);
>> return 0;
>> }
>>
>> please explain  the logic behind the output.
>>
>> Thanks,
>> Rajesh
>>
>  --
>
>
>



-- 
Thanks and Regards:
Rahul Kumar Patle
M.Tech, School of Information Technology
Indian Institute of Technology, Kharagpur-721302,
India<http://www.iitkgp.ac.in/>
Mobile No: +91-8798049298, +91-9424738542
Alternate Email: rahulkumarpa...@hotmail.com
[image: Linkedin]<http://www.linkedin.com/profile/view?id=106245716&trk=tab_pro>
[image: Twitter] <https://twitter.com/rahulkumarpatle>
<https://www.facebook.com/rkpatle>

-- 




Re: [algogeeks] Re: Output

2012-11-25 Thread Rahul Kumar Patle
sorry its left shift.. one mistake.. other than this ans is correct.. i have
done left shift on 1 by 4 bits that why result became ~(0.1)
ignore the right shift i have mentioned..

On Sun, Nov 25, 2012 at 4:48 PM, Rahul Kumar Patle <
patlerahulku...@gmail.com> wrote:

> @pandey : here you are shifting 1 to right by 4 bit (as rushiraj said
> correctly)
> which becomes 0.1, then you are doing negation which becomes
> 11...0(mask)
> now do you and operation
> mask & 56  = 40
> mask & 64 = 64
> mask & 127 = 111
> you can notice that only 5th lsb (effective value 16) is zero which is
> present in 56 and 127 but not in 64
> so 64 remains the same but 56 and 127 got reduced by 16.
>
>
> On Sat, Nov 24, 2012 at 8:36 PM, Dave  wrote:
>
>> @Rajesh: In binary, mask = 111...10 (with 4-byte ints, this is 27
>> 1-bits followed by 5 0-bits). The logical product of num with mask zeros
>> out the low order 5 bits while retaining the high order 27 bits. Thus, res
>> is num truncated to the largest multiple of 32 that does not exceed num. 56
>> = (1*32 + 24) goes to 1*32 = 32, 64 (=2*32 + 0) stays at 2*32 = 64, and 127
>> (=3*32 + 31) goes to 3*32 = 96.
>>
>> Dave
>>
>> On Saturday, November 24, 2012 2:45:24 AM UTC-6, rajesh pandey wrote:
>>
>>> void dosomething(int num)
>>> {
>>> int mask=~(1<<5-1);
>>> int res=num&mask;
>>>  printf("%d",res);
>>> }
>>> int main()
>>> {
>>> dosomething(56);
>>>  dosomething(64);
>>> dosomething(127);
>>> return 0;
>>> }
>>>
>>> please explain  the logic behind the output.
>>>
>>> Thanks,
>>> Rajesh
>>>
>>  --
>>
>>
>>
>
>
>
> --
> Thanks and Regards:
> Rahul Kumar Patle
> M.Tech, School of Information Technology
> Indian Institute of Technology, Kharagpur-721302, 
> India<http://www.iitkgp.ac.in/>
> Mobile No: +91-8798049298, +91-9424738542
> Alternate Email: rahulkumarpa...@hotmail.com
> [image: 
> Linkedin]<http://www.linkedin.com/profile/view?id=106245716&trk=tab_pro>
> [image: Twitter] <https://twitter.com/rahulkumarpatle>
> <https://www.facebook.com/rkpatle>
>
>


-- 
Thanks and Regards:
Rahul Kumar Patle
M.Tech, School of Information Technology
Indian Institute of Technology, Kharagpur-721302,
India<http://www.iitkgp.ac.in/>
Mobile No: +91-8798049298, +91-9424738542
Alternate Email: rahulkumarpa...@hotmail.com
[image: Linkedin]<http://www.linkedin.com/profile/view?id=106245716&trk=tab_pro>
[image: Twitter] <https://twitter.com/rahulkumarpatle>
<https://www.facebook.com/rkpatle>

-- 




Re: [algogeeks] C o/p adobe

2012-11-15 Thread Rahul Kumar Dubey
@rahulsharma
 file1.c

#include
extern int i;// defintion provided in this file itself
extern int j; // definition provided in file2
void next()
{
++i;
other();
}
int main()
{
++i;
printf("%d\n",j);
printf("%d\n",i);
   next();
}
int i=3;

// end of file1.c

file2.c
extern int i; // declaration of i as extern
int j=10; // j defined in file2 here which was declared as extern in file 1
void other()
{
++i;
printf("%d\n",i);
}
// end of file2.c

compile both file together
as
rahul@rahul:~gcc file1.c file2.c
rahul@rahul:~./a.out
you will get the required output





On Fri, Nov 16, 2012 at 8:27 AM, Neeraj Gangwar wrote:

> That's why you are getting the error. You have to compile both the files
> together. Search on google. I don't use dev c++.
>
> *Neeraj Gangwar*
> B.Tech. IV Year
> Electronics and Communication IDD
> Indian Institute of Technology Roorkee
> Contact No. : +91 9897073730
>
>
> On Thu, Nov 15, 2012 at 11:32 PM, rahul sharma wrote:
>
>>  No...individually...dev cpp..how to compile both together???
>>
>>
>> On Thu, Nov 15, 2012 at 9:26 PM, Neeraj Gangwar 
>> wrote:
>>
>>> Which compiler are you using ? Are you compiling both the files together
>>> ?
>>>
>>> *Neeraj Gangwar*
>>> B.Tech. IV Year
>>> Electronics and Communication IDD
>>> Indian Institute of Technology Roorkee
>>> Contact No. : +91 9897073730
>>>
>>>
>>>
>>> On Thu, Nov 15, 2012 at 9:10 PM, rahul sharma 
>>> wrote:
>>>
>>>> but how can i use extern..if i simply declare a variable in file1 as
>>>> int j and try to use in file2 with extern then it shows that j nit
>>>> defined..how cum file2 knows in which file j is definedfor e.g if i use
>>>> extern in file it means that this variable/fxn is defined somewhr else.then
>>>> what are those files in which it searches this variable definition..i m
>>>> getting errorplese give me 2 files in which one files defines variable
>>>> and other uses using extern.its not working for me
>>>>
>>>> On Thu, Nov 15, 2012 at 12:08 PM, Rahul Kumar Dubey 
>>>> wrote:
>>>>
>>>>> @rahul it will compile perfectly well . note that you have declared j
>>>>> in file 1 as extern and used it and have not provided its definition any
>>>>> where
>>>>> so getting compile error.
>>>>> as far as functions are concerned they are external by defaullt as
>>>>> specified by @shobhit
>>>>>
>>>>> i am attaching your corrected code which runs fine ...
>>>>> file1.c
>>>>>
>>>>>
>>>>> #include
>>>>> extern int i;
>>>>> //extern int j; // provide a declaration for this
>>>>> void next(void);
>>>>>
>>>>> int main()
>>>>> {
>>>>> ++i;
>>>>> printf("%d\n",i);
>>>>>
>>>>> next();
>>>>> getchar();
>>>>> }
>>>>> int i=3;
>>>>> void next()
>>>>> {
>>>>> ++i;
>>>>> printf("%d\n",i);
>>>>> //printf("%d",j); // since no defintion provided so getting error
>>>>> other();
>>>>> }
>>>>>
>>>>> file2.c
>>>>>
>>>>>
>>>>> extern int i;
>>>>> void other()
>>>>> {
>>>>> ++i;
>>>>> printf("%d\n",i);
>>>>> }
>>>>>
>>>>> if you want to use j u need to provide defintion either in file 1 or
>>>>> file 2
>>>>> output:
>>>>> 4
>>>>> 5
>>>>> 6
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Wed, Oct 24, 2012 at 10:56 PM, rahul sharma <
>>>>> rahul23111...@gmail.com> wrote:
>>>>>
>>>>>> can nyone provide me dummy code of how exactly to use extern in c..
>>>>>> in dev environment
>>>>>>
>>>>>> when i declare int i in one fyl
>>>>>> and try use use with extern int i in another then it doesnt
>>>>>> compile..plz coment
>>>>>>
>>>>>>
>>>>>> On Wed, Oct 24, 2012 at 9:58 PM, rahul sharma <
>>>>>> rahul23111...@gmail.co

Re: [algogeeks] time complexity of gcd euclid algo(recursive)

2012-11-15 Thread Rahul Kumar Dubey
The complexity is O(h^2) where h is the number of digits in the smaller
number *m* in base 10.


On Tue, Nov 13, 2012 at 3:34 PM, Shruti Gupta wrote:

> hi
>
> Can anyone help me find out the time complexity of recursive gcd algorithm
> (using euclid's algo)
> i.e. for the following program :
>
> int gcd(int n,int m) //given n>m
> {
>if(n%m==0)
>return m;
>else
> return gcd(m,n%m);
>
> }
>
> i think the soln is lg(a*b) but have no idea how..
>
>  --
> 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.
>



-- 
*RAHUL KUMAR DUBEY*
*BTech-3rd  year *
*Computer Science &Engineering *
*Motilal Nehru National Institute Of Technology*
*Allahabad[211004],UP.*

-- 
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: Printing all inversions in an array

2012-11-14 Thread Rahul Kumar Dubey
@carl barbon
if in worst case to print all inversion it takes O(n^2) why to use merge
sort ot BIT , simply use insertion sort ..


On Wed, Oct 24, 2012 at 12:03 AM, Dipit Grover wrote:

> ^ Exactly!
>
> Dipit Grover
> B.Tech in Computer Science and Engineering - lVth year
> IIT Roorkee, India
>
>
>
>  --
> 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.
>



-- 
*RAHUL KUMAR DUBEY*
*BTech-3rd  year *
*Computer Science &Engineering *
*Motilal Nehru National Institute Of Technology*
*Allahabad[211004],UP.*

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

2012-11-14 Thread Rahul Kumar Dubey
@rahul it will compile perfectly well . note that you have declared j in
file 1 as extern and used it and have not provided its definition any where
so getting compile error.
as far as functions are concerned they are external by defaullt as
specified by @shobhit

i am attaching your corrected code which runs fine ...
file1.c

#include
extern int i;
//extern int j; // provide a declaration for this
void next(void);

int main()
{
++i;
printf("%d\n",i);
next();
getchar();
}
int i=3;
void next()
{
++i;
printf("%d\n",i);
//printf("%d",j); // since no defintion provided so getting error
other();
}

file2.c

extern int i;
void other()
{
++i;
printf("%d\n",i);
}

if you want to use j u need to provide defintion either in file 1 or file 2
output:
4
5
6




On Wed, Oct 24, 2012 at 10:56 PM, rahul sharma wrote:

> can nyone provide me dummy code of how exactly to use extern in c..
> in dev environment
>
> when i declare int i in one fyl
> and try use use with extern int i in another then it doesnt compile..plz
> coment
>
>
> On Wed, Oct 24, 2012 at 9:58 PM, rahul sharma wrote:
>
>> Then why its not running?
>>
>>
>> On Wed, Oct 24, 2012 at 6:50 PM, SHOBHIT GUPTA <
>> shobhitgupta1...@gmail.com> wrote:
>>
>>> http://www.geeksforgeeks.org/archives/840
>>>
>>> By default, the declaration and definition of a C function have “extern”
>>> prepended with them. It means even though we don’t use extern with the
>>> declaration/definition of C functions, it is present there. For example,
>>> when we write.
>>>
>>> int foo(int arg1, char arg2);
>>>
>>> There’s an extern present in the beginning which is hidden and the
>>> compiler treats it as below.
>>>
>>> extern int foo(int arg1, char arg2);
>>>
>>>
>>> On Wed, Oct 24, 2012 at 4:40 PM, rahul sharma 
>>> wrote:
>>>
>>>> Pleaase reply with sol as asp
>>>>
>>>> Fille 1:
>>>> #include
>>>> extern int i;
>>>>
>>>> extern int j;
>>>> void next(void);
>>>> int main()
>>>> {
>>>> ++i;
>>>> printf("%d",i);
>>>> next();
>>>> getchar();
>>>> }
>>>> int i=3;
>>>> void next()
>>>> {
>>>>  ++i;
>>>>  printf("%d",i);
>>>>  printf("%d",j);
>>>> other();
>>>>  }
>>>> File 2:
>>>> extern int i;
>>>>
>>>> void other()
>>>> {
>>>>  ++i;
>>>> printf("%d",i)'
>>>> }
>>>>
>>>> How cum file 1 knows what is other();as we havnet define with
>>>> extern void other();
>>>> it should be error
>>>> but when i include the statemetn extern void other,then also it shows??
>>>> pls provide me o/p of this questiona nd also tell how use use variable
>>>> of one file in other as simply writing extern in a is not accesing global a
>>>> of other file
>>>>
>>>> --
>>>> 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.
>



-- 
*RAHUL KUMAR DUBEY*
*BTech-3rd  year *
*Computer Science &Engineering *
*Motilal Nehru National Institute Of Technology*
*Allahabad[211004],UP.*

-- 
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] using name space std

2012-11-14 Thread Rahul Kumar Dubey
"using namespace std" --> it specify that we want to use whole namespace
named*  std .*

In  std namespace varous objects like cout, cin ,endl etc are define
if we donot  use std namespace then we have to explicitly specify name
namespace in which particular objects are defined
eg. std::cout<<"hello world ";
  std::cin>>x; etc *
for more deatils about namespaces read chapter 10 part 1 (thinking in C++
by bruceckel , very nice explanation )
*


On Tue, Oct 9, 2012 at 8:52 PM, rishabh singh yadav <
rishirocker.sing...@gmail.com> wrote:

>  namespaces allows us to group a set of global classes, objects and/or
> functions under a name. If you specify *using namespace std* then you
> don't have to put *std::* throughout your code.
>
>
> On Tue, Oct 9, 2012 at 7:46 PM, rahul sharma wrote:
>
>> That i know..please tell me its use and need
>>
>>
>> On Tue, Oct 9, 2012 at 12:05 AM, Abhishek Patro wrote:
>>
>>> if u have seen the iostream file then it begins like this:-
>>>
>>> #include 
>>> #include 
>>> #include 
>>> *
>>> *
>>> *namespace std *
>>> {
>>>   /**
>>>*  @name Standard Stream Objects
>>>*
>>>*  The <iostream> header declares the eight standard stream
>>>*  objects.  For other declarations, see
>>>*  http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#10 and
>>> the
>>>*  @link s27_2_iosfwd I/O forward declarations @endlink
>>>*
>>>*  They are required by default to cooperate with the global C
>>> library's
>>>*  @c FILE streams, and to be available during program startup and
>>>*  termination.  For more information, see the HOWTO linked to above.
>>>   */
>>>   //@{
>>>   extern istream cin; ///< Linked to standard input
>>>   extern ostream cout; ///< Linked to standard output
>>>   extern ostream cerr; ///< Linked to standard error (unbuffered)
>>>
>>> The new implementation is done in C# format. So we use the term "using"
>>> to include the iostream "package".
>>>
>>>
>>>
>>> On Tue, Oct 9, 2012 at 12:01 AM, rahul sharma 
>>> wrote:
>>>
>>>> using name space std
>>>>
>>>> Please explain about this
>>>> thnx
>>>>
>>>> --
>>>> 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.
>>>>
>>>
>>>
>>>
>>> --
>>> Abhishek Patro
>>>
>>>  --
>>> 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.
>



-- 
*RAHUL KUMAR DUBEY*
*BTech-3rd  year *
*Computer Science &Engineering *
*Motilal Nehru National Institute Of Technology*
*Allahabad[211004],UP.*

-- 
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] Advice needed

2012-11-14 Thread Rahul Kumar Dubey
modern C does suppport bool
u need to include
*#include *
header
it will work fine as in C++



On Sat, Oct 27, 2012 at 3:21 AM, rahul sharma wrote:

> There is question asked like
> O/p of following in C(32 bit OS)
> #include 
>  #include
> using namespace std;
>
>
> bool IsEqual(char * a)
> {
> printf("abc");
> return true;
> }
>
> int main()
> {
> char str[30];
> printf("%d",sizeof(sizeof(IsEqual(str;
> getchar();
> return 0;
> }
> I run with .cppi know o/p and all in c++...but c doesn't support
> bool.so what should i write in answer as it is asked in written..so wat
> should be writen
>
> 4 i.e the answer in c++ or should i write that c doesn't support bool
>
> plez comment
>
> --
> 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.
>



-- 
*RAHUL KUMAR DUBEY*
*BTech-3rd  year *
*Computer Science &Engineering *
*Motilal Nehru National Institute Of Technology*
*Allahabad[211004],UP.*

-- 
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: Informatica written que : C output

2012-10-31 Thread Rahul Kumar Patle
@shivam: but when i replace
printf("Hello"); by printf("Hello\n");
it works correctly.. can you justify this by your logic..


On Wed, Oct 31, 2012 at 1:07 PM, Shivam Rohilla <
rohillashivam.jade...@gmail.com> wrote:

> Yes it will print 30+ times.
> fork() --> it's create the the child process which copie's the address
> stack of the parent process.
> now when you will do fork();
> look 1st iteration --> it wil break; ( if parent process scheduled 1st by
> the kernel )
> when 2nd iteration --> it will again fork in child process. and will print
> hello once and dan goes to parent dan break.
> when 3rd iteration -->  it will fork again and print hello twice and dan
> break
> when 4th iteration --> it will again fork and prnt hello 4 times i.e.
> hello once by iteration and dan fork child will start process from start
> and dan print hello 3 more times and dan parent will schedule and dan break.
> and so on...
>
> On 31 October 2012 11:49, tendua  wrote:
>
>> \n also flushes the standard output buffer. If it is not present, it is
>> possible that you have previously entered data in it. Flushing also means
>> it forces printf to print on the screen as soon as \n is processed.
>> Otherwise it is buffered output and you can never predict how long would OS
>> buffer your output and when precisely it chooses to actually print.
>>
>> --
>> 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/-/cNFex4s9a8UJ.
>>
>> 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.
>



-- 
Thanks and Regards:
Rahul Kumar Patle
M.Tech, School of Information Technology
Indian Institute of Technology, Kharagpur-721302,
India<http://www.iitkgp.ac.in/>
Mobile No: +91-8798049298, +91-9424738542
Alternate Email: rahulkumarpa...@hotmail.com
[image: Linkedin]<http://www.linkedin.com/profile/view?id=106245716&trk=tab_pro>
[image: Twitter] <https://twitter.com/rahulkumarpatle>
<https://www.facebook.com/rkpatle>

-- 
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] Informatica written que : C output

2012-10-30 Thread Rahul Kumar Patle
can anyone explain the reason for weird output producing by this code..
it is giving output hello many time >30 but as code's logic it should print
only 9 time
it runs correctly when i comment out statements inside else{}
thanks in advance

#include
#include
int count = 0;
main()
{
int tmp[10] , i;
int n = 0;
for(i=0;i<9;i++)
{
tmp[i]=fork();
if(tmp[i]>0)
break;
else
{
//count++;
printf("Hello");
//printf(" %d -> %d \n" , tmp[i], count);
    }
    }
}

-- 
Thanks and Regards:
Rahul Kumar Patle
M.Tech, School of Information Technology
Indian Institute of Technology, Kharagpur-721302,
India<http://www.iitkgp.ac.in/>
Mobile No: +91-8798049298, +91-9424738542
Alternate Email: rahulkumarpa...@hotmail.com
[image: Linkedin]<http://www.linkedin.com/profile/view?id=106245716&trk=tab_pro>
[image: Twitter] <https://twitter.com/rahulkumarpatle>
<https://www.facebook.com/rkpatle>

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



Re: [algogeeks] Microsoft Interview Question

2012-10-16 Thread Rahul Kumar Patle
@atul: in your solution object only can move down or right direction. but
in my problem object is free to move in any direction and hence there are ch
ances of cycle.. how to memoize cycle.
if there is cycle then your approach will give infinite solution.

consider this maze
1  1  0  0  0
1  1  0  0  0
0  1  1  0  0
0  1  1  0  0
0  0  1  1  1

you can see that object can take path
M[0][0] -> M[0][1] -> M[1][1]-> M[1][2]-> M[][]-> M[][]
OR
M[0][0] -> M[1][0] -> M[1][1]-> M[1][2]-> M[][]-> M[][]
But simple approach will also take path
M[0][0] -> M[0][1] -> M[1][1]-> M[1][0]-> M[0][0]-> M[0][1]  -- CYCLE

how you will avoid these cycles...

On Tue, Oct 16, 2012 at 8:58 AM, atul anand  wrote:

> http://www.geeksforgeeks.org/archives/13376
>
>
> On Tue, Oct 16, 2012 at 8:56 AM, atul anand wrote:
>
>> can be done simply by backtracking .
>>
>> On Sat, Oct 13, 2012 at 12:31 AM, Rahul Kumar Patle <
>> patlerahulku...@gmail.com> wrote:
>>
>>> Pls help to solve this que.. does any one have DP solution for following
>>> que.
>>>
>>> http://www.geeksforgeeks.org/archives/24488
>>> section 5/question 2
>>>
>>> Write a program to find all the possible paths from a starting point to
>>> dest point in a maze(2-D array).
>>>
>>> ex: 1 0 1 0
>>> 1 1 1 1
>>> 0 1 0 1
>>> 0 0 1 1
>>>
>>> If there is a block it’s represented by 0.
>>> If there is a path it’s represented by 1.
>>>
>>>
>>>
>>> --
>>> Thanks and Regards:
>>> Rahul Kumar Patle
>>> M.Tech, School of Information Technology
>>> Indian Institute of Technology, Kharagpur-721302, 
>>> India<http://www.iitkgp.ac.in/>
>>> Mobile No: +91-8798049298, +91-9424738542
>>> Alternate Email: rahulkumarpa...@hotmail.com
>>> [image: 
>>> Linkedin]<http://www.linkedin.com/profile/view?id=106245716&trk=tab_pro>
>>> [image: Twitter] <https://twitter.com/rahulkumarpatle>
>>> <https://www.facebook.com/rkpatle>
>>>
>>>  --
>>> 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.
>



-- 
Thanks and Regards:
Rahul Kumar Patle
M.Tech, School of Information Technology
Indian Institute of Technology, Kharagpur-721302,
India<http://www.iitkgp.ac.in/>
Mobile No: +91-8798049298, +91-9424738542
Alternate Email: rahulkumarpa...@hotmail.com
[image: Linkedin]<http://www.linkedin.com/profile/view?id=106245716&trk=tab_pro>
[image: Twitter] <https://twitter.com/rahulkumarpatle>
<https://www.facebook.com/rkpatle>

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

2012-10-15 Thread Rahul Kumar Patle
response awaited!!!
anyone??

On Sat, Oct 13, 2012 at 12:31 AM, Rahul Kumar Patle <
patlerahulku...@gmail.com> wrote:

> Pls help to solve this que.. does any one have DP solution for following
> que.
>
> http://www.geeksforgeeks.org/archives/24488
> section 5/question 2
>
> Write a program to find all the possible paths from a starting point to
> dest point in a maze(2-D array).
>
> ex:   1 0 1 0
>   1 1 1 1
>   0 1 0 1
>   0 0 1 1
>
> If there is a block it’s represented by 0.
> If there is a path it’s represented by 1.
>
>
>
> --
> Thanks and Regards:
> Rahul Kumar Patle
> M.Tech, School of Information Technology
> Indian Institute of Technology, Kharagpur-721302, 
> India<http://www.iitkgp.ac.in/>
> Mobile No: +91-8798049298, +91-9424738542
> Alternate Email: rahulkumarpa...@hotmail.com
> [image: 
> Linkedin]<http://www.linkedin.com/profile/view?id=106245716&trk=tab_pro>
> [image: Twitter] <https://twitter.com/rahulkumarpatle>
> <https://www.facebook.com/rkpatle>
>
>


-- 
Thanks and Regards:
Rahul Kumar Patle
M.Tech, School of Information Technology
Indian Institute of Technology, Kharagpur-721302,
India<http://www.iitkgp.ac.in/>
Mobile No: +91-8798049298, +91-9424738542
Alternate Email: rahulkumarpa...@hotmail.com
[image: Linkedin]<http://www.linkedin.com/profile/view?id=106245716&trk=tab_pro>
[image: Twitter] <https://twitter.com/rahulkumarpatle>
<https://www.facebook.com/rkpatle>

-- 
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] Microsoft Interview Question

2012-10-15 Thread Rahul Kumar Patle
Pls help to solve this que.. does any one have DP solution for following
que.

http://www.geeksforgeeks.org/archives/24488
section 5/question 2

Write a program to find all the possible paths from a starting point to
dest point in a maze(2-D array).

ex: 1 0 1 0
1 1 1 1
0 1 0 1
0 0 1 1

If there is a block it’s represented by 0.
If there is a path it’s represented by 1.



-- 
Thanks and Regards:
Rahul Kumar Patle
M.Tech, School of Information Technology
Indian Institute of Technology, Kharagpur-721302,
India<http://www.iitkgp.ac.in/>
Mobile No: +91-8798049298, +91-9424738542
Alternate Email: rahulkumarpa...@hotmail.com
[image: Linkedin]<http://www.linkedin.com/profile/view?id=106245716&trk=tab_pro>
[image: Twitter] <https://twitter.com/rahulkumarpatle>
<https://www.facebook.com/rkpatle>

-- 
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] longest palindrome in a string size 2*10^4

2012-09-23 Thread Rahul Kumar Dubey
 *Manacher's algorithm *
*
*
*Its a famous algorithm for finding longest palindrome in a string in O(n)*
*have a look at it on internet ...*
*http://www.leetcode.com/2011/11/longest-palindromic-substring-part-ii.html*
see if it can help you ..

On Sun, Sep 23, 2012 at 5:29 PM, Navin Kumar wrote:

> " *Ukkonen's algorithm* is a linear-time, online 
> algorithm<http://en.wikipedia.org/wiki/Online_algorithm>for constructing 
> suffix
> trees <http://en.wikipedia.org/wiki/Suffix_tree>, proposed by Esko 
> Ukkonen<http://en.wikipedia.org/w/index.php?title=Esko_Ukkonen&action=edit&redlink=1>in
>  1995"
>
> source: wikipedia
>
>
> On Sun, Sep 23, 2012 at 5:08 PM, Navin Kumar wrote:
>
>> Build a common suffix tree for the given string and for its reverse. Then
>> take out the string ending at maximum depth at a common node. Time
>> complexity would be linear.
>>
>> On Sat, Sep 22, 2012 at 5:33 PM, Aditya Raman > > wrote:
>>
>>> Hello everybody,
>>> I need to find a way of finding the longest palindrome in a very very
>>> long string (n<=2) . a linear time algo is expected. help me out
>>>
>>> --
>>> 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/-/JdXOBU9fu34J.
>>> 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.
>



-- 
*RAHUL KUMAR DUBEY*
*BTech-3rd  year *
*Computer Science &Engineering *
*Motilal Nehru National Institute Of Technology*
*Allahabad[211004],UP.*

-- 
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] Adobe Written Test - 25 SEPT 2010

2012-09-23 Thread Rahul Kumar Patle
@dave sir: i understand your point, here my solution is only limited to
hold the divisor in range of integer..

On Sat, Sep 22, 2012 at 1:41 AM, Dave  wrote:

> @Rahul: What does this print for n = 193?
>
> Dave
>
> On Friday, September 21, 2012 12:14:18 AM UTC-5, Rahul Kumar Patle wrote:
>
>> here is my code:
>>
>> main()
>> {
>> int n=13;
>> int divisor=1;
>> int temp;
>> while( divisor < n )
>> divisor = 10 * divisor + 1;
>> printf("%d\n" , divisor);
>> temp = divisor;
>> while(n)
>> {
>> if(temp%n == 0)
>> break;
>> temp = 10 * (temp % n) + 1;
>> divisor = 10 * divisor + 1;
>> while( temp < n )
>> {
>> divisor = 10 * divisor + 1;
>> temp = 10 * temp + 1;
>> }
>> printf("%d and %d\n" , divisor, temp);
>> }
>> printf("%d\n", divisor);
>> }
>>
>>
>>
>> On Fri, Sep 21, 2012 at 10:30 AM, Rahul Kumar Patle > > wrote:
>>
>>> @navin: you have to find a number containing all 1's which is divisible
>>> by a given number xx...3, here given number contains 3 at it unit place...
>>>
>>> On Fri, Sep 21, 2012 at 10:25 AM, Navin Kumar wrote:
>>>
>>>>  @all: Please explain question number 8. I am not getting the question
>>>> exactly what it says ?
>>>>
>>>> On Fri, Sep 21, 2012 at 9:30 AM, Dave  wrote:
>>>>
>>>>> @Bharat: Simulate long division, dividing a number ...1 by the
>>>>> number. You can do this one digit at a time, printing the quotient digit 
>>>>> by
>>>>> digit until you "bring down" a zero. It could look something like this:
>>>>>
>>>>> int n=;
>>>>> int divisor=1;
>>>>> while( divisor < n )
>>>>> divisor = 10 * divisor + 1;
>>>>> while( divisor != 0 )
>>>>> {
>>>>> printf("%d",divisor / n);
>>>>> divisor = 10 * (divisor % n) + 1;
>>>>> }
>>>>> printf("\n");
>>>>>
>>>>> Dave
>>>>>
>>>>> On Thursday, September 20, 2012 9:45:55 PM UTC-5, bharat wrote:
>>>>>
>>>>>> what is the solution(not brute force) for 8th question ?
>>>>>>
>>>>>> On Fri, Sep 14, 2012 at 5:19 PM, Bhupendra Dubey >>>>> > wrote:
>>>>>>
>>>>>>> Which edition of barron?
>>>>>>>
>>>>>>>
>>>>>>> On Wed, Sep 28, 2011 at 6:05 PM, VIHARRI  wrote:
>>>>>>>
>>>>>>>> 1. Java uses stack for byte code in JVM - each instruction is of one
>>>>>>>> byte, so how many such instructions are possible in an operating
>>>>>>>> system.
>>>>>>>>
>>>>>>>> 2. Three processes p1, p2, p3, p4 - each have sizes 1GB, 1.2GB, 2GB,
>>>>>>>> 1GB. And each processes is executed as a time sharing fashion. Will
>>>>>>>> they be executed on an operating system.
>>>>>>>>
>>>>>>>> 3. write a recursive program for reversing the linked list.
>>>>>>>>
>>>>>>>> 4. write a program for checking the given number is a palindrome.
>>>>>>>> ( dont use string / array for converting number ).
>>>>>>>>
>>>>>>>> 5. write a recursive program for multiplying two numbers a and b,
>>>>>>>> with
>>>>>>>> additions. The program should take care of doing min # additions as
>>>>>>>> that of which ever number is lower between a and b.
>>>>>>>>
>>>>>>>> 6. There are two sets A and B with n integers, write a program to
>>>>>>>> check the whether there exists two numbers a in A and b in B such
>>>>>>>> that
>>>>>>>> a+b = val ( val is given );
>>>>>>>>
>>>>>>>> 7. write a program to return the row number which has max no of
>>>>>>>> one's
>>>>>>>> in an array of NxN matrix where all 1's occur before any 0's starts.
>>>>>>>>
>>>>>>>> 8. For every number that has 3 in its units place

Re: [algogeeks] Adobe Written Test - 25 SEPT 2010

2012-09-21 Thread Rahul Kumar Patle
here is my code:

main()
{
int n=13;
int divisor=1;
int temp;
while( divisor < n )
divisor = 10 * divisor + 1;
printf("%d\n" , divisor);
temp = divisor;
while(n)
{
if(temp%n == 0)
break;
temp = 10 * (temp % n) + 1;
divisor = 10 * divisor + 1;
while( temp < n )
{
divisor = 10 * divisor + 1;
temp = 10 * temp + 1;
}
printf("%d and %d\n" , divisor, temp);
}
printf("%d\n", divisor);
}



On Fri, Sep 21, 2012 at 10:30 AM, Rahul Kumar Patle <
patlerahulku...@gmail.com> wrote:

> @navin: you have to find a number containing all 1's which is divisible by
> a given number xx...3, here given number contains 3 at it unit place...
>
> On Fri, Sep 21, 2012 at 10:25 AM, Navin Kumar wrote:
>
>> @all: Please explain question number 8. I am not getting the question
>> exactly what it says ?
>>
>> On Fri, Sep 21, 2012 at 9:30 AM, Dave  wrote:
>>
>>> @Bharat: Simulate long division, dividing a number ...1 by the
>>> number. You can do this one digit at a time, printing the quotient digit by
>>> digit until you "bring down" a zero. It could look something like this:
>>>
>>> int n=;
>>> int divisor=1;
>>> while( divisor < n )
>>> divisor = 10 * divisor + 1;
>>> while( divisor != 0 )
>>> {
>>> printf("%d",divisor / n);
>>> divisor = 10 * (divisor % n) + 1;
>>> }
>>> printf("\n");
>>>
>>> Dave
>>>
>>> On Thursday, September 20, 2012 9:45:55 PM UTC-5, bharat wrote:
>>>
>>>> what is the solution(not brute force) for 8th question ?
>>>>
>>>> On Fri, Sep 14, 2012 at 5:19 PM, Bhupendra Dubey 
>>>> wrote:
>>>>
>>>>> Which edition of barron?
>>>>>
>>>>>
>>>>> On Wed, Sep 28, 2011 at 6:05 PM, VIHARRI  wrote:
>>>>>
>>>>>> 1. Java uses stack for byte code in JVM - each instruction is of one
>>>>>> byte, so how many such instructions are possible in an operating
>>>>>> system.
>>>>>>
>>>>>> 2. Three processes p1, p2, p3, p4 - each have sizes 1GB, 1.2GB, 2GB,
>>>>>> 1GB. And each processes is executed as a time sharing fashion. Will
>>>>>> they be executed on an operating system.
>>>>>>
>>>>>> 3. write a recursive program for reversing the linked list.
>>>>>>
>>>>>> 4. write a program for checking the given number is a palindrome.
>>>>>> ( dont use string / array for converting number ).
>>>>>>
>>>>>> 5. write a recursive program for multiplying two numbers a and b, with
>>>>>> additions. The program should take care of doing min # additions as
>>>>>> that of which ever number is lower between a and b.
>>>>>>
>>>>>> 6. There are two sets A and B with n integers, write a program to
>>>>>> check the whether there exists two numbers a in A and b in B such that
>>>>>> a+b = val ( val is given );
>>>>>>
>>>>>> 7. write a program to return the row number which has max no of one's
>>>>>> in an array of NxN matrix where all 1's occur before any 0's starts.
>>>>>>
>>>>>> 8. For every number that has 3 in its units place has one multiple
>>>>>> which has all one's i.e. 111 is such multiple and 13 has a multiple
>>>>>> 11. Write a program to find such multiple for any number that has
>>>>>> 3 at its units place.
>>>>>>
>>>>>> 9. what are the maximum no of edges that can be connected in a graph
>>>>>> of n vertices and 0 edges such that after adding edges given graph is
>>>>>> still disconnected.
>>>>>>
>>>>>> 10. One Question on critical section.
>>>>>>
>>>>>> For Analytical Test - Prepare the Questions in the barrons book of
>>>>>> sample paper - 2 ( they have give two passages )
>>>>>>
>>>>>> --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "Algorithm Geeks" group.
>>>>>> To post to this group, send email to algo...@googlegroups.com.
>>>>>> To unsubscribe from this group, send email to algogeeks+...@**
>>>>&g

Re: [algogeeks] Adobe Written Test - 25 SEPT 2010

2012-09-21 Thread Rahul Kumar Patle
@navin: you have to find a number containing all 1's which is divisible by
a given number xx...3, here given number contains 3 at it unit place...

On Fri, Sep 21, 2012 at 10:25 AM, Navin Kumar wrote:

> @all: Please explain question number 8. I am not getting the question
> exactly what it says ?
>
> On Fri, Sep 21, 2012 at 9:30 AM, Dave  wrote:
>
>> @Bharat: Simulate long division, dividing a number ...1 by the
>> number. You can do this one digit at a time, printing the quotient digit by
>> digit until you "bring down" a zero. It could look something like this:
>>
>> int n=;
>> int divisor=1;
>> while( divisor < n )
>> divisor = 10 * divisor + 1;
>> while( divisor != 0 )
>> {
>> printf("%d",divisor / n);
>> divisor = 10 * (divisor % n) + 1;
>> }
>> printf("\n");
>>
>> Dave
>>
>> On Thursday, September 20, 2012 9:45:55 PM UTC-5, bharat wrote:
>>
>>> what is the solution(not brute force) for 8th question ?
>>>
>>> On Fri, Sep 14, 2012 at 5:19 PM, Bhupendra Dubey wrote:
>>>
>>>> Which edition of barron?
>>>>
>>>>
>>>> On Wed, Sep 28, 2011 at 6:05 PM, VIHARRI  wrote:
>>>>
>>>>> 1. Java uses stack for byte code in JVM - each instruction is of one
>>>>> byte, so how many such instructions are possible in an operating
>>>>> system.
>>>>>
>>>>> 2. Three processes p1, p2, p3, p4 - each have sizes 1GB, 1.2GB, 2GB,
>>>>> 1GB. And each processes is executed as a time sharing fashion. Will
>>>>> they be executed on an operating system.
>>>>>
>>>>> 3. write a recursive program for reversing the linked list.
>>>>>
>>>>> 4. write a program for checking the given number is a palindrome.
>>>>> ( dont use string / array for converting number ).
>>>>>
>>>>> 5. write a recursive program for multiplying two numbers a and b, with
>>>>> additions. The program should take care of doing min # additions as
>>>>> that of which ever number is lower between a and b.
>>>>>
>>>>> 6. There are two sets A and B with n integers, write a program to
>>>>> check the whether there exists two numbers a in A and b in B such that
>>>>> a+b = val ( val is given );
>>>>>
>>>>> 7. write a program to return the row number which has max no of one's
>>>>> in an array of NxN matrix where all 1's occur before any 0's starts.
>>>>>
>>>>> 8. For every number that has 3 in its units place has one multiple
>>>>> which has all one's i.e. 111 is such multiple and 13 has a multiple
>>>>> 11. Write a program to find such multiple for any number that has
>>>>> 3 at its units place.
>>>>>
>>>>> 9. what are the maximum no of edges that can be connected in a graph
>>>>> of n vertices and 0 edges such that after adding edges given graph is
>>>>> still disconnected.
>>>>>
>>>>> 10. One Question on critical section.
>>>>>
>>>>> For Analytical Test - Prepare the Questions in the barrons book of
>>>>> sample paper - 2 ( they have give two passages )
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Algorithm Geeks" group.
>>>>> To post to this group, send email to algo...@googlegroups.com.
>>>>> To unsubscribe from this group, send email to algogeeks+...@**
>>>>> googlegroups.com.
>>>>>
>>>>> For more options, visit this group at http://groups.google.com/**
>>>>> group/algogeeks?hl=en <http://groups.google.com/group/algogeeks?hl=en>
>>>>> .
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Thanks & regards
>>>> Bhupendra
>>>>
>>>>
>>>>
>>>>  --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To post to this group, send email to algo...@googlegroups.com.
>>>> To unsubscribe from this group, send email to algogeeks+...@**
>>>> googlegroups.com.
>>>>
>>>> For more options, visit this group at http://groups.google.

Re: [algogeeks] Data Structure

2012-09-21 Thread Rahul Kumar Patle
@atul: nicely explained,
@ashish: i think question is not asked about the data structure required
for "back" or "forward" button of browser, are you thinking in that term??
what advantage you will have using stack?
and as i think this choice may be developer dependent, because here we have
to store the history just in serial order, as we can see how chrome shows
the history, if developer want to customize it in some manner so that user
can view the history from different angle then it can use specific data
structure..

On Tue, Sep 18, 2012 at 5:38 PM, atul anand  wrote:

> i guess even circular queue , make new queue for each date
> now add all urls to this queue say for monday
> for Tuesday create another queue ..and soo on
> now at the end of day you just add queue to the hastable with key = day
> (say monday ) and value=queue reference.
>
> you can do these till sunday , after sunday created new queue say
> "last_week" and append all queues created to the this new queue and add it
> to hastable.
> clear all  previous "monday" to "sunday" queues.
> and start creating queue for new week.
>
>
>
> On Tue, Sep 18, 2012 at 1:20 PM, Navin Kumar wrote:
>
>>
>> Which data structure is used to maintain browser history?
>>
>> --
>> 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/-/MCj-0bFwvV0J.
>> 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.
>



-- 
Thanks and Regards:
Rahul Kumar Patle<http://www.linkedin.com/profile/view?id=106245716&trk=tab_pro>
M.Tech, School of Information Technology
Indian Institute of Technology, Kharagpur-721302,
India<http://www.iitkgp.ac.in/>
Mobile No: +91-8798049298, +91-9424738542
Alternate Email: rahulkumarpa...@hotmail.com

-- 
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] help to give DP solution

2012-09-16 Thread Rahul Kumar Patle
@atul: in Hungarian Algorithms works for minimization of cost where the
terminating condition is based on zeros.. in my problem what value i will
have to consider as base/terminating values because there may not be same
values in coloumn and rows..
second thing you use subtraction there, here will i have to use addition..??
please clarify..
i have seen following link:
http://s-mat-pcs.oulu.fi/~mpa/matreng/eem1_2-1.htm
if you have link which explains maximization problem..
please post here..

On Sun, Sep 16, 2012 at 12:44 AM, atul anand wrote:

> correct me if i am wrong ,
> it seems similar to Hungarian algorithm.
> here each column can be considered as persons P(p0,p1,p2,..pn) and each as
> cost of job say X(x0,x1,x2,x3,x4xn).
>  Hungarian algorithm tells how to find minimal but here its maximal...so i
> guess changes in the algo will give the outputl
>
> On Sat, Sep 15, 2012 at 9:10 PM, Rahul Kumar Patle <
> patlerahulku...@gmail.com> wrote:
>
>> A 2D array of order A[N][N] is given, considering entry A[i][i] as
>> invalid you have to select one element from each row such that
>> 1. Selected elements does not belong to same column.
>> 2. Sum of selected element has maximal.
>>
>>
>> --
>> Thanks and Regards:
>> Rahul Kumar 
>> Patle<http://www.linkedin.com/profile/view?id=106245716&trk=tab_pro>
>> M.Tech, School of Information Technology
>> Indian Institute of Technology, Kharagpur-721302, 
>> India<http://www.iitkgp.ac.in/>
>> Mobile No: +91-8798049298, +91-9424738542
>> Alternate Email: rahulkumarpa...@hotmail.com
>>
>>  --
>> 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.
>



-- 
Thanks and Regards:
Rahul Kumar Patle<http://www.linkedin.com/profile/view?id=106245716&trk=tab_pro>
M.Tech, School of Information Technology
Indian Institute of Technology, Kharagpur-721302,
India<http://www.iitkgp.ac.in/>
Mobile No: +91-8798049298, +91-9424738542
Alternate Email: rahulkumarpa...@hotmail.com

-- 
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] help to give DP solution

2012-09-15 Thread Rahul Kumar Patle
A 2D array of order A[N][N] is given, considering entry A[i][i] as invalid
you have to select one element from each row such that
1. Selected elements does not belong to same column.
2. Sum of selected element has maximal.


-- 
Thanks and Regards:
Rahul Kumar Patle<http://www.linkedin.com/profile/view?id=106245716&trk=tab_pro>
M.Tech, School of Information Technology
Indian Institute of Technology, Kharagpur-721302,
India<http://www.iitkgp.ac.in/>
Mobile No: +91-8798049298, +91-9424738542
Alternate Email: rahulkumarpa...@hotmail.com

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



Re: [algogeeks] Microsoft written test question

2012-09-06 Thread Rahul Kumar Patle
@shashi: once we have two pointer where anomalies exist, we can exchange
their data value to obtain original BST...

On Wed, Sep 5, 2012 at 12:38 PM, shashi kant  wrote:

> Is it required only to retain the BST property ??  or to retain the
> original BST (tree)
>
>
>
>
> *Shashi Kant *
> ***"Think positive and find fuel in failure"*
> http://thinkndoawesome.blogspot.com/
> *System/Software Engineer*
> *Hewlett-Packard India Software Operations.
> *
>
>
>
> On Tue, Sep 4, 2012 at 1:56 PM, Rahul Kumar Patle <
> patlerahulku...@gmail.com> wrote:
>
>> @atul: correctly caught...
>> here you have to notice that if u get only one violation not second
>> violation ill the last... then sure the violation is created because of
>> swapping of previous and current of first violation...
>> so when you got first violation and put first marker on previous time put
>> second marker on current...
>> suppose and the last if you don't get the second violation then 2nd
>> marker will the current node of first violation...
>> as in your case when we got first violation at node prev = 20 and current
>> = 10.. mark first point at 20 and second pointer at 10.. at the last the
>> 2nd pointer does not get change...
>> i have checked this with other test cases.. this case is coming only when
>> previous and current are the consecutive nodes(parent and its direct child)
>> and one of the node is leaf node...
>>
>> On Tue, Sep 4, 2012 at 1:22 AM, atul anand wrote:
>>
>>> i guess i missed this part of bharat post :-
>>> /*
>>> If we don't get the violation for the second time .. means both are
>>> side-by-side elements .. swap them ..
>>> */
>>> i was saying the same.so it will work.
>>>
>>>
>>> On 9/4/12, atul anand  wrote:
>>> > @rahul : Here are the boundary cases need to be taken care of :-
>>> > suppose given BST is the following :-
>>> >
>>> > root=allocate(70);
>>> > root->right=allocate(75);
>>> > root->left=allocate(50);
>>> > root->left->left=allocate(20);
>>> > root->left->left->right=allocate(25);
>>> > root->left->left->left=allocate(10);
>>> > root->left->right=allocate(60);
>>> > root->left->right->right=allocate(65);
>>> > root->left->right->left=allocate(55);
>>> >
>>> > now suppose node(20) and node(10) get swapped
>>> >
>>> > inorder of given tree is :-
>>> > 20 10 25 50 55 60 65 70 75
>>> >
>>> > now first violation is at node(20)
>>> > but you wont get second voilation...because rest is in inc order.
>>> >
>>> > yes , it can be done by taking care of root of that first violation.
>>> >
>>> >
>>> > On 9/3/12, Rahul Kumar Patle  wrote:
>>> >> @bharat: +1
>>> >> i have tried some test cases.. working finely.. @anyone pls verify??
>>> >>
>>> >> On Mon, Sep 3, 2012 at 11:58 AM, bharat b
>>> >> wrote:
>>> >>
>>> >>> while doing in-order traversal, we have to check if(prev > current)
>>> -->
>>> >>> then mark prev element for swapping in the first time violation..
>>> >>> if it happens for the second time..then mark current element for
>>> >>> swapping.
>>> >>> swap both ..
>>> >>>
>>> >>> If we don't get the violation for the second time .. means both are
>>> >>> side-by-side elements .. swap them ..
>>> >>>
>>> >>> Hope works .. If I miss any case .. correct me
>>> >>> thanks,
>>> >>>
>>> >>>
>>> >>> On Sun, Sep 2, 2012 at 7:45 PM, Rahul Kumar Patle <
>>> >>> patlerahulku...@gmail.com> wrote:
>>> >>>
>>> >>>> @navin: can u explain ur algorithms in words pls..
>>> >>>>
>>> >>>> On Sun, Sep 2, 2012 at 5:53 PM, Navin Kumar
>>> >>>> wrote:
>>> >>>>
>>> >>>>> void correctBST(struct node *root)
>>> >>>>> {
>>> >>>>>   int flag =0;
>>> >>>>>   static struct node *temp1, *temp2, *temp3, *prev;
>>> >>>>>   static int found;
>>> >>>>>
>>> >>>>>  

Re: [algogeeks] Microsoft written test question

2012-09-04 Thread Rahul Kumar Patle
@atul: correctly caught...
here you have to notice that if u get only one violation not second
violation ill the last... then sure the violation is created because of
swapping of previous and current of first violation...
so when you got first violation and put first marker on previous time put
second marker on current...
suppose and the last if you don't get the second violation then 2nd marker
will the current node of first violation...
as in your case when we got first violation at node prev = 20 and current =
10.. mark first point at 20 and second pointer at 10.. at the last the 2nd
pointer does not get change...
i have checked this with other test cases.. this case is coming only when
previous and current are the consecutive nodes(parent and its direct child)
and one of the node is leaf node...

On Tue, Sep 4, 2012 at 1:22 AM, atul anand  wrote:

> i guess i missed this part of bharat post :-
> /*
> If we don't get the violation for the second time .. means both are
> side-by-side elements .. swap them ..
> */
> i was saying the same.so it will work.
>
>
> On 9/4/12, atul anand  wrote:
> > @rahul : Here are the boundary cases need to be taken care of :-
> > suppose given BST is the following :-
> >
> > root=allocate(70);
> > root->right=allocate(75);
> > root->left=allocate(50);
> > root->left->left=allocate(20);
> > root->left->left->right=allocate(25);
> > root->left->left->left=allocate(10);
> > root->left->right=allocate(60);
> > root->left->right->right=allocate(65);
> > root->left->right->left=allocate(55);
> >
> > now suppose node(20) and node(10) get swapped
> >
> > inorder of given tree is :-
> > 20 10 25 50 55 60 65 70 75
> >
> > now first violation is at node(20)
> > but you wont get second voilation...because rest is in inc order.
> >
> > yes , it can be done by taking care of root of that first violation.
> >
> >
> > On 9/3/12, Rahul Kumar Patle  wrote:
> >> @bharat: +1
> >> i have tried some test cases.. working finely.. @anyone pls verify??
> >>
> >> On Mon, Sep 3, 2012 at 11:58 AM, bharat b
> >> wrote:
> >>
> >>> while doing in-order traversal, we have to check if(prev > current) -->
> >>> then mark prev element for swapping in the first time violation..
> >>> if it happens for the second time..then mark current element for
> >>> swapping.
> >>> swap both ..
> >>>
> >>> If we don't get the violation for the second time .. means both are
> >>> side-by-side elements .. swap them ..
> >>>
> >>> Hope works .. If I miss any case .. correct me
> >>> thanks,
> >>>
> >>>
> >>> On Sun, Sep 2, 2012 at 7:45 PM, Rahul Kumar Patle <
> >>> patlerahulku...@gmail.com> wrote:
> >>>
> >>>> @navin: can u explain ur algorithms in words pls..
> >>>>
> >>>> On Sun, Sep 2, 2012 at 5:53 PM, Navin Kumar
> >>>> wrote:
> >>>>
> >>>>> void correctBST(struct node *root)
> >>>>> {
> >>>>>   int flag =0;
> >>>>>   static struct node *temp1, *temp2, *temp3, *prev;
> >>>>>   static int found;
> >>>>>
> >>>>>   if(found) return;
> >>>>>
> >>>>>   if(root) {
> >>>>>   correctBST(root->left);
> >>>>>   if(!temp1 && prev && root->data < prev->data) {
> >>>>>   temp1 = prev;
> >>>>>   temp2 = root;
> >>>>>   swap(&(temp1->data), &(temp2->data));
> >>>>>   flag = 1;
> >>>>>   prev = temp1;
> >>>>>   }
> >>>>>   else if(!temp3 && prev && root->data < prev->data) {
> >>>>>   temp3 = root;
> >>>>>   swap(&(temp1->data), &(temp2->data));
> >>>>>   swap(&(temp1->data), &(temp3->data));
> >>>>>   found = 1;
> >>>>>   return;
> >>>>>   }
> >>>>>   if(!flag)
> >>>>>  prev = root;
> >>>>>   correctBST(root->right);
> >>>>>   }
> >>>>> }
> >>>>>
> >>>>> On Sun, Sep 2, 2012 at 4:02 PM, Rahul Kum

Re: [algogeeks] Microsoft written test question

2012-09-03 Thread Rahul Kumar Patle
@bharat: +1
i have tried some test cases.. working finely.. @anyone pls verify??

On Mon, Sep 3, 2012 at 11:58 AM, bharat b wrote:

> while doing in-order traversal, we have to check if(prev > current) -->
> then mark prev element for swapping in the first time violation..
> if it happens for the second time..then mark current element for swapping.
> swap both ..
>
> If we don't get the violation for the second time .. means both are
> side-by-side elements .. swap them ..
>
> Hope works .. If I miss any case .. correct me
> thanks,
>
>
> On Sun, Sep 2, 2012 at 7:45 PM, Rahul Kumar Patle <
> patlerahulku...@gmail.com> wrote:
>
>> @navin: can u explain ur algorithms in words pls..
>>
>> On Sun, Sep 2, 2012 at 5:53 PM, Navin Kumar wrote:
>>
>>> void correctBST(struct node *root)
>>> {
>>>   int flag =0;
>>>   static struct node *temp1, *temp2, *temp3, *prev;
>>>   static int found;
>>>
>>>   if(found) return;
>>>
>>>   if(root) {
>>>   correctBST(root->left);
>>>   if(!temp1 && prev && root->data < prev->data) {
>>>   temp1 = prev;
>>>   temp2 = root;
>>>   swap(&(temp1->data), &(temp2->data));
>>>   flag = 1;
>>>   prev = temp1;
>>>   }
>>>   else if(!temp3 && prev && root->data < prev->data) {
>>>   temp3 = root;
>>>   swap(&(temp1->data), &(temp2->data));
>>>   swap(&(temp1->data), &(temp3->data));
>>>   found = 1;
>>>   return;
>>>   }
>>>   if(!flag)
>>>  prev = root;
>>>       correctBST(root->right);
>>>   }
>>> }
>>>
>>> On Sun, Sep 2, 2012 at 4:02 PM, Rahul Kumar Patle <
>>> patlerahulku...@gmail.com> wrote:
>>>
>>>> help to solve the following..
>>>> Question: Two of the nodes of a BST are swapped. Correct the BST (taken
>>>> from GeekforGeeks <http://www.geeksforgeeks.org/archives/23272> 2nd
>>>> online test 3rd question)
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Thanks and Regards:
>>>> Rahul Kumar 
>>>> Patle<http://www.linkedin.com/profile/view?id=106245716&trk=tab_pro>
>>>> M.Tech, School of Information Technology
>>>> Indian Institute of Technology, Kharagpur-721302, 
>>>> India<http://www.iitkgp.ac.in/>
>>>> Mobile No: +91-8798049298, +91-9424738542
>>>> Alternate Email: rahulkumarpa...@hotmail.com
>>>>
>>>>  --
>>>> 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.
>>>
>>
>>
>>
>> --
>> Thanks and Regards:
>> Rahul Kumar 
>> Patle<http://www.linkedin.com/profile/view?id=106245716&trk=tab_pro>
>> M.Tech, School of Information Technology
>> Indian Institute of Technology, Kharagpur-721302, 
>> India<http://www.iitkgp.ac.in/>
>> Mobile No: +91-8798049298, +91-9424738542
>> Alternate Email: rahulkumarpa...@hotmail.com
>>
>>  --
>> 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.
>



-- 
Thanks and Regards:
Rahul Kumar Patle<http://www.linkedin.com/profile/view?id=106245716&trk=tab_pro>
M.Tech, School of Information Technology
Indian Institute of Technology, Kharagpur-721302,
India<http://www.iitkgp.ac.in/>
Mobile No: +91-8798049298, +91-9424738542
Alternate Email: rahulkumarpa...@hotmail.com

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



Re: [algogeeks] MICROSOFT:Given a BST and a number. Find two node in a BST whose sum is equal to given number in O(n) time and O(1) space.

2012-09-03 Thread Rahul Kumar Patle
@dave same doubt as @atul, how we can manage both function parallel
and to all can we traverse a tree using some looping instead of traditional
recursive methods..??

On Mon, Sep 3, 2012 at 1:13 PM, atul anand  wrote:

> @Dave : algo seems fine...but it seems to me that it would difficult to
> maintain both left to right and right to left parallel way :( :( .
> it would be gr8 if you can provided little bit of coded algorithm for it.
>
>
> On Mon, Sep 3, 2012 at 10:36 AM, Dave  wrote:
>
>> @Atul007: No need to destroy the BST. Perform two simultaneous inorder
>> traversals of the BST, one from left to right (the usual direction) and one
>> from right to left. At any stage you have selected two nodes. If the sum is
>> less than the given number, advance the left-to-right traversal; If the sum
>> is greater, advance the right-to-left traversal. Quit with success when the
>> sum equals the given number or with failure when the two traversals have
>> reached the same node.
>> Dave
>>
>> On Sunday, September 2, 2012 11:00:42 PM UTC-5, atul007 wrote:
>>
>>> convert BST to sorted DLL..
>>> now it is a double linked list , so we can find 2 number in O(n)  time
>>> by keeping 2 pointers(one at start and one at end) from sorted DLL.
>>> now convert DLL to BST.
>>>
>>>  On Mon, Sep 3, 2012 at 1:32 AM, Navin Kumar wrote:
>>> MICROSOFT:Given a BST and a number. Find two node in a BST whose sum is
>>> equal to given number in O(n) time and O(1) space.
>>>
>>>  --
>> 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/-/oizd-5CSfuoJ.
>>
>> 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.
>



-- 
Thanks and Regards:
Rahul Kumar Patle<http://www.linkedin.com/profile/view?id=106245716&trk=tab_pro>
M.Tech, School of Information Technology
Indian Institute of Technology, Kharagpur-721302,
India<http://www.iitkgp.ac.in/>
Mobile No: +91-8798049298, +91-9424738542
Alternate Email: rahulkumarpa...@hotmail.com

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



Re: [algogeeks] Microsoft written test question

2012-09-02 Thread Rahul Kumar Patle
@navin: can u explain ur algorithms in words pls..

On Sun, Sep 2, 2012 at 5:53 PM, Navin Kumar wrote:

> void correctBST(struct node *root)
> {
>   int flag =0;
>   static struct node *temp1, *temp2, *temp3, *prev;
>   static int found;
>
>   if(found) return;
>
>   if(root) {
>   correctBST(root->left);
>   if(!temp1 && prev && root->data < prev->data) {
>   temp1 = prev;
>   temp2 = root;
>   swap(&(temp1->data), &(temp2->data));
>   flag = 1;
>   prev = temp1;
>   }
>   else if(!temp3 && prev && root->data < prev->data) {
>   temp3 = root;
>   swap(&(temp1->data), &(temp2->data));
>   swap(&(temp1->data), &(temp3->data));
>   found = 1;
>   return;
>   }
>   if(!flag)
>  prev = root;
>   correctBST(root->right);
>   }
> }
>
> On Sun, Sep 2, 2012 at 4:02 PM, Rahul Kumar Patle <
> patlerahulku...@gmail.com> wrote:
>
>> help to solve the following..
>> Question: Two of the nodes of a BST are swapped. Correct the BST (taken
>> from GeekforGeeks <http://www.geeksforgeeks.org/archives/23272> 2nd
>> online test 3rd question)
>>
>>
>>
>>
>> --
>> Thanks and Regards:
>> Rahul Kumar 
>> Patle<http://www.linkedin.com/profile/view?id=106245716&trk=tab_pro>
>> M.Tech, School of Information Technology
>> Indian Institute of Technology, Kharagpur-721302, 
>> India<http://www.iitkgp.ac.in/>
>> Mobile No: +91-8798049298, +91-9424738542
>> Alternate Email: rahulkumarpa...@hotmail.com
>>
>>  --
>> 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.
>



-- 
Thanks and Regards:
Rahul Kumar Patle<http://www.linkedin.com/profile/view?id=106245716&trk=tab_pro>
M.Tech, School of Information Technology
Indian Institute of Technology, Kharagpur-721302,
India<http://www.iitkgp.ac.in/>
Mobile No: +91-8798049298, +91-9424738542
Alternate Email: rahulkumarpa...@hotmail.com

-- 
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] explain the ouput

2012-09-02 Thread Rahul Kumar Dubey
@Rajat Dubey

Actually C forbids the use of sizeof() operator to a function  name .(you
can see the warning using "gcc -pedantic" option of gcc )

so by writing
printf("%d",sizeof(fn) );  // u r trying to get the size of function "fn"
which in no way legal .
and output 1 is compiler dependent .

compile above program with g++ (that is in C++ )  you will get Error as it
has been made illegal in c++ now. and applyiong ""sizeof " to an expression
of funtion type is illegal.

// but printf("%d\n",sizeof(fn())); here its the "sizeof " return value of
function call

On Sun, Sep 2, 2012 at 11:12 AM, RAJAT DUBEY wrote:

> @Rahul kumar Dubey
>
> #include
> double fn(char *a , int b , char c)
> {
> return (1.1);
> }
>
> int main()
> {
> int it = 2;
> char ct = 'c';
> char a[30];
> printf("%d\n",(sizeof(fn)));
> }
>
> why it is always giving output as 1 irrespective of the return type of
> function ??
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
*RAHUL KUMAR DUBEY*
*BTech-3rd  year *
*Computer Science &Engineering *
*Motilal Nehru National Institute Of Technology*
*Allahabad[211004],UP.*

-- 
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] Microsoft written test question

2012-09-02 Thread Rahul Kumar Patle
help to solve the following..
Question: Two of the nodes of a BST are swapped. Correct the BST (taken
from GeekforGeeks <http://www.geeksforgeeks.org/archives/23272> 2nd online
test 3rd question)



-- 
Thanks and Regards:
Rahul Kumar Patle<http://www.linkedin.com/profile/view?id=106245716&trk=tab_pro>
M.Tech, School of Information Technology
Indian Institute of Technology, Kharagpur-721302,
India<http://www.iitkgp.ac.in/>
Mobile No: +91-8798049298, +91-9424738542
Alternate Email: rahulkumarpa...@hotmail.com

-- 
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] explain the ouput

2012-09-01 Thread Rahul Kumar Dubey
since the function fn() is returning "bool"(here "true " which is of one
byte ) value whose size is 1 byte in C
so your output is showing  1 .

if you change the return type of your function ..say "int " it will print 4
byte (size of integer on your machine ).or say double it will print 8 byte
(size of double on your machine )



On Fri, Aug 31, 2012 at 9:25 PM, Rahul Kumar Patle <
patlerahulku...@gmail.com> wrote:

> #include
> #include
>
> bool fn(char *a , int b , char c)
> {
> return true;
> }
>
> int main()
> {
> int it = 2;
> char ct = 'c';
> char a[30];
> printf("%d\n",(sizeof(fn(a , it , ct;
> }
>
> in gcc 32 bit compiler the above code is always printing 1 even if i
> change the no of argument in fn()
> why?? pls explain..
>
>
>
> --
> Thanks and Regards:
> Rahul Kumar 
> Patle<http://www.linkedin.com/profile/view?id=106245716&trk=tab_pro>
> M.Tech, School of Information Technology
> Indian Institute of Technology, Kharagpur-721302, 
> India<http://www.iitkgp.ac.in/>
> Mobile No: +91-8798049298, +91-9424738542
> Alternate Email: rahulkumarpa...@hotmail.com
>
>  --
> 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.
>



-- 
*RAHUL KUMAR DUBEY*
*BTech-3rd  year *
*Computer Science &Engineering *
*Motilal Nehru National Institute Of Technology*
*Allahabad[211004],UP.*

-- 
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] explain the ouput

2012-09-01 Thread Rahul Kumar Patle
#include
#include

bool fn(char *a , int b , char c)
{
return true;
}

int main()
{
int it = 2;
char ct = 'c';
char a[30];
printf("%d\n",(sizeof(fn(a , it , ct;
}

in gcc 32 bit compiler the above code is always printing 1 even if i change
the no of argument in fn()
why?? pls explain..



-- 
Thanks and Regards:
Rahul Kumar Patle<http://www.linkedin.com/profile/view?id=106245716&trk=tab_pro>
M.Tech, School of Information Technology
Indian Institute of Technology, Kharagpur-721302,
India<http://www.iitkgp.ac.in/>
Mobile No: +91-8798049298, +91-9424738542
Alternate Email: rahulkumarpa...@hotmail.com

-- 
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] file handle

2012-08-18 Thread Rahul Kumar Dubey
It is because "fputc()" does not  writes to file directly . All contents
remain in buffer  and as soon as fclose()
is called for that file pointer, buffer content is flushed  to file . so
the file pointer which is closed  last
will overwrite finally  to the file  .
in this case fp2's buffer content will be flushed  last so it will be in
file.
on interchanging two statements "fp1's " buffer content will be flushed
last so it will be in file .

On Sat, Aug 18, 2012 at 5:09 PM, Ratan  wrote:

> #include
> main()
> {
> FILE *fp1,*fp2;
> fp1=fopen("one","w");
> fp2=fopen("one","w");
> fputc('A',fp1);
> fputc('B',fp2);
> fclose(fp1);   // stmt 1
> fclose(fp2);   // stmt 2
> }
>
>
>
> on interchanging the stmt 1 and stmt 2 content of file "one" is also
> changed. how does this happen ... as becauz i am just reversing
> the file closing handle that has nothing to do with writng to the file
> as the file has already been written by fputc() function 
> kindly clarify my confusion..
>
> --
> --
> Ratan | Final Year | Information Technology | NIT ALLAHABAD
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
*RAHUL KUMAR DUBEY*
*BTech-3rd  year *
*Computer Science &Engineering *
*Motilal Nehru National Institute Of Technology*
*Allahabad[211004],UP.*

-- 
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: Finding the repeated element

2012-07-23 Thread Rahul Kumar

what is the time complexity for the code ?

#include
using namespace std;

main()
{
int arr[] = { 2,3,4,9,2,7};
int *ptr1 = &arr[0];
int *ptr2 = &arr[1];
const int SIZE = sizeof arr / sizeof arr[0];
while(1)
{
if(*ptr1 == *ptr2)
{
cout << *ptr1 << endl;
return 0;
}
if( ptr1 == (arr+SIZE*(sizeof arr[0])))
ptr1=arr;
else
ptr1++;
if( ptr2 == &arr[SIZE-2])
ptr2=arr+1;
else if( ptr2 == &arr[SIZE-1])
ptr2=arr;
else 
ptr2+=2;
} 
return 1;
}

-- 
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/-/XIpYk-5n94wJ.
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:

2012-07-23 Thread Rahul Kumar
N+=3;

print N!-(N^2-1);


let me know if I am wrong


On Wednesday, 11 July 2012 16:42:38 UTC+5:30, wentworth miller wrote:
>
> hi ..
> can anybody tell the Nth term of the following series...
> 9 96 685 4992.
>

-- 
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/-/Fs9vaJ4g8bEJ.
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: Directi Interview Ques

2012-07-23 Thread Rahul Kumar

>
>
> http://www.ocf.berkeley.edu/~wwu/cgi-bin/yabb/YaBB.cgi?board=riddles_cs;action=display;num=1280183627
>  
>  

-- 
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/-/EyWqplydCDEJ.
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] Need links for Problem solving interview questions(non DS and algorithmic) probably with how to reach a solution

2012-07-11 Thread Rahul Kumar Patle
http://uva.onlinejudge.org/index.php
http://www.careercup.com/
http://www.codershunt.com/
http://www.cs.sunysb.edu/~skiena/392/programs/
https://www.interviewstreet.com/challenges/#
and in last
topcoder, codechef and stack overflow all three are best...

On Wed, Jul 11, 2012 at 10:37 AM, raghavan M
 wrote:
> hi
> I am looking for some web links where i can find problem solving questions
> and method that one can use to solve the problems that are asked in
> interviews.Please let me know if you came across one.
>
> Thanks
> Rag
>
> --
> 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.



-- 
Thanks and Regards:
Rahul Kumar Patle
M.Tech, School of Information Technology
Indian Institute of Technology, Kharagpur-721302, India
Mobile No: +91-8798049298, +91-9424738542

-- 
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] Datastructure and algorithms book

2012-06-05 Thread Rahul Kumar Patle
go though 4shared.com and esnips.com
huge online storage of shared files including pdf..

On Tue, Jun 5, 2012 at 12:32 PM, arun prakash  wrote:

> Can anyone pls mail me good datastrucutre and algo books..or any link to
> download those books..thanks in advance
>
> --
> 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/-/S3oFJ1RDgZ8J.
> 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.
>



-- 
Thanks and Regards:
Rahul Kumar Patle
M.Tech, School of Information Technology
Indian Institute of Technology, Kharagpur-721302, India
Mobile No: +91-8798049298, +91-9424738542
patlerahulku...@gmail.com
rahulkumarpa...@yahoo.com

-- 
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: MS: searching problem......help me out...

2012-06-04 Thread Rahul Kumar Patle
i think gene is correct in normal RAM it is impossible @abhishek you
are talking about parallel algorithms but till this extent is not possible
to implement in general computers..
@abhinav you was correct.. firsst we will have to make heap tree which is
impossible in log(n) time...

On Sun, Jun 3, 2012 at 11:23 PM, Gene  wrote:

> Finding a given element in an unsorted list in less than O(n) time
> (with a normal RAM model of computation) is easy to prove impossible.
>
> On Jun 3, 11:01 am, abhinav gupta  wrote:
> >   We have given a list 14 6 7 15 8 9 we have to find 15 in
> (log
> > n ) times.
> > --
> >
> > *Thanks and Regards,*
> >
> > Abhinav Kumar Gupta
> > **abhinav@gmail.com
>
> --
> 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.
>
>


-- 
Thanks and Regards:
Rahul Kumar Patle
M.Tech, School of Information Technology
Indian Institute of Technology, Kharagpur-721302, India
Mobile No: +91-8798049298, +91-9424738542
patlerahulku...@gmail.com
rahulkumarpa...@yahoo.com

-- 
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] MS: searching problem......help me out...

2012-06-03 Thread Rahul Kumar Patle
@abhinav: if you want to search just 15 in log(n) time then you can use the
concept of heap tree.. apply one round of heapification (not for all
elements but just one time it will be complete in log(n) times), and you
will need to swap elements but when you got element 15 you can stop..
although space complexity has increased... you will need one redundant
array to use heap operation so that finally you will have original array as
it is...

Thanks and Regards:
Rahul Kumar Patle


On Sun, Jun 3, 2012 at 8:31 PM, abhinav gupta  wrote:

>
>   We have given a list 14 6 7 15 8 9 we have to find 15 in
> (log n ) times.
> --
>
> *Thanks and Regards,*
>
> Abhinav Kumar Gupta
> **abhinav@gmail.com
>
>  --
> 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: Rectangle area

2012-06-03 Thread Rahul Kumar Patle
@payel : you have mentioned sum of square of diagonal of rectangle.. but as
you can see that 29 can't be the sum of square of diagonal of any
rectangle.. because for a rectangle both diagonal would be equal...
so sum shoud be 2 * diagonal^2...
please explain your que..

On Sun, Jun 3, 2012 at 1:28 AM, Dave  wrote:

> @Payel: Fermat's theorem on the sum of two squares applies. It says that
> an odd prime p can be written as the sum of two perfect squares if and only
> if p is congruent to 1 (mod 4). See
> http://en.wikipedia.org/wiki/Proofs_of_Fermat's_theorem_on_sums_of_two_squares.
>
>
> Thus, since 29 is congruent to 1 (mod 4), it can be written as the sum of
> two squares, as you have demonstrated. But, e.g., 7, 11, and 19 cannot be
> written as the sum of two perfect squares.
>
> Code follows:
>
> int PrimeIsSumOfTwoSquares(int p)
> {
> return (p & 3) == 1;
> }
>
> Dave
>
> On Saturday, June 2, 2012 2:31:43 PM UTC-5, payel roy wrote:
>
>> How do you verify whether sides of rectangular area are integer number If
>> square of diagonal of a rectangular area is prime?
>>
>> Ex : Let's say square of a diagonal is : 2
>>
>> 2 = 1^2 + 1^2 [where 1,1 are the sides of the rectangular area]
>>
>> square of a diagonal is : 29
>>
>> 29 = 5^2 + 2^2.
>>
>  --
> 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/-/wVxBh-kN-LoJ.
>
> 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.
>



-- 
Thanks and Regards:
Rahul Kumar Patle
M.Tech, School of Information Technology
Indian Institute of Technology, Kharagpur-721302, India
Mobile No: +91-8798049298, +91-9424738542
patlerahulku...@gmail.com
rahulkumarpa...@yahoo.com

-- 
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: Rectangle area

2012-06-03 Thread Rahul Kumar Patle
sorry got the que...
ignore my last reply..
thanks

On Sun, Jun 3, 2012 at 9:49 AM, Rahul Kumar Patle  wrote:

> @payel : you have mentioned sum of square of diagonal of rectangle.. but
> as you can see that 29 can't be the sum of square of diagonal of any
> rectangle.. because for a rectangle both diagonal would be equal...
> so sum shoud be 2 * diagonal^2...
> please explain your que..
>
> On Sun, Jun 3, 2012 at 1:28 AM, Dave  wrote:
>
>> @Payel: Fermat's theorem on the sum of two squares applies. It says that
>> an odd prime p can be written as the sum of two perfect squares if and only
>> if p is congruent to 1 (mod 4). See
>> http://en.wikipedia.org/wiki/Proofs_of_Fermat's_theorem_on_sums_of_two_squares.
>>
>>
>> Thus, since 29 is congruent to 1 (mod 4), it can be written as the sum of
>> two squares, as you have demonstrated. But, e.g., 7, 11, and 19 cannot be
>> written as the sum of two perfect squares.
>>
>> Code follows:
>>
>> int PrimeIsSumOfTwoSquares(int p)
>> {
>> return (p & 3) == 1;
>> }
>>
>> Dave
>>
>> On Saturday, June 2, 2012 2:31:43 PM UTC-5, payel roy wrote:
>>
>>> How do you verify whether sides of rectangular area are integer number
>>> If square of diagonal of a rectangular area is prime?
>>>
>>> Ex : Let's say square of a diagonal is : 2
>>>
>>> 2 = 1^2 + 1^2 [where 1,1 are the sides of the rectangular area]
>>>
>>> square of a diagonal is : 29
>>>
>>> 29 = 5^2 + 2^2.
>>>
>>  --
>> 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/-/wVxBh-kN-LoJ.
>>
>> 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.
>>
>
>
>
> --
> Thanks and Regards:
> Rahul Kumar Patle
> M.Tech, School of Information Technology
> Indian Institute of Technology, Kharagpur-721302, India
> Mobile No: +91-8798049298, +91-9424738542
> patlerahulku...@gmail.com
> rahulkumarpa...@yahoo.com
>



-- 
Thanks and Regards:
Rahul Kumar Patle
M.Tech, School of Information Technology
Indian Institute of Technology, Kharagpur-721302, India
Mobile No: +91-8798049298, +91-9424738542
patlerahulku...@gmail.com
rahulkumarpa...@yahoo.com

-- 
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] Required O(n) Algorithm

2012-04-18 Thread Rahul Kumar Patle
use counting sort..
it gives linear time complexity...
first step of counting sort is the same as you have mentioned in question...


On Wed, Apr 18, 2012 at 6:37 PM, VIHARRI  wrote:

> Can anybody give an O(n) algorithm for the following problem.
>
> Suppose if we have an array, I would like to construct an array with the
> elements which specify their corresponding position in the sorted array.
>
> For example if the array is { 0.87, 0.04, 0.95, 0.12, 0.36 } then the
> sorted array would be { 0.04, 0.12, 0.36, 0.87, 0.95 }.
> Then output array would be {3, 0, 4, 1, 2 }.
>
> Hope I'm clear...
>
> --
> 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/-/NH1P0aIguFEJ.
> 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.
>



-- 
Thanks and Regards:
Rahul Kumar Patle
M.Tech, School of Information Technology
Indian Institute of Technology, Kharagpur-721302, India
Mobile No: +91-8798049298, +91-9424738542
patlerahulku...@gmail.com
rahulkumarpa...@yahoo.com

-- 
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] decimal to binary..c code....

2012-01-29 Thread Rahul Kumar
ur subject is decimal to binary but in content u have written float to
decimal... I don't get it

On Sat, Jan 28, 2012 at 11:49 PM, rahul sharma wrote:

> it should be able to convert not only int but also float like 190.345 to
> decimalcan ny one suggest thnx 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.