Re: [algogeeks] Re: What would be the output for the following code fragment?

2012-06-07 Thread Prem Krishna Chettri
Does anybody know's Why the Value is like this So... Seems simple but when
I decoded it.. its very interesting... U all should look into this simple
question which can reveal some internal manipulation.

Good One !!!

BR,
Prem

On Thu, Jun 7, 2012 at 1:13 AM, Garima Mishra garima9...@gmail.com wrote:

 556 if the machine is little endian
 258 if machine is big endian

 On Jun 6, 11:57 pm, g4ur4v gauravyadav1...@gmail.com wrote:
  main()
  {
  int i=300;
  char *ptr = i;
  *++ptr=2;
  printf(%d,i);
 
 
 
 
 
 
 
  }

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



-- 
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: What would be the output for the following code fragment?

2012-06-07 Thread Abhishek Sharma
Is there any online compiler which gives output for both little/big endian
machines ?
or it is fine to convert value from one form to another using a small c
program ?

On Thu, Jun 7, 2012 at 1:13 AM, Garima Mishra garima9...@gmail.com wrote:

 556 if the machine is little endian
 258 if machine is big endian

 On Jun 6, 11:57 pm, g4ur4v gauravyadav1...@gmail.com wrote:
  main()
  {
  int i=300;
  char *ptr = i;
  *++ptr=2;
  printf(%d,i);
 
 
 
 
 
 
 
  }

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




-- 
Abhishek Sharma
Under-Graduate Student,
PEC University of Technology

-- 
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] If any one have algorithms for interviews by adnan aziz ebook... Please mail ...

2012-06-07 Thread rajesh singarapu
please share the link.

thanks
Rajesh


On Thu, Jun 7, 2012 at 1:44 AM, Prakhar Jain jprakha...@gmail.com wrote:
 @abhishek...Plz share the link here.Thanks

 --
 Prakhar Jain
 IIIT Allahabad
 B.Tech IT 3rd Year
 Mob no: +91 9454992196
 E-mail: rit2009...@iiita.ac.in
           jprakha...@gmail.com



 On Wed, Jun 6, 2012 at 5:32 PM, amrit harry dabbcomput...@gmail.com wrote:

 @abhishek pls send link me too... thanks.


 On Mon, Jun 4, 2012 at 5:54 PM, Abhishek Sharma abhi120...@gmail.com
 wrote:

 mailing you the link for same


 On Mon, Jun 4, 2012 at 1:31 AM, Dhaval Moliya moliyadha...@gmail.com
 wrote:

 If any one have algorithms for interviews by adnan aziz ebook... Please
 mail ...

 Thanks

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




 --
 Abhishek Sharma
 Under-Graduate Student,
 PEC University of Technology

 --
 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  Regards
 Amritpal singh

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


 --
 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: What would be the output for the following code fragment?

2012-06-07 Thread Abhishek Sharma
@prem, i don't get it.could you please elaborate the interesting part of
this solution ?


On Thu, Jun 7, 2012 at 11:39 AM, Abhishek Sharma abhi120...@gmail.comwrote:

 Is there any online compiler which gives output for both little/big endian
 machines ?
 or it is fine to convert value from one form to another using a small c
 program ?

 On Thu, Jun 7, 2012 at 1:13 AM, Garima Mishra garima9...@gmail.comwrote:

 556 if the machine is little endian
 258 if machine is big endian

 On Jun 6, 11:57 pm, g4ur4v gauravyadav1...@gmail.com wrote:
  main()
  {
  int i=300;
  char *ptr = i;
  *++ptr=2;
  printf(%d,i);
 
 
 
 
 
 
 
  }

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




 --
 Abhishek Sharma
 Under-Graduate Student,
 PEC University of Technology




-- 
Abhishek Sharma
Under-Graduate Student,
PEC University of Technology

-- 
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: What would be the output for the following code fragment?

2012-06-07 Thread Prem Krishna Chettri
Try decode how the final value of 556 or 228 end up there.. it alwayz
compiles to those values .. try finding how compiler end up to these
values..

On Thu, Jun 7, 2012 at 12:53 PM, Abhishek Sharma abhi120...@gmail.comwrote:

 @prem, i don't get it.could you please elaborate the interesting part of
 this solution ?


 On Thu, Jun 7, 2012 at 11:39 AM, Abhishek Sharma abhi120...@gmail.comwrote:

 Is there any online compiler which gives output for both little/big
 endian machines ?
 or it is fine to convert value from one form to another using a small c
 program ?

 On Thu, Jun 7, 2012 at 1:13 AM, Garima Mishra garima9...@gmail.comwrote:

 556 if the machine is little endian
 258 if machine is big endian

 On Jun 6, 11:57 pm, g4ur4v gauravyadav1...@gmail.com wrote:
  main()
  {
  int i=300;
  char *ptr = i;
  *++ptr=2;
  printf(%d,i);
 
 
 
 
 
 
 
  }

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




 --
 Abhishek Sharma
 Under-Graduate Student,
 PEC University of Technology




 --
 Abhishek Sharma
 Under-Graduate Student,
 PEC University of Technology

  --
 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: What would be the output for the following code fragment?

2012-06-07 Thread Abhishek Sharma
oh ,now i see. 300 = 000100101100
first 8 bits = 0001
last 8 bits = 00101100

in case of big-endian machine, when we assign 2 to next location, last 8
bits become 0010 (2 in decimal), first 8 bits remain same.
in case of little-endian machine, when we assign 2 to next location, last 8
bits become 0010 (2 in decimal), last 8 bits remain same.

Am i right ?

On Thu, Jun 7, 2012 at 12:53 PM, Abhishek Sharma abhi120...@gmail.comwrote:

 @prem, i don't get it.could you please elaborate the interesting part of
 this solution ?


 On Thu, Jun 7, 2012 at 11:39 AM, Abhishek Sharma abhi120...@gmail.comwrote:

 Is there any online compiler which gives output for both little/big
 endian machines ?
 or it is fine to convert value from one form to another using a small c
 program ?

 On Thu, Jun 7, 2012 at 1:13 AM, Garima Mishra garima9...@gmail.comwrote:

 556 if the machine is little endian
 258 if machine is big endian

 On Jun 6, 11:57 pm, g4ur4v gauravyadav1...@gmail.com wrote:
  main()
  {
  int i=300;
  char *ptr = i;
  *++ptr=2;
  printf(%d,i);
 
 
 
 
 
 
 
  }

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




 --
 Abhishek Sharma
 Under-Graduate Student,
 PEC University of Technology




 --
 Abhishek Sharma
 Under-Graduate Student,
 PEC University of Technology




-- 
Abhishek Sharma
Under-Graduate Student,
PEC University of Technology

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



Re: [algogeeks] What would be the output for the following code fragment?

2012-06-07 Thread atul anand
i=300 // binary = 0001 00101100
// in case of little Endien
it will be saved like this :-
0001
00101100
//suppose int = 2 bytes and char = 1 byte
char *ptr = i; // take care it *char *ptr* not *int* **ptr*so what
will happen

*ptr will be pointing to 00101100

*++ptr // now ptr is pointing to 0001 bcozz it is a char * hence it
will be increment by 1 byte
ptr=2 // now 0001 will be converted to 0010

so final value of i becomes 001000101100 = 556

now you can try for big endian 

On Thu, Jun 7, 2012 at 12:27 AM, g4ur4v gauravyadav1...@gmail.com wrote:



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

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



-- 
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: What would be the output for the following code fragment?

2012-06-07 Thread atul anand
@Abhishek : correct 

On Thu, Jun 7, 2012 at 1:03 PM, Abhishek Sharma abhi120...@gmail.comwrote:

 oh ,now i see. 300 = 000100101100
 first 8 bits = 0001
 last 8 bits = 00101100

 in case of big-endian machine, when we assign 2 to next location, last 8
 bits become 0010 (2 in decimal), first 8 bits remain same.
 in case of little-endian machine, when we assign 2 to next location, last
 8 bits become 0010 (2 in decimal), last 8 bits remain same.

 Am i right ?

 On Thu, Jun 7, 2012 at 12:53 PM, Abhishek Sharma abhi120...@gmail.comwrote:

 @prem, i don't get it.could you please elaborate the interesting part of
 this solution ?


 On Thu, Jun 7, 2012 at 11:39 AM, Abhishek Sharma abhi120...@gmail.comwrote:

 Is there any online compiler which gives output for both little/big
 endian machines ?
 or it is fine to convert value from one form to another using a small c
 program ?

 On Thu, Jun 7, 2012 at 1:13 AM, Garima Mishra garima9...@gmail.comwrote:

 556 if the machine is little endian
 258 if machine is big endian

 On Jun 6, 11:57 pm, g4ur4v gauravyadav1...@gmail.com wrote:
  main()
  {
  int i=300;
  char *ptr = i;
  *++ptr=2;
  printf(%d,i);
 
 
 
 
 
 
 
  }

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




 --
 Abhishek Sharma
 Under-Graduate Student,
 PEC University of Technology




 --
 Abhishek Sharma
 Under-Graduate Student,
 PEC University of Technology




 --
 Abhishek Sharma
 Under-Graduate Student,
 PEC University of Technology

  --
 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: What would be the output for the following code fragment?

2012-06-07 Thread ranju
#includestiod.h
int main(void)
{
  int i=0xff00ff11;
printf(%x\n, i);
i = htonl(i);
printf(%x\n, i);
}

I feel endianness better explained by this code

In networking domain , this has importance . This code segment is used when
a data is planning to send a big endian machine from a little endian
machine

Regards
RNP


On Thu, Jun 7, 2012 at 1:05 PM, atul anand atul.87fri...@gmail.com wrote:

 @Abhishek : correct 


 On Thu, Jun 7, 2012 at 1:03 PM, Abhishek Sharma abhi120...@gmail.comwrote:

 oh ,now i see. 300 = 000100101100
 first 8 bits = 0001
 last 8 bits = 00101100

 in case of big-endian machine, when we assign 2 to next location, last 8
 bits become 0010 (2 in decimal), first 8 bits remain same.
 in case of little-endian machine, when we assign 2 to next location, last
 8 bits become 0010 (2 in decimal), last 8 bits remain same.

 Am i right ?

 On Thu, Jun 7, 2012 at 12:53 PM, Abhishek Sharma abhi120...@gmail.comwrote:

 @prem, i don't get it.could you please elaborate the interesting part of
 this solution ?


 On Thu, Jun 7, 2012 at 11:39 AM, Abhishek Sharma 
 abhi120...@gmail.comwrote:

 Is there any online compiler which gives output for both little/big
 endian machines ?
 or it is fine to convert value from one form to another using a small c
 program ?

 On Thu, Jun 7, 2012 at 1:13 AM, Garima Mishra garima9...@gmail.comwrote:

 556 if the machine is little endian
 258 if machine is big endian

 On Jun 6, 11:57 pm, g4ur4v gauravyadav1...@gmail.com wrote:
  main()
  {
  int i=300;
  char *ptr = i;
  *++ptr=2;
  printf(%d,i);
 
 
 
 
 
 
 
  }

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




 --
 Abhishek Sharma
 Under-Graduate Student,
 PEC University of Technology




 --
 Abhishek Sharma
 Under-Graduate Student,
 PEC University of Technology




 --
 Abhishek Sharma
 Under-Graduate Student,
 PEC University of Technology

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


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


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



Re: [algogeeks] Re: What would be the output for the following code fragment?

2012-06-07 Thread Prem Krishna Chettri
Well Thanks Rajni but I don't see any BETTER EXPLANATION of endianess here
, as you are completely relying on library function like htonl() to provide
data manipulation for you. The use case mentioned is absolutely valid and
very promising although.

 Yeah both guys are on the spot .. :)

Br,
Prem

On Thu, Jun 7, 2012 at 1:12 PM, ranju ranjini...@gmail.com wrote:

 #includestiod.h
 int main(void)
 {
   int i=0xff00ff11;
 printf(%x\n, i);
 i = htonl(i);
 printf(%x\n, i);
 }

 I feel endianness better explained by this code

 In networking domain , this has importance . This code segment is used
 when a data is planning to send a big endian machine from a little endian
 machine

 Regards
 RNP


 On Thu, Jun 7, 2012 at 1:05 PM, atul anand atul.87fri...@gmail.comwrote:

 @Abhishek : correct 


 On Thu, Jun 7, 2012 at 1:03 PM, Abhishek Sharma abhi120...@gmail.comwrote:

 oh ,now i see. 300 = 000100101100
 first 8 bits = 0001
 last 8 bits = 00101100

 in case of big-endian machine, when we assign 2 to next location, last 8
 bits become 0010 (2 in decimal), first 8 bits remain same.
 in case of little-endian machine, when we assign 2 to next location,
 last 8 bits become 0010 (2 in decimal), last 8 bits remain same.

 Am i right ?

 On Thu, Jun 7, 2012 at 12:53 PM, Abhishek Sharma 
 abhi120...@gmail.comwrote:

 @prem, i don't get it.could you please elaborate the interesting part
 of this solution ?


 On Thu, Jun 7, 2012 at 11:39 AM, Abhishek Sharma 
 abhi120...@gmail.comwrote:

 Is there any online compiler which gives output for both little/big
 endian machines ?
 or it is fine to convert value from one form to another using a small
 c program ?

 On Thu, Jun 7, 2012 at 1:13 AM, Garima Mishra garima9...@gmail.comwrote:

 556 if the machine is little endian
 258 if machine is big endian

 On Jun 6, 11:57 pm, g4ur4v gauravyadav1...@gmail.com wrote:
  main()
  {
  int i=300;
  char *ptr = i;
  *++ptr=2;
  printf(%d,i);
 
 
 
 
 
 
 
  }

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




 --
 Abhishek Sharma
 Under-Graduate Student,
 PEC University of Technology




 --
 Abhishek Sharma
 Under-Graduate Student,
 PEC University of Technology




 --
 Abhishek Sharma
 Under-Graduate Student,
 PEC University of Technology

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


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


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


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



Re: [algogeeks] MS Q: how to test a driverless car?

2012-06-07 Thread Umer Farooq
What are the specs of the car. Can you please give the answer to the
following clarifying questions:

- How much distance is it suppose to travel without the driver?
- Is it suppose to run on smooth roads only or can it also run on roads
with jumps on it? On what type of road is the car most suitable?
- Is it suppose to slow down at speed brakers?
- Is it suppose to run on a two-way street as well or can it run on one way
roads only?
- Is it suppose to auto-park the car, or do we need to have a driver to
park the car?

On Wed, Jun 6, 2012 at 8:34 PM, Ashish Goel ashg...@gmail.com wrote:


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

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




-- 
Umer

-- 
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: What would be the output for the following code fragment?

2012-06-07 Thread s yogeesh
Same endian concepts comes into picture but some 1 explain why obj.ch[0] =
-1 not 255 ??

Code -

#include stdio.h

int main()
{
union s
   {
int i;
char ch[2];
   };


union s obj;
obj.i=255;
printf(%d %d %d\n,obj.i,obj.ch[0],obj.ch[1]);

}

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



Re: [algogeeks] What would be the output for the following code fragment?

2012-06-07 Thread s yogeesh
A: 556

-- 
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] If any one have algorithms for interviews by adnan aziz ebook... Please mail ...

2012-06-07 Thread BUBUN SHEKHAR
Guys is this book useful for cracking interviews??

On Mon, Jun 4, 2012 at 1:31 AM, Dhaval Moliya moliyadha...@gmail.comwrote:

 If any one have algorithms for interviews by adnan aziz ebook... Please
 mail ...
 Thanks

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.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] If any one have algorithms for interviews by adnan aziz ebook... Please mail ...

2012-06-07 Thread Abhishek Sharma
yes,it is helpful,but read it only if u have fully understood Introduction
to algorithms or if u have strong foundation of algorithms/data structures

On Thu, Jun 7, 2012 at 12:37 PM, BUBUN SHEKHAR dce.stu...@gmail.com wrote:

 Guys is this book useful for cracking interviews??

 On Mon, Jun 4, 2012 at 1:31 AM, Dhaval Moliya moliyadha...@gmail.comwrote:

 If any one have algorithms for interviews by adnan aziz ebook... Please
 mail ...
 Thanks

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.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.




-- 
Abhishek Sharma
Under-Graduate Student,
PEC University of Technology

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



Re: [algogeeks] What would be the output for the following code fragment?

2012-06-07 Thread Prem Krishna Chettri
Hahaha.. Xcellent question Dude.. People Who Know can easily explain.. So
for who don't here it is..

It has nothing to do with Endianess Mr.Yogesh.. Actually the bit patter
happens to be reside such that ob.ch[0] fills with all ones ..

Now as we knw the sign bit concept , here compilers goes mad thinking that
the first 1 of 8 consecutive 1's for 255 number as the Sign bit and does
the required operation of transforming to equivalent positive integer which
happen to be 1..

So as I said no endian here.. if u change the machine than U'll get other
-1 .i.e. ch[1]=-1 and again ch[0]=0..

BR,
Prem

On Thu, Jun 7, 2012 at 11:14 AM, s yogeesh yogees...@gmail.com wrote:

 A: 556

 --
 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] If any one have algorithms for interviews by adnan aziz ebook... Please mail ...

2012-06-07 Thread sengar.mahi
http://users.ece.utexas.edu/~adnan/afi-samples.pdf

is dis wat u al r lukin 4??

On Thu, Jun 7, 2012 at 3:01 PM, Abhishek Sharma abhi120...@gmail.comwrote:

 yes,it is helpful,but read it only if u have fully understood
 Introduction to algorithms or if u have strong foundation of
 algorithms/data structures


 On Thu, Jun 7, 2012 at 12:37 PM, BUBUN SHEKHAR dce.stu...@gmail.comwrote:

 Guys is this book useful for cracking interviews??

 On Mon, Jun 4, 2012 at 1:31 AM, Dhaval Moliya moliyadha...@gmail.comwrote:

 If any one have algorithms for interviews by adnan aziz ebook... Please
 mail ...
 Thanks

 --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.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.




 --
 Abhishek Sharma
 Under-Graduate Student,
 PEC University of Technology

  --
 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] If any one have algorithms for interviews by adnan aziz ebook... Please mail ...

2012-06-07 Thread Umer Farooq
cracking interviews is what Microsoft suggests. I'm not sure about the
other one.

On Thu, Jun 7, 2012 at 2:58 PM, sengar.mahi sengar.m...@gmail.com wrote:

 http://users.ece.utexas.edu/~adnan/afi-samples.pdf

 is dis wat u al r lukin 4??


 On Thu, Jun 7, 2012 at 3:01 PM, Abhishek Sharma abhi120...@gmail.comwrote:

 yes,it is helpful,but read it only if u have fully understood
 Introduction to algorithms or if u have strong foundation of
 algorithms/data structures


 On Thu, Jun 7, 2012 at 12:37 PM, BUBUN SHEKHAR dce.stu...@gmail.comwrote:

 Guys is this book useful for cracking interviews??

 On Mon, Jun 4, 2012 at 1:31 AM, Dhaval Moliya moliyadha...@gmail.comwrote:

 If any one have algorithms for interviews by adnan aziz ebook... Please
 mail ...
 Thanks

 --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.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.




 --
 Abhishek Sharma
 Under-Graduate Student,
 PEC University of Technology

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




-- 
Umer

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



Re: [algogeeks] What would be the output for the following code fragment?

2012-06-07 Thread s yogeesh
Sign bit.
well i forgot abt that. Bro still nly 1 bit s taken for sign so nly 1 '1' s
taken as determining sign to be negative. Still we have 7 1's in hand.
Wat abt that ?

-- 
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] If any one have algorithms for interviews by adnan aziz ebook... Please mail ...

2012-06-07 Thread nadeem khan
please share the link !!

On Thu, Jun 7, 2012 at 3:01 PM, Abhishek Sharma abhi120...@gmail.comwrote:

 yes,it is helpful,but read it only if u have fully understood
 Introduction to algorithms or if u have strong foundation of
 algorithms/data structures


 On Thu, Jun 7, 2012 at 12:37 PM, BUBUN SHEKHAR dce.stu...@gmail.comwrote:

 Guys is this book useful for cracking interviews??

 On Mon, Jun 4, 2012 at 1:31 AM, Dhaval Moliya moliyadha...@gmail.comwrote:

 If any one have algorithms for interviews by adnan aziz ebook... Please
 mail ...
 Thanks

 --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.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.




 --
 Abhishek Sharma
 Under-Graduate Student,
 PEC University of Technology

  --
 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] If any one have algorithms for interviews by adnan aziz ebook... Please mail ...

2012-06-07 Thread ashish kumar
please send me the download link @hi.ashish...@gmail.com.
..Thanks

On Thu, Jun 7, 2012 at 3:28 PM, sengar.mahi sengar.m...@gmail.com wrote:

 http://users.ece.utexas.edu/~adnan/afi-samples.pdf

 is dis wat u al r lukin 4??


 On Thu, Jun 7, 2012 at 3:01 PM, Abhishek Sharma abhi120...@gmail.comwrote:

 yes,it is helpful,but read it only if u have fully understood
 Introduction to algorithms or if u have strong foundation of
 algorithms/data structures


 On Thu, Jun 7, 2012 at 12:37 PM, BUBUN SHEKHAR dce.stu...@gmail.comwrote:

 Guys is this book useful for cracking interviews??

 On Mon, Jun 4, 2012 at 1:31 AM, Dhaval Moliya moliyadha...@gmail.comwrote:

 If any one have algorithms for interviews by adnan aziz ebook... Please
 mail ...
 Thanks

 --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.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.




 --
 Abhishek Sharma
 Under-Graduate Student,
 PEC University of Technology

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




-- 
Ashish Kumar
Bharat Electronics Ltd
Ghaziabad
+91 8527110885

-- 
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] Finding Anagrams

2012-06-07 Thread Decipher
First read a file of English words, one word per line, and then
  another file, with a set of (possibly space separated) letters,
  one set per line.
  For each set in file 2, write out all valid anagrams of those
  letters, from the words given in file 1.
  For instance, if the letters in some line in file 2 are
  Am Lady
  The answer for that line should be
  Am Lady : malady

-- 
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/-/7mY0S92WID4J.
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: What would be the output for the following code fragment?

2012-06-07 Thread atul anand
@yogeesh :
here is the reason why you are getting ch[0] = -1...bcozz
in your code.
#include stdio.h

 int main()
 {
 union s
{
 int i;
 char ch[2];  // this is signed
};
}

char ch[2] is declared as signed oneso when compiler see that ch[]
is declared as signed and it has all 1's entry ...so it interpret it
as -1.
now execute this code by making ch[] as unsigned  unsigned char[2];
you will get ch[0] as 255.

so in little endian machine ch[0] will be -1 or 255 (depending if
ch[] is signed or unsigned). or if ch[0] = 0 ..then it is big Endian
machine.


On 6/7/12, s yogeesh yogees...@gmail.com wrote:
 Same endian concepts comes into picture but some 1 explain why obj.ch[0] =
 -1 not 255 ??

 Code -

 #include stdio.h

 int main()
 {
 union s
{
 int i;
 char ch[2];
};


 union s obj;
 obj.i=255;
 printf(%d %d %d\n,obj.i,obj.ch[0],obj.ch[1]);

 }

 --
 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] Matrix Minimum Path Sum

2012-06-07 Thread KK
The problem u are referencing is different one.. here u can move in all 4 
directions!
On Wednesday, 6 June 2012 18:43:15 UTC+5:30, Dheeraj wrote:

 http://www.geeksforgeeks.org/archives/14943

 On Mon, Jun 4, 2012 at 7:57 PM, Decipher ankurseth...@gmail.com wrote:

 @Victor - Someone had asked this question from me !! He told me its from 
 Project Euler Q-83.
 @Hassan -  I think you are right. This question can be solved by 
 Dijikstra's algo, if we consider the matrix elements as weights.  


 On Monday, 4 June 2012 16:28:31 UTC+5:30, Hassan Monfared wrote:

 moving must be done in A* style

 On Mon, Jun 4, 2012 at 1:17 PM, atul anand atul.87fri...@gmail.comwrote:

 i dont think so dijistra will worh here..bcozz we cannot move 
 diagonally ...but according to matrix this path can be considered. 

 On Mon, Jun 4, 2012 at 1:39 PM, Hassan Monfared hmonfa...@gmail.comwrote:

 for non-negative values Dijkstra will solve the problem in ( O(N^2) )
 and Floyd-Warshal is the solution for negative cells. ( O(N^3) )

  

 On Mon, Jun 4, 2012 at 11:20 AM, atul anand 
 atul.87fri...@gmail.comwrote:

 this recurrence wont work..ignore 

 On Mon, Jun 4, 2012 at 8:55 AM, atul anand 
 atul.87fri...@gmail.comwrote:

 find cumulative sum row[0]
 find cumulative sum of col[0]

 after this following recurrence will solve the problem.

 start from mat[1][1]

 mat[i][j]=mat[i][j]+min( mat[i][j-1] , mat[i-1][j] )


 On Sun, Jun 3, 2012 at 7:30 PM, Decipher ankurseth...@gmail.comwrote:

 Q) In the 5 by 5 matrix below, the minimal path sum from the top 
 left to the bottom right, by moving left, right, up, and down, is 
 indicated 
 in bold red and is equal to 2297.

 
  *131*
  
 673
  
 *234*
  
 *103*
  
 *18*
   
 *201*
  
 *96*
  
 *342*
  
 965
  
 *150*
   
 630
  
 803
  
 746
  
 *422*
  
 *111*
   
 537
  
 699
  
 497
  
 *121*
  
 956
   
 805
  
 732
  
 524
  
 *37*
  
 *331*
   

   
 Write an algorithm to find the same. Also, write an algorithm if 
 the same matrix contains negative numbers (maybe negative cycle) and 
 compare the space and time complexity of both.
  
  -- 
 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/-/3JeyGNqWbs8Jhttps://groups.google.com/d/msg/algogeeks/-/3JeyGNqWbs8J
 .
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to 
 algogeeks+unsubscribe@**googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at http://groups.google.com/**
 group/algogeeks?hl=enhttp://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+unsubscribe@*
 *googlegroups.com algogeeks%2bunsubscr...@googlegroups.com.
 For more options, visit this group at http://groups.google.com/**
 group/algogeeks?hl=enhttp://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+unsubscribe@**
 googlegroups.com algogeeks%2bunsubscr...@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
 .


  -- 
 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+unsubscribe@**
 googlegroups.com algogeeks%2bunsubscr...@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.


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

 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.



On Wednesday, 6 June 2012 18:43:15 UTC+5:30, Dheeraj wrote:

 http://www.geeksforgeeks.org/archives/14943

 On Mon, Jun 4, 2012 at 7:57 PM, Decipher ankurseth...@gmail.com wrote:

 @Victor - Someone had asked this question from me !! He told me its from 
 Project Euler Q-83.
 @Hassan -  I think you are right. This question can be solved by 
 Dijikstra's algo, if we consider the matrix elements as weights.  


 On Monday, 4 June 2012 16:28:31 UTC+5:30, Hassan Monfared wrote:

 moving must 

[algogeeks] wrong output of C program

2012-06-07 Thread Mad Coder
The following is a simple C program which tries to multiply an integer by 5
using the bitwise operations. But it doesn't do so. Explain the reason for
the wrong behavior of the program.

  #include stdio.h
  #define PrintInt(expr) printf(%s : %d\n,#expr,(expr))
  *int* FiveTimes(*int* a)
  {
  *int* t;
  t *=* a**2 *+* a;
  *return* t;
  }

  *int* main()
  {
  *int* a *=* 1, b *=* 2,c *=* 3;
  PrintInt(FiveTimes(a));
  PrintInt(FiveTimes(b));
  PrintInt(FiveTimes(c));
  *return* 0;
  }

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



Re: [algogeeks] wrong output of C program

2012-06-07 Thread sengar.mahi
Good Question ,eagerly waiting for some good explanation to this one !!!

On Fri, Jun 8, 2012 at 5:46 AM, Mad Coder imamadco...@gmail.com wrote:

 The following is a simple C program which tries to multiply an integer by
 5 using the bitwise operations. But it doesn't do so. Explain the reason
 for the wrong behavior of the program.

   #include stdio.h
   #define PrintInt(expr) printf(%s : %d\n,#expr,(expr))
   *int* FiveTimes(*int* a)
   {
   *int* t;

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

   *return* t;
   }

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

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

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

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.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] wrong output of C program

2012-06-07 Thread Navin Kumar
one left shift is equivalent to multiplying with 2.Two left is equivalent
to multiplying with 2^2. and so on. so i left shift means multiplying with
2^i.

In your program you did left shift with 2.so it is equivalent to
multiplying with 4. so when input is 1 function will return 4*1+1=5. when
input is 2..output is 2*4+2=10.For 3 o/p is 3*4+3=15

On Fri, Jun 8, 2012 at 5:46 AM, Mad Coder imamadco...@gmail.com wrote:

 The following is a simple C program which tries to multiply an integer by
 5 using the bitwise operations. But it doesn't do so. Explain the reason
 for the wrong behavior of the program.

   #include stdio.h
   #define PrintInt(expr) printf(%s : %d\n,#expr,(expr))
   *int* FiveTimes(*int* a)
   {
   *int* t;

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

   *return* t;
   }

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

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

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

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.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: wrong output of C program

2012-06-07 Thread Navin Kumar
@Mahendra: for ur above code with t=(a2)+a o/p will be 5,10, 15 as i
explained above. without bracket answer will be 8 , 32 and 96 because +
precedence is higher than .

On Fri, Jun 8, 2012 at 7:31 AM, Mahendra Sengar sengar.m...@gmail.comwrote:

 Cracked it...i guess precedence of + is more than 
 so
 use t=(a2)+a;

 I checked, its giving proper output now !!!


 On Friday, June 8, 2012 5:46:09 AM UTC+5:30, algo lover wrote:

 The following is a simple C program which tries to multiply an integer by
 5 using the bitwise operations. But it doesn't do so. Explain the reason
 for the wrong behavior of the program.

   #include stdio.h
   #define PrintInt(expr) printf(%s : %d\n,#expr,(expr))
   *int* FiveTimes(*int* a)
   {
   *int* t;

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

   *return* t;
   }

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

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

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

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/algogeeks/-/7CNEyeGuUzEJ.

 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: MS question : string compression

2012-06-07 Thread Ashish Goel
The idea here is that there will be parts of the stream which actually
should not be compressed. For example abcdef as well as aa do not need any
compression. We need to compress only if 3 characters match because for
compressing two chars we will take up 2 chars so no compression benefit (:

So we need to keep a pos as a reference to say that here is the position in
the string i am processing now and do the compress(either verbatim or real
compress) when 3 same chars are found

eg

abcfdgffg: pos is 0 and at index 8 we get to know that there is a run,
so we should say 8-3+1=6 need to go verbatim so we write 6abcfdg and update
pos to index 6, and count to 1. Since now run flag is on, we continue till
we find a triplet mismatch(f==f but f!=g) which happens at g (index
12)implying an end to a run, therefore now count is 4, we would write 4f
implying 2+4 times of next char should be expanded. now again pos will be
set to 12, count to 0 and three same char check should re-begin. This will
for sure have 2 while loops and a bit comex, and i donot think this is what
the interviewer should expect one to code. Kindly note that if run is more
than max length, we need to tweak the writing part too.


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


On Thu, Jun 7, 2012 at 7:05 PM, Navin Gupta navin.nit...@gmail.com wrote:

 If abcdef is changed to a1b1c1d1e1f1,
 then we need to allocate memory dynamically.
 Because length is increased,I think this has no practical
 implementation.As abcdef  serves the same purpose.


 On Sunday, 3 June 2012 09:36:25 UTC+5:30, utsav sharma wrote:

 @ashish:-algo given in link wiil fail for abcdef

 @navin:- output of abcdef should be 1a1b1c1d1e1f

 On Sun, May 27, 2012 at 3:24 PM, Ashish Goel ashg...@gmail.com wrote:

 Will fail for the sing having say 257characters all same

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


 On Sat, May 26, 2012 at 12:26 PM, Navin Gupta navin.nit...@gmail.comwrote:

 This is called Run-Length-Encoding (RLE)  of a string.
 Its purpose is to save space.So in case of abcdef,I think the output
 needed is abcdef (1 is implicit).
 The added benefit is it makes the solution in-place.

 Approach:- (In-place and Linear Time)
 Start from the left of  string  and  PREVIOUS_CHAR = str[0]
 move forward till u match the CURRENT_CHAR with PREVIOUS_CHAR and keep
 count of PREVIOUS_CHAR
 At any point if (PREVIOUS_CHAR!=CURRENT_CHAR)
put the count of prev_char next to the start position of the
 previous character.

 Below is the working code :-
 void torle(char *str)
 {   int i=0,j=0,k=0,cnt=1;
 char cur_char=str[0],num[100];
 while(str[j+1])
 {
 cnt=1;
 while(str[j+1]==cur_char  str[j]!='\0'){
 j++;
 cnt++;
 }
 str[i++]=cur_char;
 if( cnt9 ){
 itoa(cnt,num);
 k=0;
 while(num[k]) str[i++]=num[k++];
 }
 else if( cnt1  cnt10 )
 str[i++]= cnt+'0';
 j++;
 if(str[j]) cur_char=str[j];
 }
 if(i!=0){
 if(cnt==1)
 str[i++]=cur_char;
 str[i]='\0';

 }
 }


 On Saturday, 26 May 2012 04:32:35 UTC+5:30, utsav sharma wrote:

 Implement a method to perform basic string compression using the
 counts of repeated characters.(inplace)

 eg:- input: aaabcdef
  output:3a5b1c1d1e1f.

 what should be my approach to this problem

 if i calculate the size of array required to store the output string
 and start from the last of the array then i wldn't get the right
 answer of above input case.

 and if start from front then i wldn't get the right answer of this
 input case
 eg:- input: abcdef
  output: 1a1b1c1d1e1f

  --
 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/-/4LxWHEUJuK8Jhttps://groups.google.com/d/msg/algogeeks/-/4LxWHEUJuK8J
 .

 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to algogeeks+unsubscribe@**
 googlegroups.com algogeeks%2bunsubscr...@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.


  --
 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+unsubscribe@**
 googlegroups.com algogeeks%2bunsubscr...@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.


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks 

[algogeeks] Re: Power(n^n)

2012-06-07 Thread Dave
@victor: But if K = 1000, then the largest N you have to deal with is 4, 
since 4^4  1000 but 5^5  1000. So your code looks like this:
 
int IsNtoNEqualK( int N, int K)
{
return (N==1)(K==1) || (N==2)(K==4) || (N==3){K==27) || 
(N==4)(K==256);
}
 

On Thursday, June 7, 2012 5:14:00 PM UTC-5, Victor Manuel Grijalva 
Altamirano wrote:

 Hi, everybody!!!
 I have the follow quest... 

 I have two numbers N and K,  i need to check that N^N = K.
 for example:
   if N=2 and K=4 , 2^2 = 4 so return true;
   if N=3 and K=26 ,   3^3 != 26 so return false
 But 0=N , K=1000 so N^N could be have 1000 digits.

 I program in C++, and i can use Bignum (array manipulation) + fast 
 power(binary power) but i want to know if exist a mathematical property.  


 -- 
 Victor Manuel Grijalva Altamirano
 Universidad Tecnologica de La Mixteca


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