[algogeeks] Job Openings at Adobe India

2014-01-07 Thread Lalit Sharma
Hi all,

*Adobe Hiring drive in Hyderabad, Noida and Bangalore*
Dates: 18th/25th Jan 2014
Profile: *Developer* (C++/Java).
Colleges Eligible: Premiere Institutes
(IITs/NITs/IISc/BITS/IIITs/NSIT/Thapar/DCE/Jadavpur etc.)
Experience Reqd : 1 – 5 Yrs experience in a good Product Company.


Please share your resumes with me.

-- 
Lalit Sharma | Member of Technical Staff | Adobe Systems ,Noida , India |
Contact No : +91-8130-321-181 .

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.


Re: [algogeeks] Address of var

2011-07-25 Thread LALIT SHARMA
yes...

On Mon, Jul 25, 2011 at 8:11 PM, Mani Bharathi manibharat...@gmail.comwrote:

 so ans is logical address right?

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

 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.




-- 
Lalit Kishore Sharma,

IIIT Allahabad,
7th Sem.
Contact No. - +919670057056 , +918957935169

-- 
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 plzz:output in file old.out

2011-07-22 Thread LALIT SHARMA
No, actually , a is defined as char ... and comparing char with EOF ,, makes
it go in infinte loop...as it never returns false.

correct me if i am wrong...

On Fri, Jul 22, 2011 at 11:41 PM, aditi garg aditi.garg.6...@gmail.comwrote:

 @shady. so in this case we shud use a!=-1 as the condition??


 On Fri, Jul 22, 2011 at 11:37 PM, shady sinv...@gmail.com wrote:

 you are scanning from stdin therefore it is not coming out of first for
 loop... because your terminating condition is for EOF, which is -1( scanf
 returns -1 ) at the end.


 On Fri, Jul 22, 2011 at 11:34 PM, shady sinv...@gmail.com wrote:

 well you didn't mention the question, directly posted the code with no
 head-tail... wait will answer, it is not coming out of first loop


 On Fri, Jul 22, 2011 at 11:26 PM, geek forgeek geekhori...@gmail.comwrote:

 @shady this is nt a joke..
 sorry if i am asking too stupid question
 i m getting an infinite loop here.
 not getting how?


 On Fri, Jul 22, 2011 at 10:40 AM, shady sinv...@gmail.com wrote:

 what kind of joke is this ?

 On Fri, Jul 22, 2011 at 11:02 PM, geek forgeek 
 geekhori...@gmail.comwrote:

 #includestdio.h
 main()
 {
 FILE *fp;
 char a;
 fp=fopen(old.out,w);
 if(fp==0)
 printf(File opening error);
 else
 {
 for(scanf(%c,a);a!=EOF;scanf(%c,a))
 fprintf(fp,%c,a);
 fclose(fp);
 fp=fopen(old.out,r);
 while(!feof(fp))
 putchar(getc(fp));
 }
 }

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




 --
 Aditi Garg
 Undergraduate Student
 Electronics  Communication Divison
 NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
 Sector 3, Dwarka
 New Delhi

 9718388816

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




-- 
Lalit Kishore Sharma,

IIIT Allahabad,
7th Sem.
Contact No. - +919670057056 , +918957935169

-- 
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 plzz:output in file old.out

2011-07-22 Thread LALIT SHARMA
@script kiddle

y u r rght ...i can smell too.. :P

On Fri, Jul 22, 2011 at 11:52 PM, varun pahwa varunpahwa2...@gmail.comwrote:

 For breaking the first loop after the input gives EOF.
 u can write it as.

 for(;~scanf(%c,a); )


 On Fri, Jul 22, 2011 at 11:43 PM, LALIT SHARMA lks.ru...@gmail.comwrote:

 No, actually , a is defined as char ... and comparing char with EOF ,,
 makes it go in infinte loop...as it never returns false.

 correct me if i am wrong...


 On Fri, Jul 22, 2011 at 11:41 PM, aditi garg 
 aditi.garg.6...@gmail.comwrote:

 @shady. so in this case we shud use a!=-1 as the condition??


 On Fri, Jul 22, 2011 at 11:37 PM, shady sinv...@gmail.com wrote:

 you are scanning from stdin therefore it is not coming out of first for
 loop... because your terminating condition is for EOF, which is -1( scanf
 returns -1 ) at the end.


 On Fri, Jul 22, 2011 at 11:34 PM, shady sinv...@gmail.com wrote:

 well you didn't mention the question, directly posted the code with no
 head-tail... wait will answer, it is not coming out of first loop


 On Fri, Jul 22, 2011 at 11:26 PM, geek forgeek 
 geekhori...@gmail.comwrote:

 @shady this is nt a joke..
 sorry if i am asking too stupid question
 i m getting an infinite loop here.
 not getting how?


 On Fri, Jul 22, 2011 at 10:40 AM, shady sinv...@gmail.com wrote:

 what kind of joke is this ?

 On Fri, Jul 22, 2011 at 11:02 PM, geek forgeek 
 geekhori...@gmail.com wrote:

 #includestdio.h
 main()
 {
 FILE *fp;
 char a;
 fp=fopen(old.out,w);
 if(fp==0)
 printf(File opening error);
 else
 {
 for(scanf(%c,a);a!=EOF;scanf(%c,a))
 fprintf(fp,%c,a);
 fclose(fp);
 fp=fopen(old.out,r);
 while(!feof(fp))
 putchar(getc(fp));
 }
 }

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




 --
 Aditi Garg
 Undergraduate Student
 Electronics  Communication Divison
 NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
 Sector 3, Dwarka
 New Delhi

 9718388816

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




 --
 Lalit Kishore Sharma,

 IIIT Allahabad,
 7th Sem.
 Contact No. - +919670057056 , +918957935169


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




 --
 Varun Pahwa
 B.Tech (IT)
 7th Sem.
 Indian Institute of Information Technology Allahabad.
 Ph : 09793899112
 Official Email :: rit2008...@iiita.ac.in
 Another Email :: varunpahwa.ii...@gmail.com

 People who fail to plan are those who plan to fail.

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




-- 
Lalit Kishore Sharma,

IIIT Allahabad,
7th Sem.
Contact No. - +919670057056 , +918957935169

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email

Re: [algogeeks] Re: how to optimally compute a matrix (nXn) to the power of k?

2011-07-19 Thread LALIT SHARMA
@rishabh  , thnX a lot :P

Plz explain further  :P

On Tue, Jul 19, 2011 at 10:15 PM, snehi jain snehijai...@gmail.com wrote:

 @Rishab  Thanks ..
 could you explain what your are doing in the function exp()..


 On Tue, Jul 19, 2011 at 9:47 PM, Rishabh Maurya poofiefoo...@gmail.comwrote:

 Yes its running fine at gcc 4.3.2  . And it might show warning in that
 case just change the name of the function exp().

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




-- 
Lalit Kishore Sharma,

IIIT Allahabad,
7th Sem.
Contact No. - +919670057056 , +918957935169

-- 
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] Find the missing number - Again given 4 billion integers

2011-07-18 Thread LALIT SHARMA
@ankit , can u xplain , the basics involved...m not able to get ur approach
.. :(

On Mon, Jul 18, 2011 at 11:06 AM, ankit sambyal ankitsamb...@gmail.comwrote:

 I also interpreted it the same way

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

2011-06-17 Thread LALIT SHARMA
There is very thin line of difference between semaphore and mutex,,

mutex are like binary semaphore ,,but the are concerned about
execution of any piece of code (critical section) ,where as a
semaphore is program construct which can be used to just hold a lock
on a set of resources .

As said by Ankit ,

thread/process which acquires a lock on mutex , is the only one to unlock it ..

On 6/17/11, ankit sambyal ankitsamb...@gmail.com wrote:
 Yes, even the threads of a single process cannot have access to each
 others mutex.
 Mutexes can be applied only to threads in a single process and do not
 work between processes as do semaphores.





 On Fri, Jun 17, 2011 at 5:40 AM, Akshata Sharma
 akshatasharm...@gmail.com wrote:
 When a thread locks a mutex only it can unlock it. Does this implies that
 even the threads of a single process cannot have access to each others
 mutex? I mean, if a thread A of process P has acquired a mutex, then only
 thread A can release it or a thread B of same process P can also release
 it?

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


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




-- 
Lalit Kishore Sharma,

IIIT Allahabad (Amethi Capmus),
6th Sem.

-- 
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: find output.

2011-06-16 Thread LALIT SHARMA
++*p++
==
++(*p++) ,
increments the value stored at p , and also increments p .



On Thu, Jun 16, 2011 at 1:10 PM, sunny agrawal sunny816.i...@gmail.comwrote:

 The place where strict constness is not enforced is with character
 array literals. You can say
 char* cp = howdy;
 and the compiler will accept it without complaint. This is
 technically an error because a character array literal (“howdy” in
 this case) is created by the compiler as a constant character array,
 and the result of the quoted character array is its starting address in
 memory. Modifying any of the characters in the array is a runtime
 error, although not all compilers enforce this correctly.
 So character array literals are actually constant character arrays. Of
 course, the compiler lets you get away with treating them as nonconst
 because there’s so much existing C code that relies on this.
 However, if you try to change the values in a character array literal,
 the behavior is undefined, although it will probably work on many
 machines.
 If you want to be able to modify the string, put it in an array:
 char cp[] = howdy;
 Since compilers often don’t enforce the difference you won’t be
 reminded to use this latter form and so the point becomes rather
 subtle.


 On Thu, Jun 16, 2011 at 12:59 PM, amit kumar amitthecoo...@gmail.comwrote:

 //kk
 //In place of

 char *p=hai friends,*p1;
 if i declare as
 char p[]=hai friends;
 char *p1;
 //then ??


 On Thu, Jun 16, 2011 at 8:16 AM, DIPANKAR DUTTA 
 dutta.dipanka...@gmail.com wrote:

 It's ok..

 char *p=hai friends...not correct

 bcz you did allocate memory for that string but assiging poiter to the
 base address.. from where gcc will get the bse address of that string when u
 r not actually allocate memory for it? thus it generate SIGSEG signal and
 give invalid memory address...ie. segmentation fault
 use malloc or use
 char p[]=..;






 On Thu, Jun 16, 2011 at 4:49 AM, DK divyekap...@gmail.com wrote:

 Gives me a SEGFAULT on gcc.
 Probably due to undefined behaviour.

 --
 DK

 http://twitter.com/divyekapoor
 http://www.divye.in

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

 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,
 --
 *DIPANKAR DUTTA*
 Visiting Research Scholar
 Dept of Computing,
 Macquarie University, Sydney, Australia
 ph.no-+61 2 98509079 ( Mon-Fri 10:15-7:00) Sydney time
 email: dipankar.du...@mq.edu.au



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




 --
 Sunny Aggrawal
 B-Tech IV year,CSI
 Indian Institute Of Technology,Roorkee


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




-- 
Lalit Kishore Sharma,

IIIT Allahabad (Amethi Capmus),
6th Sem.

-- 
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: find output.

2011-06-16 Thread LALIT SHARMA
@amit ,

Then explain me , in simpler words .. as i am not able to get it ...

On 6/17/11, Anand anandut2...@gmail.com wrote:
 Question:
 main()
 {
   char str[] = hai friends;
   char *p,*p1;
   p = str;
   p1=p;
   while(*p != 's')
   {
  ++*p++;

   }
   printf( %s,p1);
 }
 http://codepad.org/24hmvzP5

 Ans: ibj!gsjfoes



 On Thu, Jun 16, 2011 at 9:24 AM, sunny agrawal
 sunny816.i...@gmail.comwrote:

 @Arpit
 Thanks to Bruce Eckel :D


 On Thu, Jun 16, 2011 at 9:00 PM, Arpit Sood soodfi...@gmail.com wrote:

 @sunny thanks, that post did clear the confusion.


 On Thu, Jun 16, 2011 at 8:17 PM, Navneet Gupta
 navneetn...@gmail.comwrote:

 Then i would suggest you give the original reference in such cases for
 still better understanding :)
 Be it a book or a website.


 On Thu, Jun 16, 2011 at 8:13 PM, sunny agrawal
 sunny816.i...@gmail.comwrote:

 yes copy pasting the exact thing :)
 for better understanding :)

  On Thu, Jun 16, 2011 at 8:06 PM, Navneet Gupta
 navneetn...@gmail.comwrote:

 @Sunny, it is good that you follow Bruce Eckel, but copy pasting the
 exact thing? :)


 On Thu, Jun 16, 2011 at 7:34 PM, keyan karthi 
 keyankarthi1...@gmail.com wrote:

 hi friends is a string literal.. ie the string hi friends is
 stored somewhere and a pointer to its base address is returned to
 pointer p
 at the time of initialization... u can always make use of this
 pointer to
 traverse / access the literal but u cant alter tat in the code, u
 r
 trying to do a ++ operation, which throws a seg fault


 On Thu, Jun 16, 2011 at 2:16 PM, Kamakshii Aggarwal 
 kamakshi...@gmail.com wrote:

 i still din't get the solution..please explain..

 On 6/16/11, LALIT SHARMA lks.ru...@gmail.com wrote:
  ++*p++
  ==
  ++(*p++) ,
  increments the value stored at p , and also increments p .
 
 
 
  On Thu, Jun 16, 2011 at 1:10 PM, sunny agrawal
  sunny816.i...@gmail.comwrote:
 
  The place where strict constness is not enforced is with
  character
  array literals. You can say
  char* cp = howdy;
  and the compiler will accept it without complaint. This is
  technically an error because a character array literal (“howdy”
  in
  this case) is created by the compiler as a constant character
 array,
  and the result of the quoted character array is its starting
 address in
  memory. Modifying any of the characters in the array is a runtime
  error, although not all compilers enforce this correctly.
  So character array literals are actually constant character
 arrays. Of
  course, the compiler lets you get away with treating them as
 nonconst
  because there’s so much existing C code that relies on this.
  However, if you try to change the values in a character array
 literal,
  the behavior is undefined, although it will probably work on many
  machines.
  If you want to be able to modify the string, put it in an array:
  char cp[] = howdy;
  Since compilers often don’t enforce the difference you won’t be
  reminded to use this latter form and so the point becomes rather
  subtle.
 
 
  On Thu, Jun 16, 2011 at 12:59 PM, amit kumar
  amitthecoo...@gmail.comwrote:
 
  //kk
  //In place of
 
  char *p=hai friends,*p1;
  if i declare as
  char p[]=hai friends;
  char *p1;
  //then ??
 
 
  On Thu, Jun 16, 2011 at 8:16 AM, DIPANKAR DUTTA 
  dutta.dipanka...@gmail.com wrote:
 
  It's ok..
 
  char *p=hai friends...not correct
 
  bcz you did allocate memory for that string but assiging poiter
 to the
  base address.. from where gcc will get the bse address of that
 string
  when u
  r not actually allocate memory for it? thus it generate SIGSEG
 signal
  and
  give invalid memory address...ie. segmentation fault
  use malloc or use
  char p[]=..;
 
 
 
 
 
 
  On Thu, Jun 16, 2011 at 4:49 AM, DK divyekap...@gmail.com
 wrote:
 
  Gives me a SEGFAULT on gcc.
  Probably due to undefined behaviour.
 
  --
  DK
 
  http://twitter.com/divyekapoor
  http://www.divye.in
 
  --
  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/-/QVAjKMQiWvoJ.
 
  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,
  --
  *DIPANKAR DUTTA*
  Visiting Research Scholar
  Dept of Computing,
  Macquarie University, Sydney, Australia
  ph.no-+61 2 98509079 ( Mon-Fri 10:15-7:00) Sydney time
  email: dipankar.du...@mq.edu.au
 
 
 
   --
  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] Puzzle

2011-06-09 Thread LALIT SHARMA
 A helicopter drops two trains, each on a parachute, onto a straight
infinite railway line. There is an undefined distance between the two
trains. Each faces the same direction, and upon landing, the parachute
attached to each train falls to the ground next to the train and detaches.
Each train has a microchip that controls its motion. The chips are
identical. There is no way for the trains to know where they are. You need
to write the code in the chip to make the trains bump into each other. Each
line of code takes a single clock cycle to execute.*
You can use the following commands (and only these);*
MF - moves the train forward
MB - moves the train backward
IF (P) - conditional that's satisfied if the train is next to a parachute.
There is no then to this IF statement.
GOTO

-- 
Lalit Kishore Sharma,

IIIT Allahabad (Amethi Capmus),
6th Sem.

-- 
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] A simple C question

2011-06-05 Thread LALIT SHARMA
@nitish

I think using fork() it is not possible , to achieve , what you are
trying to do ..
Because , though address space is shared , but all the variable of
parent process can't be communicated through child process.as they
dont have a shared memory block.where we can place our semaphore.

It would be better if you use , a global variable and 2 threads and
try to show how semaphores work.

Correct Me , if I am wrong ..!!

On Fri, Jun 3, 2011 at 11:26 PM, nicks crazy.logic.k...@gmail.com wrote:
 @naveen.. thanks...i got it finally :)

 On Fri, Jun 3, 2011 at 10:35 AM, Naveen Kumar naveenkumarve...@gmail.com
 wrote:

 when we fork a new process, parent gets the PID of the chid as return
 value and child will get 0 as return value.
 Same address space is copied and both of them start executing this program
 in their own address space.
 In Modern OSes 99% of the time child comes first so child process is
 execute else part and parent will execute if place.



 On Fri, Jun 3, 2011 at 10:58 PM, nicks crazy.logic.k...@gmail.com wrote:

 i mean why both the if else statements are working by using fork ?

 On Fri, Jun 3, 2011 at 10:20 AM, Naveen Kumar
 naveenkumarve...@gmail.com wrote:

 Process don't share address space when forked.


 On Fri, Jun 3, 2011 at 10:40 PM, nitish goyal nitishgoy...@gmail.com
 wrote:

 @ Lalit
 You are right.

 that's why i am saying how i can use semaphores in the above example

 On Fri, Jun 3, 2011 at 10:37 PM, LALIT SHARMA lks.ru...@gmail.com
 wrote:

 While using fork(), child shares parent address space ,

 Correct me If I am wrong ..

 On Fri, Jun 3, 2011 at 10:28 PM, nitish goyal nitishgoy...@gmail.com
 wrote:
  Hi all,
 
  I am stuck with this code..Can anyone tell me how to implement
  semaphores in
  fork system call
  Code:
 
  #includestdio.h
 
  int signal(int *n);
  int wait(int *n);
 
 
  int main()
  {
      int n;
      n=0;
      if(fork())
      {
          printf(Hello);
          signal(n);
      }
      else
      {
          wait(n);
          printf(World);
      }
  }
  int signal(int *n)
  {
      (*n)++;
  }
  int wait(int *n)
  {
      while((*n)=0);
      (*n)--;
  }
 
  Since parent process and child process will be having different
  address
  spaces...so change of n in one address space will not be visible to
  other.so
  please tell me how to make n visible to both the processes
 
  On Fri, Jun 3, 2011 at 2:45 PM, Subhransu
  subhransu.panigr...@gmail.com
  wrote:
 
  Here you go in C code
   http://codepad.org/gk6AZj0T
 
 
  int main()
  {
  if(printf(hello)!=0) {
   printf(world);
  }
  else {
   printf(SCREWED ! ! !); }
 
  return 0;
  }
 
 
  Subhransu Panigrahi
 
  Mobile: +91-9840931538
  Email: subhransu.panigr...@gmail.com
 
 
  On Fri, Jun 3, 2011 at 1:57 PM, Naveen Kumar
  naveenkumarve...@gmail.com
  wrote:
 
  Hi Shachindra,
  I don't think letters will be jumbled because we a calling one api
  to
  output on console  tty's driver takes whole line and output it at
  once.
 
  On Fri, Jun 3, 2011 at 12:40 PM, Vishal Thanki
  vishaltha...@gmail.com
  wrote:
 
  @sachindra, @naveen,
  this was just a plain trick to execute if and else block. i
  agree
  with your concerns :)
 
  2011/6/3 Vιиodh vinodh...@gmail.com:
   @vishal:
   can u explain the fork()  solution??
  
   On Fri, Jun 3, 2011 at 12:16 PM, Shachindra A C
   sachindr...@gmail.com
   wrote:
  
   There can be some synchronisation problems with fork() right?
   say
   world
   might get printed first...or maybe the letters can get jumbled
   too...We
   cannot guarantee the order of execution unless we use
   semaphores.
  
   On Fri, Jun 3, 2011 at 12:14 PM, Naveen Kumar
   naveenkumarve...@gmail.com
   wrote:
  
   oh yes,
   gud one
  
   On Fri, Jun 3, 2011 at 12:12 PM, Vishal Thanki
   vishaltha...@gmail.com
   wrote:
  
   vishal@ubuntu:~/progs/c\ 12:11:53 PM $ cat fork.c
   #include stdio.h
   #include stdlib.h
  
   int main()
   {
          if (fork()) {
                  printf(hello );
          } else {
                  printf(world\n);
          }
          return 0;
   }
   vishal@ubuntu:~/progs/c\ 12:11:56 PM $ gcc fork.c
   vishal@ubuntu:~/progs/c\ 12:12:06 PM $ ./a.out
   hello world
  
  
   On Fri, Jun 3, 2011 at 12:09 PM, Naveen Kumar
   naveenkumarve...@gmail.com wrote:
Hi Vishal,
   
Can you show us how it be done with fork?
   
On Fri, Jun 3, 2011 at 12:02 PM, Vishal Thanki
vishaltha...@gmail.com
wrote:
   
can use fork() also..
   
On Fri, Jun 3, 2011 at 11:57 AM, anand karthik
anandkarthik@gmail.com wrote:
 (!printf(Hello))

 On Jun 3, 2011 11:52 AM, Arpit Mittal
 mrmittalro...@gmail.com
 wrote:
 Please help me in this question.

 What's the condition so that the following code
 prints both
 HelloWorld !

 if condition
 printf (Hello);
 else
 printf(World);




 --
 -Arpit Mittal
 6th Semester,
 Indian Institute

Re: [algogeeks] A simple C question

2011-06-03 Thread LALIT SHARMA
While using fork(), child shares parent address space ,

Correct me If I am wrong ..

On Fri, Jun 3, 2011 at 10:28 PM, nitish goyal nitishgoy...@gmail.com wrote:
 Hi all,

 I am stuck with this code..Can anyone tell me how to implement semaphores in
 fork system call
 Code:

 #includestdio.h

 int signal(int *n);
 int wait(int *n);


 int main()
 {
     int n;
     n=0;
     if(fork())
     {
         printf(Hello);
         signal(n);
     }
     else
     {
         wait(n);
         printf(World);
     }
 }
 int signal(int *n)
 {
     (*n)++;
 }
 int wait(int *n)
 {
     while((*n)=0);
     (*n)--;
 }

 Since parent process and child process will be having different address
 spaces...so change of n in one address space will not be visible to other.so
 please tell me how to make n visible to both the processes

 On Fri, Jun 3, 2011 at 2:45 PM, Subhransu subhransu.panigr...@gmail.com
 wrote:

 Here you go in C code
  http://codepad.org/gk6AZj0T


 int main()
 {
 if(printf(hello)!=0) {
  printf(world);
 }
 else {
  printf(SCREWED ! ! !); }

 return 0;
 }


 Subhransu Panigrahi

 Mobile: +91-9840931538
 Email: subhransu.panigr...@gmail.com


 On Fri, Jun 3, 2011 at 1:57 PM, Naveen Kumar naveenkumarve...@gmail.com
 wrote:

 Hi Shachindra,
 I don't think letters will be jumbled because we a calling one api to
 output on console  tty's driver takes whole line and output it at once.

 On Fri, Jun 3, 2011 at 12:40 PM, Vishal Thanki vishaltha...@gmail.com
 wrote:

 @sachindra, @naveen,
 this was just a plain trick to execute if and else block. i agree
 with your concerns :)

 2011/6/3 Vιиodh vinodh...@gmail.com:
  @vishal:
  can u explain the fork()  solution??
 
  On Fri, Jun 3, 2011 at 12:16 PM, Shachindra A C
  sachindr...@gmail.com
  wrote:
 
  There can be some synchronisation problems with fork() right? say
  world
  might get printed first...or maybe the letters can get jumbled
  too...We
  cannot guarantee the order of execution unless we use semaphores.
 
  On Fri, Jun 3, 2011 at 12:14 PM, Naveen Kumar
  naveenkumarve...@gmail.com
  wrote:
 
  oh yes,
  gud one
 
  On Fri, Jun 3, 2011 at 12:12 PM, Vishal Thanki
  vishaltha...@gmail.com
  wrote:
 
  vishal@ubuntu:~/progs/c\ 12:11:53 PM $ cat fork.c
  #include stdio.h
  #include stdlib.h
 
  int main()
  {
         if (fork()) {
                 printf(hello );
         } else {
                 printf(world\n);
         }
         return 0;
  }
  vishal@ubuntu:~/progs/c\ 12:11:56 PM $ gcc fork.c
  vishal@ubuntu:~/progs/c\ 12:12:06 PM $ ./a.out
  hello world
 
 
  On Fri, Jun 3, 2011 at 12:09 PM, Naveen Kumar
  naveenkumarve...@gmail.com wrote:
   Hi Vishal,
  
   Can you show us how it be done with fork?
  
   On Fri, Jun 3, 2011 at 12:02 PM, Vishal Thanki
   vishaltha...@gmail.com
   wrote:
  
   can use fork() also..
  
   On Fri, Jun 3, 2011 at 11:57 AM, anand karthik
   anandkarthik@gmail.com wrote:
(!printf(Hello))
   
On Jun 3, 2011 11:52 AM, Arpit Mittal
mrmittalro...@gmail.com
wrote:
Please help me in this question.
   
What's the condition so that the following code prints both
HelloWorld !
   
if condition
printf (Hello);
else
printf(World);
   
   
   
   
--
-Arpit Mittal
6th Semester,
Indian Institute of Information Technology,Allahabad
Email : arpitmittal.ii...@gmail.com
rit2008...@iiita.ac.in
Contact : +91-8853049787
   
Let every man be respected as an individual and no man
idolized.
   
--
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.
  
  
  
  
   --
   Cheers
   Naveen Kumar
  
   --
   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, 

Re: [algogeeks] remove duplicate chars in a string without using extra memory

2011-06-03 Thread LALIT SHARMA
@Johari ,

You have correctly mapped but the question demanded , to remove all
repetition , though the string is still the same as it was given in input .

On Fri, Jun 3, 2011 at 7:00 PM, Kunal Patil kp101...@gmail.com wrote:

 If you are not going to allow  extra space, you have to compromise on time
 complexity..[?]
 If you dont have your string already stored in a trie/hashmap usage of it
 requires additional buffer.
 Simple solution would be:
 Sort given string using in-place sorting algorithm and then removal of
 duplicate characters becomes O(n).
 Total time complexity - O(nlogn) where n -- number of characters in the
 input string.


 On Thu, Jun 2, 2011 at 11:17 PM, Aakash Johari aakashj@gmail.comwrote:

 It was given that one or two extra variables are allowed. So I used a
 variable instead for mapping.
 It is simply mapping of each character in alphabet to a bit in the
 variable.


 On Thu, Jun 2, 2011 at 7:10 AM, Ashish Goel ashg...@gmail.com wrote:

 using bitmap, but  extra memory not allowed?


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


 On Thu, Jun 2, 2011 at 7:38 PM, Ashish Goel ashg...@gmail.com wrote:

 what is the logic, kindly explain
 Best Regards
 Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652



 On Sat, May 28, 2011 at 12:23 PM, Aakash Johari 
 aakashj@gmail.comwrote:

 Following code works for [A-Za-z], can be extended for whole
 character-set :

 #include stdio.h

 int main()
 {
 unsigned long long int a = 0;
 char str[50];
 int i;

 scanf (%s, str);

 for ( i = 0; str[i]; i++ ) {
 if ( str[i] = 'A'  str[i] = 'Z' ) {
 if ( (a  (1ULL  (str[i] - 'A'))) == 0 ) {
 a |= (1ULL  (str[i] - 'A'));
 putchar (str[i]);
 }
 } else if ( str[i] = 'a'  str[i] = 'z' ) {
 if ( (a  (1ULL  (str[i] - 'a' + 26))) == 0 ) {
 a |= (1ULL  (str[i] - 'a' + 26));
 putchar(str[i]);
 }
 }
 }

 return 0;
 }



 On Fri, May 27, 2011 at 11:15 PM, saurabh singh 
 saurabh.n...@gmail.com wrote:

 string getStringWithoutDuplicateChars(string input)
 {

 create_empty_trie_ds (say trie)

 integer count = 0;

 for_each_char_in_string (say ch)
 {

 if(trie-contains(ch)) //if ch not there in ds then add it and
 return false otherwise return true
 {
  input.remove(count)
  }

count++
 }

 return input
 }

 On Sat, May 28, 2011 at 11:32 AM, Rajeev Kumar 
 rajeevprasa...@gmail.com wrote:

 Design an algorithm and write code to remove the duplicate characters
 in a string without using any additional buffer.
  NOTE: One or two additional variables are fine.
  An extra copy of the array is not.


 --
 Thank You
 Rajeev Kumar

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

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




 --
 -Aakash Johari
 (IIIT 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.



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




 --
 -Aakash Johari
 (IIIT 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.


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

Re: [algogeeks] Odd Even Sort array

2011-05-27 Thread LALIT SHARMA
It will give correct answer ,
but instead of doing manipulation after taking input.
as it would take some O(n) time. if n would be large , we would incur
this extra cost .

we should change the termination condition of merge-sort function and
modify the merge function of merge sort ..to reach our objective .

correct me , if i am wrong ...

On Sat, May 28, 2011 at 1:40 AM, Piyush Sinha ecstasy.piy...@gmail.com wrote:
 main()
 {
       int a[100];
       int i,j,N;
       printf(enter the number of elements: );
       scanf(%d,N);
       for(i=0;iN;i++)
         scanf(%d,a[i]);
       if(N%2) j = N/2+1;
       else j = N/2;
       i =1;
       while(jN)
       {
         swap(a[i],a[j]);
         i+=2;
         j+=2;
       }
       if(N%2){
              inv_mergesort(a,0,N/2);//sort the array in descending order
              mergesort(a,N/2+1,N-1);
       }
       else{
            inv_mergesort(a,0,N/2-1);//sort the array in descending order
             mergesort(a,N/2,N-1);
       }

       for(i=0;iN;i++)
          printf(%d,a[i]);
 }

 I hope the code doesn't contain any bugs...:P :P

 On 5/28/11, srajan dongre srajan.don...@gmail.com wrote:
 wat about insertion sort (with some limited conditions obviously )  ??

 On Sat, May 28, 2011 at 12:56 AM, Piyush Sinha
 ecstasy.piy...@gmail.comwrote:

 will it be given that the number of elements is always even??

 On 5/28/11, ross jagadish1...@gmail.com wrote:
  Hi all,
 
  Sort all elements in odd indices of an array in ascending order and
  even indices in descending order.
  Finally, rearrange so that all even indexed elements come first.
 
  eg:
 
  input – 7 2 6 4 8 3 1
 
  even indexed : 7 6 8 1 = sort 8 7 6 1
  odd indexed: 2 4 3 = sort 2 3 4
 
  output – 8 7 6 1 2 3 4
 
  What could be the best algo to solve it?
  Is it possible to arrive at the output using only O(1) extra space?
 
  --
  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.
 
 


 --
 *Piyush Sinha*
 *IIIT, Allahabad*
 *+91-8792136657*
 *+91-7483122727*
 *https://www.facebook.com/profile.php?id=10655377926 *

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




 --
 --

 Srajan Dongre
 ||nd year  CSI (dual degree)
 Indian Institute of Technology , Roorkee
 Uttrakhand , India
 pin code--247667

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




 --
 *Piyush Sinha*
 *IIIT, Allahabad*
 *+91-8792136657*
 *+91-7483122727*
 *https://www.facebook.com/profile.php?id=10655377926 *

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





-- 
Lalit Kishore Sharma,
IIIT Allahabad (Amethi Capmus),
6th Sem.

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

2011-04-21 Thread LALIT SHARMA
Please mail me 2 ,

my id is lks.ru...@gmail.com

thnX in Advance ..

On Thu, Apr 21, 2011 at 12:45 PM, kamlesh yadav kamleshlu2...@gmail.com wrote:
 can anyone give me  list of books  like ( cracking the coding
 interview )
  for placement preparation

 thanks in advance.

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





-- 
Lalit Kishore Sharma,
IIIT Allahabad (Amethi Capmus),
6th Sem.

-- 
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] [brain teaser ] Math Prime number puzzle 15april

2011-04-15 Thread LALIT SHARMA
9+26 = 53  lolzz...

On Fri, Apr 15, 2011 at 3:20 PM, hary rathor harry.rat...@gmail.com wrote:

  it true because 2*2+26 =30 which is not prime number
 3*3+26=53 which is prime number

 these both statement contradicting that given expression is not suitable
 for all prime number

 so not true

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




-- 
Lalit Kishore Sharma,

IIIT Allahabad (Amethi Capmus),
6th Sem.

-- 
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: Need help on Divide and Conquer Algorithm

2011-04-14 Thread LALIT SHARMA
Yes , I also need the same...Thanks for the help .

On Fri, Apr 15, 2011 at 12:52 AM, vishwakarma
vishwakarma.ii...@gmail.comwrote:

 I can post solution of this complexity if you want !!

 On Apr 15, 12:19 am, vishwakarma vishwakarma.ii...@gmail.com wrote:
  complexity : O(n) + O(nlogn)
 
  Sweety wrote:
   Question :Let A[1..n] be an array of integers. Design an efficient
   divide and conquer algorithm to determine if A contains a majority
   element, i.e an element appears more than n/2 times in A. What is the
   time complexity of your algorithm?
 
   Answer:
   a[1..n] is an array
   int majorityElement(int a[], int first, int last)
   {
If (first = = last)
   {
   return a[first]; // Array has one element and its count = 1
   and it is major element
}
   mid= (first+last)/2;
 
  (majorL,countL)= majorityElement(a,first,mid);
  (majorR,countR)= majorityElement(a,mid
   +1,last);
   n = total elements in an array;
 If(majorL==majorR)
   return(countL+countR);
else
{
  If(countLcountR)
   return(majorL,countL);
 elseif(countL countR)
   return(majorR,countR);
 else
  return(majorL,majorR);
 }
if(countLn/2)
   temp1=majorL;
 if(countRn/2)
temp2=majorR;
 
  If(temp1 = = temp2)
 return temp1;
 elseif(countLcountR)
return temp1;
else (countRcountL)
   return temp2;
   else
 return -1;
   }
 
   int main()
   {
 int a[8] = {2,3,2,2,4,2,2,2};
 int first =1;
 int last=8;   //change the value of last when the array
   increases or decreases in size
 int x = majorityElement(a,first,last);
 if(x= = -1)
   printf(“No Majority Element”)
 else
 Majority element = x;
}

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




-- 
Lalit Kishore Sharma,

IIIT Allahabad (Amethi Capmus),
6th Sem.

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

2011-04-03 Thread LALIT SHARMA
:P

On Sun, Apr 3, 2011 at 9:46 AM, Dr. Deepak Garg dr.gar...@gmail.com wrote:

 Beta, puchna hi tha, to mujhse puchte!
 Anyways, you will get the solution in tomorrow's lecture @1pm.
 I have gone through your profile. See me in my cabin after the class.
 Make sure that you attend tomorrow's lecture. For now, study dynamic
 programming..

 On Apr 3, 6:03 pm, SANDEEP AAMIN sandeep.aa...@gmail.com wrote:
  hey guys please help me to solve this
 
  QUESTION :  input a number C , an output all of the ways that a group
  of ascending positive numbers can be summed to give C. for e.g if
  C=6,the output should be
  1+2+3
  1+5
  2+4
  [solve using dynamic programming]
 
  please tell me about this..

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




-- 
Lalit Kishore Sharma,

IIIT Allahabad (Amethi Capmus),
6th Sem.

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

2011-01-22 Thread LALIT SHARMA
*case 1 :*
#include stdio.h
#include math.h
#include conio.h
int main()
{
float i = 2.5;
printf (%f %f\n, floor(i), ceil(i));
getch();
return 0;
}
*ans : 2.00 3.00*

*case 2: *
#include stdio.h
#include math.h
#include conio.h
int main()
{
float i = 2.5;
printf (%d %f\n, floor(i), ceil(i));
getch();
return 0;
}

*ans: 0 0.00*
*
case 3 :*

#include stdio.h
#include math.h
#include conio.h
int main()
{
float i = 2.5;
printf (%f %d\n, floor(i), ceil(i));
getch();
return 0;
}

*ans: 2.00 0*

*case 4:*
#include stdio.h
#include math.h
#include conio.h
int main()
{
float i = 2.5;
printf (%d %d\n, floor(i), ceil(i));
getch();
return 0;
}

*ans : 0 1073741824*

case 1 : nothing new .
case 2 and case 3 : it seems to me... as ceil and floor returns double
values 64 bit , so when converting into int , LSB of 64 bits is given to 32
bits , so 0 is produced as answer..
case 4: i don have any idea.

may be i am wrong regarding case 2 and 3  but confident about case 1 , lol
;)
help me regarding this.

-- 
Lalit Kishore Sharma,

IIIT Allahabad (Amethi Capmus),
6th Sem.

-- 
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] OS galvin sol..

2011-01-21 Thread LALIT SHARMA
My Pleasure !!
On Fri, Jan 21, 2011 at 11:22 PM, Anand anandut2...@gmail.com wrote:

 It's really good. Thanks a lot


 On Fri, Jan 21, 2011 at 8:24 AM, Sreeprasad Govindankutty 
 sreeprasad...@gmail.com wrote:

 Thanks so much


 On Wed, Jan 19, 2011 at 4:20 AM, jayapriya surendran priya7...@gmail.com
  wrote:

 wow..thank you so much


 On Wed, Jan 19, 2011 at 2:08 PM, LALIT SHARMA lks.ru...@gmail.comwrote:



 --
 Lalit Kishore Sharma,

 IIIT Allahabad (Amethi Capmus),
 6th Sem.

 --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


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




 --
 Thanks and many regards,
 Sreeprasad Govindankutty


  --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


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




-- 
Lalit Kishore Sharma,

IIIT Allahabad (Amethi Capmus),
6th Sem.

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

2011-01-08 Thread LALIT SHARMA
@bittu

I would like to discuss one thing regarding your approach ,

How you managed to put forward your 1st statement that is of Synchronization
.

On Fri, Jan 7, 2011 at 1:18 PM, Pedro Rezende web...@gmail.com wrote:

 Hi all!
 And what could be the best way to test / debug issues like these?

 2011/1/7 vaibhav agrawal agrvaib...@gmail.com

 @Douglas, nicely put!!!


 On Fri, Jan 7, 2011 at 8:37 PM, Douglas Diniz dgdi...@gmail.com wrote:

 Some examples, supposing you do always the same thing:

 1-) You have a program that use some random number, and based on the
 number the program do different things, and this different things
 crash the program at different places.

 2-) you have a program that connect with a external server. Depending
 on the links status you could crash in different places.

 3-) You have a program that talk with another program (or external
 server) through a protocol, and the protocol could do different things
 even if you do the same thing several times.

 4-) Your program has timeouts that could expire based on the system
 usage, crashing the program in different places.

 5-) Your program read some system variable and do different things.

 6-) etc

 On Fri, Jan 7, 2011 at 12:09 PM, juver++ avpostni...@gmail.com wrote:
  The application is single threaded :)
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algoge...@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 

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


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


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




-- 
Lalit Kishore Sharma

IIIT Allahabad (Amethi Capmus)
6th Sem

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



Re: [algogeeks] Re: Adobe - Coding

2011-01-08 Thread LALIT SHARMA
@bittu ,

I think RLE , would be of no use ;
as

inp:AAABBRRGH
out :3A2B2R1G1H

so to reach the top 5 counts , there will be of no use .

as stated earlier by others ,
HASH TABLE will be the one of best solution for this .
maintain hash table in O(n) and then sort it .for top 5 counts.

Please mend me if I am wrong somewhere as I am also in a learning phase.

On Sat, Jan 8, 2011 at 7:08 AM, bittu shashank7andr...@gmail.com wrote:

 RLE run length encoding is another solution  because counting sort
 eats space whilw with RLE we can do it in

 time complexity O(n)
 Space Complexity O(1)

 Correct me if i am wrong ...i m talking about possibility not
 exactness.

 Regards
 Shashank

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




-- 
Lalit Kishore Sharma

IIIT Allahabad (Amethi Capmus)
5th Sem

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



Re: [algogeeks] Re: switch vs if -- which is faster

2010-11-22 Thread LALIT SHARMA
I was asking you for some examples ..as i dont have any knowledge
regarding this assembly code and how to study it  .

there was no intention of mine to challenge you or disregard you .

On 11/22/10, Gene gene.ress...@gmail.com wrote:
 I'm not sure what you mean by support.

 If you mean examples, gcc uses several of the techniques I mentioned.
 Write some switch statements with different distributions of cases.
 Compile with -S, and inspect the assembly code.  If you don't now how
 to do that, take the time to learn.

 If you mean justify the truth of what I wrote, it's observation while
 studying and teaching courses about compilers on and off for over 15
 years and building some myself.

 BTW, u c I won't ansr mor ??s if wrds arnt spld out...


 On Nov 22, 12:28 am, LALIT SHARMA lks.ru...@gmail.com wrote:
 @dipankar

 Can u tell us , sumthng more in support of ur ans...??

 On Mon, Nov 22, 2010 at 10:40 AM, DIPANKAR DUTTA

 dutta.dipanka...@gmail.com wrote:
  both are same .. because any good optimizing compiler generate same
  assembly
  code of them...

  On Mon, Nov 22, 2010 at 9:38 AM, Gene gene.ress...@gmail.com wrote:

  A good compiler will never generate a switch that is slower than an
  if...else chain.  It will analyze the switch cases and pick one of
  several options for code generation.  These may include cascaded
  conditional jumps (like if...else code), simple jump tables, segmented
  jump tables (cascaded jumps pick one of several jump tables because a
  single table would be too big), binary searches in a sorted table of
  case values, and perfect hash functions.  These are the ones I've
  seen.  There may be others.

  On Nov 21, 8:15 am, shiva shivanand.kadwad...@gmail.com wrote:
   As per my understanding it is compiler depending thing..

   what i feel is switch need to evaluate the expression only once but
   if
   else if need to evaluate the expression more than once(what if
   expression stored in variable and then compare...)

   Does any one please comment difference in speed of switch and if
   depending on how it is implemented...

   I heard switch uses jump table for its operation.

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

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

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

 --
 Lalit Kishore Sharma
 IIIT Allahabad (Amethi Capmus)
 5th Sem

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




-- 
Lalit Kishore Sharma

IIIT Allahabad (Amethi Capmus)
5th Sem

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



Re: [algogeeks] Re: switch vs if -- which is faster

2010-11-21 Thread LALIT SHARMA
@dipankar

Can u tell us , sumthng more in support of ur ans...??


On Mon, Nov 22, 2010 at 10:40 AM, DIPANKAR DUTTA
dutta.dipanka...@gmail.com wrote:
 both are same .. because any good optimizing compiler generate same assembly
 code of them...

 On Mon, Nov 22, 2010 at 9:38 AM, Gene gene.ress...@gmail.com wrote:

 A good compiler will never generate a switch that is slower than an
 if...else chain.  They will analyze the switch cases and pick one of
 several options for code generation.  These may include cascaded
 conditional jumps (like if...else code), simple jump tables, segmented
 jump tables (cascaded jumps pick one of several jump tables because a
 single table would be too big), binary searches in a sorted table of
 case values, and perfect hash functions.  These are the ones I've
 seen.  There may be others.


 On Nov 21, 8:15 am, shiva shivanand.kadwad...@gmail.com wrote:
  As per my understanding it is compiler depending thing..
 
  what i feel is switch need to evaluate the expression only once but if
  else if need to evaluate the expression more than once(what if
  expression stored in variable and then compare...)
 
  Does any one please comment difference in speed of switch and if
  depending on how it is implemented...
 
  I heard switch uses jump table for its operation.

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




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

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




-- 
Lalit Kishore Sharma
IIIT Allahabad (Amethi Capmus)
5th Sem

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



[algogeeks] Happy Diwali ..

2010-11-05 Thread LALIT SHARMA
Wish u all a happy diwali ...
-- 
Lalit Kishore Sharma
IIIT Allahabad (Amethi Capmus)
5th Sem

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



Re: [algogeeks] compute all subset in given array

2010-11-02 Thread LALIT SHARMA
Have a look at this code 

#include iostream
#include cmath
using namespace std ;

int main() {
int n ;
cin  n;
int a[n] ;
for(int i=0;in;i++)
cin  a[i] ;
for(int i=1;i=pow(2,n);i++){
for(int j=0;jn;j++){
if( i  (1  j)) {
cout  J::  j  ;
//cout  lks  ( i  (1  j)) endl ;
cout  a[j]  ;
}
}
cout  \n;
}
return 0 ;
}




On Mon, Nov 1, 2010 at 11:19 PM, RIDER mohit...@gmail.com wrote:

 given an array how to find number of set which results to give a
 particular sum ( consider continues, noncontinue) both.

 example [5, 5, 10, 2, 3] should return 4 (5 + 10, 5 + 10, 5 + 5 + 2 +
 3, 10 + 2 + 3

 can we do any logical  thing to computer sum if range is known??

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




-- 
Lalit Kishore Sharma
IIIT Allahabad (Amethi Capmus)
5th Sem

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