Re: [algogeeks] Re: Novell - Puzzle

2011-07-31 Thread Shubham Maheshwari
for the cows ques ... you all are forgetting to add the orginal starting cow
...
thus the answer should be *233*

On Sun, Jul 31, 2011 at 1:30 PM, Nikhil Gupta nikhilgupta2...@gmail.comwrote:

 Oops. My bad. Rabbits produce every month too.
 I overlooked that.

 On Sun, Jul 31, 2011 at 1:24 PM, Tushar Bindal tushicom...@gmail.comwrote:

 Suppose that our rabbits never die and that the female always
 produces one new pair (one male, one female) *every month from the
 second month on
 *
 @Priyanka
 You have answer 288
 I added 178 to it because I got the answer that 89 females would have
 given birth in the last month.
 Pls clarify.
 Are you taking one month less or am I taking 1 more?

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




 --
 Nikhil Gupta
 Senior Co-ordinator, Publicity
 CSI, NSIT Students' Branch
 NSIT, New Delhi, India

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


-- 
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] 32 bit?

2011-07-31 Thread Shubham Maheshwari
if OS installed is of 32 bit ... then compiler will work as working on a 32
bit architecture ... and give the results accordingly ...

@aditi :: i am not so sure abt your stateent regarding the size of pointer
and an int being th same ... could you plzz quote the reference for the same
...

On Sun, Jul 31, 2011 at 12:36 PM, aditi garg aditi.garg.6...@gmail.comwrote:

 @Nikhil the size of pointer is same as int i guess...so it differs on diff
 machines...im not sure abt ur OS and architecture doubt tho...


 On Sat, Jul 30, 2011 at 8:02 PM, Nikhil Gupta 
 nikhilgupta2...@gmail.comwrote:

 One more query. What if the architecture is 64 bit, but the OS is 32 bit?
 (Example windows XP)

 What will be the size of a pointer variable then?


 On Sat, Jul 30, 2011 at 8:00 PM, Nikhil Gupta 
 nikhilgupta2...@gmail.comwrote:

 @Aditi, Isn't the size of int variable 4 bytes in both the architectures?

 On Sat, Jul 30, 2011 at 12:52 PM, aditi garg 
 aditi.garg.6...@gmail.comwrote:

 it can also be found out by using printf(%d,sizeof(int)*8);
 Correct me if i am wrong...


 On Sat, Jul 30, 2011 at 11:55 AM, rajeev bharshetty 
 rajeevr...@gmail.com wrote:

 If pointer size is 4bytes then it is 32 bit machine and if 8 bytes it
 is 64 bit


 On Sat, Jul 30, 2011 at 11:51 AM, Nikhil Gupta 
 nikhilgupta2...@gmail.com wrote:

 How do you find out if a machine is 32 bit or 64 bit?

 I was thinking since the size of pointer variable is different in the
 2 configurations, we can declare a pointer and use sizeof()
 Will that work?
 Any other suggestions?

 --
 Nikhil Gupta

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




 --
 Regards
 Rajeev N B http://www.opensourcemania.co.cc

 *Winners Don't do Different things , they do things Differently*

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


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




 --
 Nikhil Gupta
 Senior Co-ordinator, Publicity
 CSI, NSIT Students' Branch
 NSIT, New Delhi, India




 --
 Nikhil Gupta
 Senior Co-ordinator, Publicity
 CSI, NSIT Students' Branch
 NSIT, New Delhi, India

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




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


  --
 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] Direct - i ques

2011-07-31 Thread Shubham Maheshwari
use a doubly linked list ... with a field node *min.
weneva you insert an element ... check for the value of min at the head ...
if the new inserted node has less value ... then set the min field to point
to itself  else copy the min field of te previous head.

insertion and deletion is easy ... and I hope i dont need to expalin that
too ...

On Sun, Jul 31, 2011 at 12:27 PM, siva viknesh sivavikne...@gmail.comwrote:

 Create a data structure where inserting, deleting and finding the
 minimum element all have O(1) time.

 --
 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: Direct - i ques

2011-07-31 Thread Shubham Maheshwari
its a *doubly* linked list ...
you can easily do the job ...

On Sun, Jul 31, 2011 at 2:23 PM, siva viknesh sivavikne...@gmail.comwrote:

 using LL u cant delete in O(1)  ... u have to traverse from head

 On Jul 31, 1:47 pm, Shubham Maheshwari shubham@gmail.com wrote:
  use a doubly linked list ... with a field node *min.
  weneva you insert an element ... check for the value of min at the head
 ...
  if the new inserted node has less value ... then set the min field to
 point
  to itself  else copy the min field of te previous head.
 
  insertion and deletion is easy ... and I hope i dont need to expalin that
  too ...
 
  On Sun, Jul 31, 2011 at 12:27 PM, siva viknesh sivavikne...@gmail.com
 wrote:
 
 
 
 
 
 
 
   Create a data structure where inserting, deleting and finding the
   minimum element all have O(1) time.
 
   --
   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: Direct - i ques

2011-07-31 Thread Shubham Maheshwari
you mean circular linked list ...!!!
in case of stack ... we cn do it via SSL ...
for a queue implementation ... we will ned circular, or doubly for deletion
in O(1).

On Sun, Jul 31, 2011 at 2:38 PM, naveen ms naveenms...@gmail.com wrote:

 @shubham...i have a doubt.can't the same be done with singly linked list??

 --
 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] Morgan stanely interview ques

2011-07-31 Thread Shubham Maheshwari
color and intensity are2 different things ...
do you mean to find pixels with same intensity ...!!

and wat is meant by can be reached ...!!

On Sun, Jul 31, 2011 at 2:40 PM, sivaviknesh s sivavikne...@gmail.comwrote:

 *Given an nxn screen, Each pixel is represented by intensity values.
 Given a specific pixel as an input, find the no. of pixels of the same
 colour which can reached from this pixel. Assume any suitable data structure
 for a screen.

 ..can this be implemented through BFS ...similar to BITMAP prob in spoj ??
 *
 --
 Regards,
 $iva

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

2011-07-31 Thread Shubham Maheshwari
hw cn u ensure that the elements are inserted in sorted order ...
wat if the elements are coming randmly ...

On Sun, Jul 31, 2011 at 2:49 PM, muthu raj muthura...@gmail.com wrote:






 Use a circular linked list with elements being inserted in sorted order.

 Inserting minimum element :

 struct node *p;
 p is a pointer to last node in the circular singly linked list.
 newmin-next=p-next;
 p-next=newmin;


 Deleting minimum element:

 struct node *temp;
 temp=p-next;
 p-next=p-next-next;
 free(temp);


 Retrieving minimum element :

 return (p-next-ele);








 *Muthuraj R
 IV th Year , ISE
 PESIT , Bangalore*




 On Sun, Jul 31, 2011 at 2:08 AM, naveen ms naveenms...@gmail.com wrote:

 @shubham...i have a doubt.can't the same be done with singly linked list??

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

2011-07-31 Thread Shubham Maheshwari
take countr to be a static variable ... that shud do the job ...!!

btw ...if thats nt the case ... thn i m nt pretty sure wat u are asking to
be done ...

On Sun, Jul 31, 2011 at 2:12 AM, Rahul Mittal rahulmitta...@gmail.comwrote:

 help me with this
 we need to find out how many times a function is recursively called
 while inserting a node in bst.

 insert (number X, node N)
  increase the counter C by 1
  if X is less than the number in node N
   if N has no left child
   create a new node with the number X and set
 it to be the left child of node N
   else
   insert (X, left child of node N)
  else (X is greater than the number in node N)
   if N has no right child
   create a new node with the number X and set
 it to be the right child of node N
   else
   insert (X, right child of node N)
 we need value of count
 PS:this algorithm will exceed time limit

 --
 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: Direct - i ques

2011-07-31 Thread Shubham Maheshwari
the operation is nt extract min ... its *find* min ...



On Sun, Jul 31, 2011 at 3:02 PM, Abhishek Gupta gupta.abh...@gmail.comwrote:

 @shubham maheshawari

 deletion can't be performed in O(1).
 after extracting the min element, we need to find the next minimum element,
 and worst case will take O(n) time.

 On Sun, Jul 31, 2011 at 3:00 PM, Shubham Maheshwari shubham@gmail.com
  wrote:

 hw cn u ensure that the elements are inserted in sorted order ...
 wat if the elements are coming randmly ...

 On Sun, Jul 31, 2011 at 2:49 PM, muthu raj muthura...@gmail.com wrote:






 Use a circular linked list with elements being inserted in sorted order.

 Inserting minimum element :

 struct node *p;
 p is a pointer to last node in the circular singly linked list.
 newmin-next=p-next;
 p-next=newmin;


 Deleting minimum element:

 struct node *temp;
 temp=p-next;
 p-next=p-next-next;
 free(temp);


 Retrieving minimum element :

 return (p-next-ele);








 *Muthuraj R
 IV th Year , ISE
 PESIT , Bangalore*




 On Sun, Jul 31, 2011 at 2:08 AM, naveen ms naveenms...@gmail.comwrote:

 @shubham...i have a doubt.can't the same be done with singly linked
 list??

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




 --
 Abhishek Gupta
 MCA
 NIT Calicut
 Kerela

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

2011-07-31 Thread Shubham Maheshwari
http://ideone.com/IZKyN

could you plzz explain this to me ...!!
anyone ...

On Sun, Jul 31, 2011 at 1:56 AM, Kamakshii Aggarwal
kamakshi...@gmail.comwrote:

 @sanchit:no,not at all :)


 On Sun, Jul 31, 2011 at 1:55 AM, Sanchit Manchanda 
 sanchit...@gmail.comwrote:

 @kamakshi- sorry if you felt i was rude. :-\


 On Sun, Jul 31, 2011 at 1:53 AM, aditi garg aditi.garg.6...@gmail.comwrote:

 some garbage value


 On Sun, Jul 31, 2011 at 1:51 AM, gaurav gupta grvgupta...@gmail.comwrote:

 then wat sud b the value of *(a+1) since array is only defind for 5
 elements


 On Sun, Jul 31, 2011 at 1:48 AM, Sanchit Manchanda 
 sanchit...@gmail.com wrote:

 yes it will print the next address in memory after the last element.


 On Sun, Jul 31, 2011 at 1:46 AM, gaurav gupta 
 grvgupta...@gmail.comwrote:

 i understand much. thanx fr it. plz tell me if i hv to print a+1 then
 it sud print the next address after the last element


 On Sun, Jul 31, 2011 at 1:40 AM, Sanchit Manchanda 
 sanchit...@gmail.com wrote:

 @gaurav- a takes you to the address 1st element of the array.
 a+1 takes you to the next address after the last element. this mean
 if int is 4bits. then arrays of 5 int values is 20 bits. so *+1 *in
 a+1 covers 20 bits in memory. similarly a+2 covers next 20 bits. and 
 so
 on.

 where as (*(a+1)) points to 1st element,(*(a+2)) points to 2nd
 element and so on.

 i hope this helps


 On Sun, Jul 31, 2011 at 1:35 AM, gaurav gupta grvgupta...@gmail.com
  wrote:

 so u mean der is difference between a and a[0]


 On Sun, Jul 31, 2011 at 1:30 AM, Kamakshii Aggarwal 
 kamakshi...@gmail.com wrote:

 a points to the array.so when u increment it by 1 it will get
 incremented by the size of array.


 On Sun, Jul 31, 2011 at 1:28 AM, gaurav gupta 
 grvgupta...@gmail.com wrote:

 a+1 takes to the last element of the array bt is the logic behind
 dis


 On Sun, Jul 31, 2011 at 1:25 AM, Kamakshii Aggarwal 
 kamakshi...@gmail.com wrote:

 a+1 will point to the next array(i.e it will skip the whole
 array)
 where as (a+1)will print address of element 2.

 On Sun, Jul 31, 2011 at 1:21 AM, Sanchit Manchanda 
 sanchit...@gmail.com wrote:

 Sorry my bad. I was wrong.

 On Sun, Jul 31, 2011 at 1:15 AM, gaurav gupta 
 grvgupta...@gmail.com wrote:

 main()
 {
 int a[5]={1,2,3,4,5};
 printf(%d%d,a+1,(a+1));
 }
 plz explain me the difference in ans.
 thanx..

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




 --
 Sanchit Manchanda
 COE(3rd year) , NSIT
 http://iblogmythots.wordpress.com/

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




 --
 Regards,
 Kamakshi
 kamakshi...@gmail.com

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


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




 --
 Regards,
 Kamakshi
 kamakshi...@gmail.com

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


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




 --
 Sanchit Manchanda
 COE(3rd year) , NSIT
 http://iblogmythots.wordpress.com/

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

Re: [algogeeks] Re: Direct - i ques

2011-07-31 Thread Shubham Maheshwari
i am givin solution for implementing a queue or a stack ...
in which ...inserting, delelting and finding min element is of O(1).

hope this is clear now ...

On Sun, Jul 31, 2011 at 3:19 PM, Abhishek Gupta gupta.abh...@gmail.comwrote:

 Qn is : Create a data structure where inserting, deleting and finding the

 minimum element all have O(1) time.

 so after deleting the minimum element, where will you point min pointer?

 Sorry if i m wrong


 On Sun, Jul 31, 2011 at 3:11 PM, Shubham Maheshwari shubham@gmail.com
  wrote:

 the operation is nt extract min ... its *find* min ...



 On Sun, Jul 31, 2011 at 3:02 PM, Abhishek Gupta 
 gupta.abh...@gmail.comwrote:

 @shubham maheshawari

 deletion can't be performed in O(1).
 after extracting the min element, we need to find the next minimum
 element, and worst case will take O(n) time.

 On Sun, Jul 31, 2011 at 3:00 PM, Shubham Maheshwari 
 shubham@gmail.com wrote:

 hw cn u ensure that the elements are inserted in sorted order ...
 wat if the elements are coming randmly ...

 On Sun, Jul 31, 2011 at 2:49 PM, muthu raj muthura...@gmail.comwrote:






 Use a circular linked list with elements being inserted in sorted
 order.

 Inserting minimum element :

 struct node *p;
 p is a pointer to last node in the circular singly linked list.
 newmin-next=p-next;
 p-next=newmin;


 Deleting minimum element:

 struct node *temp;
 temp=p-next;
 p-next=p-next-next;
 free(temp);


 Retrieving minimum element :

 return (p-next-ele);








 *Muthuraj R
 IV th Year , ISE
 PESIT , Bangalore*




 On Sun, Jul 31, 2011 at 2:08 AM, naveen ms naveenms...@gmail.comwrote:

 @shubham...i have a doubt.can't the same be done with singly linked
 list??

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




 --
 Abhishek Gupta
 MCA
 NIT Calicut
 Kerela

  --
 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 Gupta
 MCA
 NIT Calicut
 Kerela

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

2011-07-22 Thread Shubham Maheshwari
x = 0;
while( n ){
x = 1;
x = x | ( n  1);
n = 1;
}

return x;

On Fri, Jul 22, 2011 at 1:31 PM, Puneet Gautam puneet.nsi...@gmail.comwrote:

 sorry guys.. dont check the above siolution.. its wrong...!!!
 misread it..


 On 7/22/11, Puneet Gautam puneet.nsi...@gmail.com wrote:
  check this out: Considering all 4 bytes of int with no left or right
  shifts..!!
  ;)
 
  main()
  { unsigned int i,j,k,no=1;
j=4;
for(k=0;k32;k++)
 no*=2;
no=no-j;
cout\n The reverse isno;
getch();
return 0;
}
 
  On 7/22/11, nicks crazy.logic.k...@gmail.com wrote:
  see this
 
  http://geeksforgeeks.org/?p=726
 
  On Fri, Jul 22, 2011 at 4:29 AM, adhyetha ranjith.kaga...@gmail.com
  wrote:
 
  reverse(int n)
  {
 int i, result = 0;
 
 for(i = 0; i  32; i++)
result |= ((n  i)  1)  (31 - i);
  }
 
 
   assuming 32 bit integer to be reversed and assuming all 32 bits
  to be reversed.. i.e 100101 reverses to
  10100100
 
  --
  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] Re: Microsoft Question!

2011-07-22 Thread Shubham Maheshwari
thnx ...
:D

On Fri, Jul 22, 2011 at 9:19 PM, sagar pareek sagarpar...@gmail.com wrote:

 gr8 shubham

 On Fri, Jul 22, 2011 at 1:42 PM, Shubham Maheshwari shubham@gmail.com
  wrote:

 x = 0;
 while( n ){
 x = 1;
 x = x | ( n  1);
 n = 1;
 }

 return x;

 On Fri, Jul 22, 2011 at 1:31 PM, Puneet Gautam 
 puneet.nsi...@gmail.comwrote:

 sorry guys.. dont check the above siolution.. its wrong...!!!
 misread it..


 On 7/22/11, Puneet Gautam puneet.nsi...@gmail.com wrote:
  check this out: Considering all 4 bytes of int with no left or right
  shifts..!!
  ;)
 
  main()
  { unsigned int i,j,k,no=1;
j=4;
for(k=0;k32;k++)
 no*=2;
no=no-j;
cout\n The reverse isno;
getch();
return 0;
}
 
  On 7/22/11, nicks crazy.logic.k...@gmail.com wrote:
  see this
 
  http://geeksforgeeks.org/?p=726
 
  On Fri, Jul 22, 2011 at 4:29 AM, adhyetha ranjith.kaga...@gmail.com
  wrote:
 
  reverse(int n)
  {
 int i, result = 0;
 
 for(i = 0; i  32; i++)
result |= ((n  i)  1)  (31 - i);
  }
 
 
   assuming 32 bit integer to be reversed and assuming all 32 bits
  to be reversed.. i.e 100101 reverses to
  10100100
 
  --
  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.




 --
 **Regards
 SAGAR PAREEK
 COMPUTER SCIENCE AND ENGINEERING
 NIT ALLAHABAD

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


-- 
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] Interview Puzzle - 100 Prisoners and Caps

2011-07-22 Thread Shubham Maheshwari
could some1 plz post the xplainations ...

On Fri, Jul 22, 2011 at 8:04 PM, Pankaj jatka.oppimi...@gmail.com wrote:

 Chetan,

 No. How could you relate this problem with that? Do you find something
 similar?

 ~
 Pankaj


 On Fri, Jul 22, 2011 at 8:01 PM, chetan kapoor 
 chetankapoor...@gmail.comwrote:

 josehus problem???


 On Fri, Jul 22, 2011 at 7:57 PM, Pankaj jatka.oppimi...@gmail.comwrote:

 Skipp Riddle,
 Yes.
 100th prisoner will risk his life. Similar puzzle was discuss recently.
 Does anyone remember the name or thread?


 ~
 Pankaj


 On Fri, Jul 22, 2011 at 7:55 PM, SkRiPt KiDdIe 
 anuragmsi...@gmail.comwrote:

 Worst case 99 get released.
 Is that correct..?

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


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


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


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


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



Re: [algogeeks] Re: subwords in a given word!

2011-07-22 Thread Shubham Maheshwari
how are you gonna do it if the originl strng contains repeated letters ...

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

 what algorithm, print it subsequently
 is there any ?


 On Fri, Jul 22, 2011 at 3:24 PM, DeeJJ..! suryaprakash...@gmail.comwrote:

 @sunny...yaa..but can u just describe the algorithm..:)

 On Jul 22, 2:51 am, sunny agrawal sunny816.i...@gmail.com wrote:
  n+(n-1) +(n-2)++1 = O(n^2)
 
 
 
  On Fri, Jul 22, 2011 at 3:16 PM, DeeJJ..! suryaprakash...@gmail.com
 wrote:
   Q)complexity to find subwords in a given word?
   ex: abcde
   ans: a b c d e
 ab bc cd de
 abc bcd cde
 abcd bcde
 abcde
 
   --
   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.


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

2011-07-20 Thread Shubham Maheshwari
let A:: ((n(n+1)/2) - sum)
let B:: ((n(n+1)(2n+1)/6) - (sum of squares of elements))

then missing number = ((B/A) + A)/2;

complexity O(n).
space complexity O(1).

On Wed, Jul 20, 2011 at 12:47 PM, saurabh singh saurab...@gmail.com wrote:

 Q1 can be solved using some simple maths:)
 Hint:What is the sum of first n natural numbers?And what is the sum of
 squares of first n natural numbers?


 On Wed, Jul 20, 2011 at 12:44 PM, siva viknesh sivavikne...@gmail.comwrote:

 gn array - say a

 hav extra array - say b - initialise all values to zero

 ques 1:

 for(i=1;i=n;i++)
 {
b[a[i]]++;

 }

 then traverse b array and print i, for which b[i] = 2

 o(n) time  space

 same idea for ques 2

 better approaches please

 On Jul 20, 12:11 pm, siva viknesh sivavikne...@gmail.com wrote:
  gn array - say a
 
  hav extra array - say b - initialise all values to zero
 
  ques 1:for(i=1;i=n;i++)
  {
  b[a[i]]++;
 
  }
 
  On Jul 20, 12:07 pm, siva viknesh sivavikne...@gmail.com wrote:
 
 
 
 
 
 
 
   1.Given an array of size n. It contains numbers in the range 1 to n.
   Each number is present at least once except for 2 numbers. Find the
   missing numbers.
 
   2.Given an array of size n. It contains numbers in the range 1 to n.
   Find the numbers which aren’t present.

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




 --
 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT 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.




-- 
Shubham Maheshwari
ShubZz
O.o o.O

enJoY ...!!!

-- 
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] is it possible to detect the first repeating number in a 2-D array (n X n) in O(n) time ?

2011-07-18 Thread Shubham Maheshwari
what would be the O(n^2) sol. to this ...!!

On Tue, Jul 19, 2011 at 12:41 AM, snehi jain snehijai...@gmail.com wrote:

 can it be solved in less than O(n^2) like O(nlogn ) types..
 i cant figure out any solution less than O(n^2).


 On Tue, Jul 19, 2011 at 12:37 AM, ankit sambyal ankitsamb...@gmail.comwrote:

 @Snehi :If the elements are random, then it seems that this problem
 can't be solved in O(n) time

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




-- 
Shubham Maheshwari
ShubZz
O.o o.O

enJoY ...!!!

-- 
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] is it possible to detect the first repeating number in a 2-D array (n X n) in O(n) time ?

2011-07-18 Thread Shubham Maheshwari
can we do anything else .. othr than hash tables ...

On Tue, Jul 19, 2011 at 1:05 AM, Saket Choudhary sake...@gmail.com wrote:

 Have a hash Table. Read the elements and push it to the hash table. If it
 alraedy exists you are done.

 On 19 July 2011 01:02, Shubham Maheshwari shubham.veloc...@gmail.comwrote:

 what would be the O(n^2) sol. to this ...!!


 On Tue, Jul 19, 2011 at 12:41 AM, snehi jain snehijai...@gmail.comwrote:

 can it be solved in less than O(n^2) like O(nlogn ) types..
 i cant figure out any solution less than O(n^2).


 On Tue, Jul 19, 2011 at 12:37 AM, ankit sambyal 
 ankitsamb...@gmail.comwrote:

 @Snehi :If the elements are random, then it seems that this problem
 can't be solved in O(n) time

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




 --
 Shubham Maheshwari
 ShubZz
 O.o o.O

 enJoY ...!!!

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




-- 
Shubham Maheshwari
ShubZz
O.o o.O

enJoY ...!!!

-- 
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] is it possible to detect the first repeating number in a 2-D array (n X n) in O(n) time ?

2011-07-18 Thread Shubham Maheshwari
the complexity of this func depends on the .include thing,
and if it were to be coded in C,
time cmplexity wud to to n^2.

On Tue, Jul 19, 2011 at 1:12 AM, Saket Choudhary sake...@gmail.com wrote:

 Ruby Solution for 1d array. The logic for 2d array remains same.

 a=[1,2,3,4,5,1]
 b=[]
 for m in a
   unless b.include?(m)
 bm
   else
 puts m
 break
   end
 end

 On 19 July 2011 01:05, Saket Choudhary sake...@gmail.com wrote:

 Have a hash Table. Read the elements and push it to the hash table. If it
 alraedy exists you are done.


 On 19 July 2011 01:02, Shubham Maheshwari shubham.veloc...@gmail.comwrote:

 what would be the O(n^2) sol. to this ...!!


 On Tue, Jul 19, 2011 at 12:41 AM, snehi jain snehijai...@gmail.comwrote:

 can it be solved in less than O(n^2) like O(nlogn ) types..
 i cant figure out any solution less than O(n^2).


 On Tue, Jul 19, 2011 at 12:37 AM, ankit sambyal ankitsamb...@gmail.com
  wrote:

 @Snehi :If the elements are random, then it seems that this problem
 can't be solved in O(n) time

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




 --
 Shubham Maheshwari
 ShubZz
 O.o o.O

 enJoY ...!!!

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




-- 
Shubham Maheshwari
ShubZz
O.o o.O

enJoY ...!!!

-- 
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] static vs dynamic array

2011-07-18 Thread Shubham Maheshwari
the 2.nd one is also working fine ...
check it out ..
http://www.ideone.com/ue96W

the given arguments are all correct .. bt since its returning a copy of it
to the main .. it'll work fine ...

On Mon, Jul 18, 2011 at 11:28 PM, sunny agrawal sunny816.i...@gmail.comwrote:

 Yes thats right but a small but obvious correction which holds good till
 you explicitly call free function or...


 On Mon, Jul 18, 2011 at 10:49 PM, Swathi chukka.swa...@gmail.com wrote:

 In first 1, you are using malloc() so the memory will be allocated from
 heap which holds good till end of your program.. In second case, the memory
 will be allocated on the stack.. so once the function is exited, your stack
 data will be released...


 On Mon, Jul 18, 2011 at 9:49 PM, rj7 r4ra...@gmail.com wrote:

 Can someone pls explain the difference between these two especially in
 terms of scope... one example i have come across is
1.
char *xxx(int n)
{
char *retbuf = malloc(25);
if(retbuf == NULL)
return NULL;
sprintf(retbuf, %d, n);
return retbuf;
}

2.
char *xxx(int n)
{
char retbuf[25];
sprintf(retbuf, %d, n);
return retbuf;
}

 First one is correct and the second one is wrong... why does the scope
 of retbuf extends to the calling function...
 am just a beginner so ignore the stupidity(if any).

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




-- 
Shubham Maheshwari
ShubZz
O.o o.O

enJoY ...!!!

-- 
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 is the output of the following program? Why?

2011-07-17 Thread Shubham Maheshwari
i wasnt sure abt the first part of it.
the one with multiple initializations ...
:P

On Sun, Jul 17, 2011 at 3:09 AM, sagar pareek sagarpar...@gmail.com wrote:

 Well shubham if you know about the unions very well then why u asked this
 question?


 On Sun, Jul 17, 2011 at 2:27 AM, Shubham Maheshwari 
 shubham.veloc...@gmail.com wrote:

 :D


 On Sun, Jul 17, 2011 at 2:24 AM, Kamakshii Aggarwal 
 kamakshi...@gmail.com wrote:

 @shubham:yes u r right.thanks :)


 On Sun, Jul 17, 2011 at 2:12 AM, Shubham Maheshwari 
 shubham.veloc...@gmail.com wrote:

 @Kamakshii:
 thats probably becuz a union has a common memory location, accessed by
 all its members.
 so, the value '100' is treated as an int by 'a', as a char array by 'b'
 and as a float by 'c'.
 I thnk i read this read tis somewhere sometime back. ... so aint
 completely sure abt it.


 On Sun, Jul 17, 2011 at 2:08 AM, Kamakshii Aggarwal 
 kamakshi...@gmail.com wrote:


 u can always retrieve that value from the union that has been assigned
 last.therefore u get correct answer only for x.c

 in the case of union y
 y.a=100 and so the output
 but am not sure why y.b is printing character equivalent of 100.


 On Sun, Jul 17, 2011 at 1:58 AM, Shubham Maheshwari 
 shubham.veloc...@gmail.com wrote:

 you mean to say .. the ques is wrong ... or what ...!!


 On Sun, Jul 17, 2011 at 1:54 AM, sagar pareek 
 sagarpar...@gmail.comwrote:

 I think you must first read about unions and the differences between
 union and structures :)

 On Sun, Jul 17, 2011 at 1:48 AM, Shubham Maheshwari 
 shubham.veloc...@gmail.com wrote:

 union Data Type
 What is the output of the following program? Why?
 #include
 main() {
 typedef union {
 int a;
 char b[10];
 float c;
 }
 Union;
 Union x,y = {100};
 x.a = 50;
 strcpy(x.b,hello);
 x.c = 21.50;
 printf(Union x : %d %s %f n,x.a,x.b,x.c);
 printf(Union y : %d %s %f n,y.a,y.b,y.c);
 }

 --
 Shubham Maheshwari
 ShubZz
 O.o o.O

 enJoY ...!!!

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




 --
 **Regards
 SAGAR PAREEK
 COMPUTER SCIENCE AND ENGINEERING
 NIT ALLAHABAD

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




 --
 Shubham Maheshwari
 ShubZz
 O.o o.O

 enJoY ...!!!

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




 --
 Regards,
 Kamakshi
 kamakshi...@gmail.com

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




 --
 Shubham Maheshwari
 ShubZz
 O.o o.O

 enJoY ...!!!

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




 --
 Regards,
 Kamakshi
 kamakshi...@gmail.com

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




 --
 Shubham Maheshwari
 ShubZz
 O.o o.O

 enJoY ...!!!

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




 --
 **Regards
 SAGAR PAREEK
 COMPUTER SCIENCE AND ENGINEERING
 NIT ALLAHABAD

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

Re: [algogeeks] Re: Finding the Kth Prime

2011-07-17 Thread Shubham Maheshwari
@Dave: could you please extrapolate on the 'sequence point rule' a bit more.
i am nt familiar with it ...


On Sun, Jul 17, 2011 at 3:01 AM, Dave dave_and_da...@juno.com wrote:

 @Anthony: Your code violates the sequence point rule, which states
 that the value of a variable can change at most one time between
 sequence points, and thus your code is nonstandard. The results of
 executing nonstandard code is undefined.

 Dave

 On Jul 15, 3:22 pm, Antony Kotre antonyko...@gmail.com wrote:
  sorry I don't know how to post new thread so posting my query here and
  please some one tell how to do that
 
  can any tell and explain the output of following code
 
  #includestdio.h
  main()
  {   int a =5, b=5;
  int res1=(++a)+(++a)+(++a);
  int res2=(++b)+(++b)*10+(++b)*100;
 
  printf(%d\n%d\n,res1,res2);
 
 
 
  }- Hide quoted text -
 
  - Show quoted text -

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




-- 
Shubham Maheshwari
ShubZz
O.o o.O

enJoY ...!!!

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



Re: [algogeeks] Microsoft Qn: Algo to find the border of a binary tree

2011-07-16 Thread Shubham Maheshwari
according to saagar's algo, it'll be printed ...

On Sun, Jul 17, 2011 at 1:02 AM, swetha rahul swetharahu...@gmail.comwrote:

 @Reynald
 Will 75 not be included in the tree that u have
 given..??


 On Sun, Jul 17, 2011 at 12:49 AM, sagar pareek sagarpar...@gmail.comwrote:

 here is the code
 void border(node*);
 void recur(node*);

 void border(node *ptr)
 {
  node* tmp; int stack[20],top=0;
  if(tmp=ptr-left)
  {
   while(tmp-left)
   {
printf(%d ,tmp-data);
tmp=tmp-left;
   }
  }
  recur(ptr);
  if(tmp=ptr-right)
  {
   while(tmp-right)
   {
stack[top++]=tmp-data;
tmp=tmp-right;
   }
  }
  while(top--) printf(%d ,stack[top]);
  printf(%d\n,ptr-data);
 }

 void recur(node* ptr)
 {
  if(ptr-left) recur(ptr-left);
  if(!ptr-left!ptr-right) printf(%d ,ptr-data);
  if(ptr-right)   recur(ptr-right);

 }

 On Sat, Jul 16, 2011 at 7:07 PM, Reynald reynaldsus...@gmail.com wrote:

 Algo to find the border of a given binary tree. Optimized for space
 and time.
 Input:
  10
   / \
 50 50
/  \ /   \
  25  75   20020
  / \   /  /\
 15 35   120155   250

 Output:50 25 15 35 120 155 250 20 150 10

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




 --
 **Regards
 SAGAR PAREEK
 COMPUTER SCIENCE AND ENGINEERING
 NIT ALLAHABAD

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


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




-- 
Shubham Maheshwari
ShubZz
O.o o.O

enJoY ...!!!

-- 
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] What is the output of the following program? Why?

2011-07-16 Thread Shubham Maheshwari
union Data Type
What is the output of the following program? Why?
#include
main() {
typedef union {
int a;
char b[10];
float c;
}
Union;
Union x,y = {100};
x.a = 50;
strcpy(x.b,hello);
x.c = 21.50;
printf(Union x : %d %s %f n,x.a,x.b,x.c);
printf(Union y : %d %s %f n,y.a,y.b,y.c);
}

-- 
Shubham Maheshwari
ShubZz
O.o o.O

enJoY ...!!!

-- 
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 is the output of the following program? Why?

2011-07-16 Thread Shubham Maheshwari
you mean to say .. the ques is wrong ... or what ...!!

On Sun, Jul 17, 2011 at 1:54 AM, sagar pareek sagarpar...@gmail.com wrote:

 I think you must first read about unions and the differences between union
 and structures :)

 On Sun, Jul 17, 2011 at 1:48 AM, Shubham Maheshwari 
 shubham.veloc...@gmail.com wrote:

 union Data Type
 What is the output of the following program? Why?
 #include
 main() {
 typedef union {
 int a;
 char b[10];
 float c;
 }
 Union;
 Union x,y = {100};
 x.a = 50;
 strcpy(x.b,hello);
 x.c = 21.50;
 printf(Union x : %d %s %f n,x.a,x.b,x.c);
 printf(Union y : %d %s %f n,y.a,y.b,y.c);
 }

 --
 Shubham Maheshwari
 ShubZz
 O.o o.O

 enJoY ...!!!

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




 --
 **Regards
 SAGAR PAREEK
 COMPUTER SCIENCE AND ENGINEERING
 NIT ALLAHABAD

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




-- 
Shubham Maheshwari
ShubZz
O.o o.O

enJoY ...!!!

-- 
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 is the output of the following program? Why?

2011-07-16 Thread Shubham Maheshwari
@Kamakshii:
thats probably becuz a union has a common memory location, accessed by all
its members.
so, the value '100' is treated as an int by 'a', as a char array by 'b' and
as a float by 'c'.
I thnk i read this read tis somewhere sometime back. ... so aint completely
sure abt it.

On Sun, Jul 17, 2011 at 2:08 AM, Kamakshii Aggarwal
kamakshi...@gmail.comwrote:


 u can always retrieve that value from the union that has been assigned
 last.therefore u get correct answer only for x.c

 in the case of union y
 y.a=100 and so the output
 but am not sure why y.b is printing character equivalent of 100.


 On Sun, Jul 17, 2011 at 1:58 AM, Shubham Maheshwari 
 shubham.veloc...@gmail.com wrote:

 you mean to say .. the ques is wrong ... or what ...!!


 On Sun, Jul 17, 2011 at 1:54 AM, sagar pareek sagarpar...@gmail.comwrote:

 I think you must first read about unions and the differences between
 union and structures :)

 On Sun, Jul 17, 2011 at 1:48 AM, Shubham Maheshwari 
 shubham.veloc...@gmail.com wrote:

 union Data Type
 What is the output of the following program? Why?
 #include
 main() {
 typedef union {
 int a;
 char b[10];
 float c;
 }
 Union;
 Union x,y = {100};
 x.a = 50;
 strcpy(x.b,hello);
 x.c = 21.50;
 printf(Union x : %d %s %f n,x.a,x.b,x.c);
 printf(Union y : %d %s %f n,y.a,y.b,y.c);
 }

 --
 Shubham Maheshwari
 ShubZz
 O.o o.O

 enJoY ...!!!

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




 --
 **Regards
 SAGAR PAREEK
 COMPUTER SCIENCE AND ENGINEERING
 NIT ALLAHABAD

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




 --
 Shubham Maheshwari
 ShubZz
 O.o o.O

 enJoY ...!!!

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




 --
 Regards,
 Kamakshi
 kamakshi...@gmail.com

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




-- 
Shubham Maheshwari
ShubZz
O.o o.O

enJoY ...!!!

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