Re: [algogeeks] Recursive version of reversing linked list

2011-07-31 Thread Vanathi Arivazhagan
struct node * Rec_Reverse(struct node *p, struct node *q) { static struct node *r; if(q-next!=NULL) Rec_Reverse(p-next,q-next); if(set == 0) {r=q; set++; } q-next = p; p-next=NULL; return r; } This method has to

Re: [algogeeks] HOW GARBAGE COLLECTOR WORKS IN JAVA

2011-07-31 Thread Deepthi Srinivasan
Garbage collection is totally JVM dependent... Some JVMs may use a mark and sweep algorithm. The first thing u should understand abt Java's garbage collection is totally unpredicatble. You cant really predict when garbage collection is done. If and when the JVM decides that garbage coll should be

Re: [algogeeks] Re: Novell - Puzzle

2011-07-31 Thread ashish kumar
233 is the right answer.. On Fri, Jul 29, 2011 at 12:27 PM, shiv narayan narayan.shiv...@gmail.comwrote: solutions for cow questions: if we consider first cow would she calf at age 2 then first new cow would come at age two. at end of 2nd year: 1st would give new cow: at end of 3rd year:1st

Re: [algogeeks] Re: FB intern

2011-07-31 Thread Prakash D
what does n mod 2's job here? the only possible return case is when n/2 is 0 or 1 On Sat, Jul 30, 2011 at 2:04 PM, saurabh singh saurab...@gmail.com wrote: And yes the formula is derived by the fact that x^(a+b)=x^a*x^b and then think top down with respect to a general variable n.(That is

Re: [algogeeks]

2011-07-31 Thread SHIVAM AGRAWAL
plz xplain y it is printing zero ...means how dis prgrm is wrkng step by step On Sun, Jul 31, 2011 at 11:03 AM, rajeev bharshetty rajeevr...@gmail.comwrote: *#includestdio.h* *#ifdef getchar* *#undef getchar* *#else* *#define getchar scanf(%c,ch);* *#endif* *main()* *{* *char

Re: [algogeeks]

2011-07-31 Thread SHIVAM AGRAWAL
i got it On Sun, Jul 31, 2011 at 11:08 AM, SHIVAM AGRAWAL shivi...@gmail.com wrote: plz xplain y it is printing zero ...means how dis prgrm is wrkng step by step On Sun, Jul 31, 2011 at 11:03 AM, rajeev bharshetty rajeevr...@gmail.comwrote: *#includestdio.h* *#ifdef getchar*

Re: [algogeeks] 32 bit?

2011-07-31 Thread Nikhil Gupta
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

Re: [algogeeks] HOW GARBAGE COLLECTOR WORKS IN JAVA

2011-07-31 Thread siddharth srivastava
Hi Vaibhav On 30 July 2011 23:40, vaibhav shukla vaibhav200...@gmail.com wrote: please give a glimps of how garbage collection is done in java. how *System.gc()* works ? Please do not use ALL CAPS in subject line. It is a bit scary :) -- best wishes!! Vaibhav -- You

Re: [algogeeks] 32 bit?

2011-07-31 Thread Nikhil Gupta
@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

Re: [algogeeks] DS representation.

2011-07-31 Thread rahul
I think it might help... struct node { int coef; /* A,B,C */ int var; /* x */ unsigned int exp;/* power of x */ struct node *next; /* next term in polynomial equation */ }; typedef struct node NODE; Regards. On Fri, Jul 29, 2011 at 7:32 PM, saurabh singh

Re: [algogeeks] Tug of War

2011-07-31 Thread Prashant Gupta
Its NP problem. :-| On Sat, Jul 30, 2011 at 4:14 PM, saurabh singh saurab...@gmail.com wrote: Its the same as we divide teams.Pick the Largest in one and second largest in other,then putting the remaining best player to the team which is weaker. the weakest get selected last.if the teams are

[algogeeks] Direct - i ques

2011-07-31 Thread siva viknesh
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

Re: [algogeeks]

2011-07-31 Thread rajeev bharshetty
scanf returns the number of characters scanned as input,in here the scanf statement gets placed at getchar and hence since it accepts 1 character 'c' will print the value 1. #ifdef getchar checks for whether getchar is defined if defined it undefines it as #undef else it #define getchar as scanf

Re: [algogeeks]

2011-07-31 Thread SHIVAM AGRAWAL
yupthnx On Sun, Jul 31, 2011 at 12:28 PM, rajeev bharshetty rajeevr...@gmail.comwrote: scanf returns the number of characters scanned as input,in here the scanf statement gets placed at getchar and hence since it accepts 1 character 'c' will print the value 1. #ifdef getchar checks

Re: [algogeeks] 32 bit?

2011-07-31 Thread aditi garg
@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?

Re: [algogeeks] Re: Novell - Puzzle

2011-07-31 Thread Tushar Bindal
@Nikhil Once the rabbits are mature, they should be able to produce babies every month. after 2 months a female produces new babies for first time. but then they should be able to produce a new pair at the end of the third month as they can again mate at the end of second month. Like in the cow

Re: [algogeeks] Re: Novell - Puzzle

2011-07-31 Thread Nikhil Gupta
In the problem statement, the rabbits give birth to new ones after every 2 months. Not after each month. On Sun, Jul 31, 2011 at 12:51 PM, Tushar Bindal tushicom...@gmail.comwrote: @Nikhil Once the rabbits are mature, they should be able to produce babies every month. after 2 months a female

Re: [algogeeks] Re: Novell - Puzzle

2011-07-31 Thread Priyanka
144 pairs correct me if im wrong On Sun, Jul 31, 2011 at 1:00 PM, Nikhil Gupta nikhilgupta2...@gmail.comwrote: In the problem statement, the rabbits give birth to new ones after every 2 months. Not after each month. On Sun, Jul 31, 2011 at 12:51 PM, Tushar Bindal tushicom...@gmail.comwrote:

Re: [algogeeks] Re: Novell - Puzzle

2011-07-31 Thread Tushar Bindal
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

Re: [algogeeks] Re: Novell - Puzzle

2011-07-31 Thread Nikhil Gupta
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 *

[algogeeks] Re: interview questoin

2011-07-31 Thread siva viknesh
using map ?? key - string , value - count..print d string whose count is 1.. On Jul 19, 8:49 pm, pacific :-) pacific4...@gmail.com wrote: sorry. On Tue, Jul 19, 2011 at 9:07 PM, Shubham Maheshwari shubham.veloc...@gmail.com wrote: what is meant by unique string ...!! A string

[algogeeks] Re: interview questoin

2011-07-31 Thread Amit Jaspal
This is discussed before I think. It will be in O(n). On Jul 31, 1:15 pm, siva viknesh sivavikne...@gmail.com wrote: using map ?? key - string , value - count..print d string whose count is 1.. On Jul 19, 8:49 pm, pacific :-) pacific4...@gmail.com wrote: sorry. On Tue, Jul 19,

Re: [algogeeks]

2011-07-31 Thread karthiga m
here we just undefining wat we defined rite then wat is the use of ifdef undef..we can directly use as #define getchar ...na !! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

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,

[algogeeks] Odd one out

2011-07-31 Thread Abhishek Gupta
Q1- A large size array is given. All except one element are repeated even no. of times and one element is repeated odd no. of times. Find that element. Don't use X-OR Ans - Is there any efficient way of finding it without using sorting or removing duplicates or using hash tables?? Q2- Same qn

Re: [algogeeks] Re: FB intern

2011-07-31 Thread priyanka raju
tats bcos... if it is a^21... it will be (a^21/2)*(a^21/2)*(a^21mod2) = (a^10)*(a^10)*(a^1) correct me if i'm wrong -- cheers priyanka -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

[algogeeks] Frequently asked interview ques

2011-07-31 Thread sivaviknesh s
1. Given words in a newspaper as input find the words that have occured oly once 2. Find the 5 most repeating words in a given document ...Is there any other optimal solutions other than using map ?? -- Regards, $iva -- You received this message because you are subscribed to the Google

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

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

[algogeeks]

2011-07-31 Thread priyanka raju
write a c program to print the following * * * * * * * * * -- cheers priyanka -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To

[algogeeks] Re: Direct - i ques

2011-07-31 Thread siva viknesh
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

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

[algogeeks] C doubt

2011-07-31 Thread Tyler Durden
How do we declare an array of N pointers to functions that return int?? An array of N pointers to integers is this: int *p[N] Just can't figure out the case for pointers to function -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view

[algogeeks] Re: C doubt

2011-07-31 Thread Tyler Durden
Is it right?? declare an array of pointers like, int *func[N]; and since they are pointers to functions, modify above as, int (*func[N])(); -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

Re: [algogeeks]

2011-07-31 Thread Someshwar Chandrasekaran
On Sun, Jul 31, 2011 at 2:20 PM, priyanka raju priyark...@gmail.com wrote: write a c program to print the following        *    *       * *      *       *     *      *         * What complexity is expected? Regards, B.C.Someshwar -- 'Talk sense to a fool and he calls you foolish.' -

Re: [algogeeks] Re: Direct - i ques

2011-07-31 Thread naveen ms
@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] Morgan stanely interview ques

2011-07-31 Thread sivaviknesh s
*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

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

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

Re: [algogeeks] Re: Direct - i ques

2011-07-31 Thread muthu raj
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;

Re: [algogeeks] Re: C doubt

2011-07-31 Thread ankit sambyal
yup its 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

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 :

Re: [algogeeks] Convert number to negative base

2011-07-31 Thread saurabh modi
it should. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this

[algogeeks] Bugs in a program

2011-07-31 Thread Puneet Gautam
What is meant by 'priority' and 'severity' of a bug..? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to

Re: [algogeeks] Re: Direct - i ques

2011-07-31 Thread Abhishek Gupta
@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.comwrote: hw cn u ensure that the elements are

Re: [algogeeks] Re: C doubt

2011-07-31 Thread Nikhil Gupta
If the function takes in an int argument, then is it modified to int (*func[N]) (int); ? On Sun, Jul 31, 2011 at 2:56 PM, ankit sambyal ankitsamb...@gmail.comwrote: yup its correct... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To

[algogeeks] Termination

2011-07-31 Thread Puneet Gautam
Is it possible to terminate this code(except break) while it is executing..? For what eof will this terminate..? #includestdio.h main(int argc,char *argv[]) {int c; while((c=getchar())!=EOF) { putchar(c); } } Reply fast... -- You received this

Re: [algogeeks] Re: C doubt

2011-07-31 Thread Abhishek Gupta
@Nikhil yes. On Sun, Jul 31, 2011 at 3:02 PM, Nikhil Gupta nikhilgupta2...@gmail.comwrote: If the function takes in an int argument, then is it modified to int (*func[N]) (int); ? On Sun, Jul 31, 2011 at 2:56 PM, ankit sambyal ankitsamb...@gmail.comwrote: yup its correct... -- You

[algogeeks] pointers

2011-07-31 Thread Puneet Gautam
What are smart pointers and what is the concept of pointer to void..? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to

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

Re: [algogeeks] Termination

2011-07-31 Thread Abhishek Gupta
compiler : gcc, OS : Fedora 15 I use ctrl + d to put EOF in files. you can verify it through this code #includestdio.h int main(int argc,char *argv[]) {int c; while((c=getchar())!=EOF) { putchar(c); } if(c==EOF) printf(EOF Break); return 0;

[algogeeks] random generation

2011-07-31 Thread Puneet Gautam
Can we write a code to generate random numbers without using rand function..? Pls help me on 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

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

Re: [algogeeks] Termination

2011-07-31 Thread Puneet Gautam
Is the eof different for different OS's..? On 7/31/11, Abhishek Gupta gupta.abh...@gmail.com wrote: compiler : gcc, OS : Fedora 15 I use ctrl + d to put EOF in files. you can verify it through this code #includestdio.h int main(int argc,char *argv[]) {int c;

Re: [algogeeks] Convert number to negative base

2011-07-31 Thread saurabh singh
itoa is not standard.. On Sun, Jul 31, 2011 at 3:01 PM, saurabh modi saurabhmodi102...@gmail.comwrote: it should. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To

Re: [algogeeks] Re: FB intern

2011-07-31 Thread saurabh singh
yup you are right.prakash try some cases and you will get why its necessary. (Yup i agree can be written in an if else way but i like it this way better) On Sun, Jul 31, 2011 at 2:08 PM, priyanka raju priyark...@gmail.com wrote: tats bcos... if it is a^21... it will be

Re: [algogeeks] Termination

2011-07-31 Thread Abhishek Gupta
I am only using linux. google it. it must be some ctrl + any key sequence On Sun, Jul 31, 2011 at 3:12 PM, Puneet Gautam puneet.nsi...@gmail.comwrote: ctrl+D doesnt work on dev , os windows 7... On 7/31/11, Puneet Gautam puneet.nsi...@gmail.com wrote: Is the eof different for different

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

Re: [algogeeks] random generation

2011-07-31 Thread Someshwar Chandrasekaran
On Sun, Jul 31, 2011 at 3:09 PM, Puneet Gautam puneet.nsi...@gmail.com wrote: Can we write a code to generate random numbers without using rand function..? Pls help me on this!! How about operating on some garbage value? Regards, B.C.Someshwar -- 'Talk sense to a fool and he calls you

Re: [algogeeks] Re: Direct - i ques

2011-07-31 Thread Abhishek Gupta
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.comwrote: the

Re: [algogeeks] Convert number to negative base

2011-07-31 Thread saurabh modi
yeah,only some compilers support 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

Re: [algogeeks] Tug of War

2011-07-31 Thread saurabh singh
Now its NP:) On Sun, Jul 31, 2011 at 2:24 PM, Shubham Maheshwari shubham@gmail.comwrote: wat if you had to divide the array in 'n' groups ... and the difference in the number of members in any 2 groups should not be more than '1'. the difference between their cumulative strengths is

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

Re: [algogeeks] Oracle interview questions

2011-07-31 Thread Ravinder Kumar
Plz tell about the type of questions asked by individual profiles . -- *With Regards :* Ravinder Kumar B.Tech Final Year Computer Science and Engineering MNNIT Allahabad -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this

Re: [algogeeks] Boundary of buildings

2011-07-31 Thread Ravinder Kumar
Can you explain the question more ?? -- *With Regards :* Ravinder Kumar B.Tech Final Year Computer Science and Engineering 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

Re: [algogeeks]

2011-07-31 Thread rajeev bharshetty
#includestdio.h int main() { int i,j,n; printf(\n Enter the value of n); scanf(%d,n); for(i=1;i=n;i++) { for(j=1;j=n-i;j++) printf( ); for(j=1;j=i;j++) printf(*); printf(\n); } for(i=1;i=n;i++) { for(j=1;j=i;j++) printf( ); for(j=1;j=n-i;j++) printf(*);

Re: [algogeeks] Termination

2011-07-31 Thread Shashank Nayak
ctrl+z for win On Sun, Jul 31, 2011 at 3:18 PM, Abhishek Gupta gupta.abh...@gmail.comwrote: I am only using linux. google it. it must be some ctrl + any key sequence On Sun, Jul 31, 2011 at 3:12 PM, Puneet Gautam puneet.nsi...@gmail.comwrote: ctrl+D doesnt work on dev , os windows 7...

Re: [algogeeks]

2011-07-31 Thread rajeev bharshetty
a Slight change to the previous program Here it goes #includestdio.h int main() { int i,j,n; printf(\n Enter the value of n); scanf(%d,n); for(i=1;i=n;i++) { for(j=1;j=n-i;j++) printf( ); for(j=1;j=i;j++) printf( *); printf(\n); } for(i=1;i=n;i++) { for(j=1;j=i;j++)

Re: [algogeeks] random generation

2011-07-31 Thread rajeev bharshetty
*#includestdio.h* * * *int main()* *{* * * *int x,a,b,i,n;* *printf(\n Enter the value of n);* *scanf(%d,n);* *printf(\n Enter Psoitive integer a);* *scanf(%d,a);* *printf(\n Enter the positisve integer b);* *scanf(%d,b);* *for(i=1;i=15;i++)* *{* * n= (a*n + b);* * printf(%d\n,n);* *}* *return 0;*

Re: [algogeeks] Re: Direct - i ques

2011-07-31 Thread Amol Sharma
here is what i think should be done to do thees operations in O(1)it is quite popular interview question.. i am using two stacks one stack arr[] in which elements in the elements will be pushed as they are normally done in a stack maintain another stack min[]whenever you insert an element

Re: [algogeeks] Re: Direct - i ques

2011-07-31 Thread Ravinder Kumar
Guys the real question is : Design a data structure which support following operation 1. insertion of an arbitrary element 2. removing the oldest element 3. Accessing min element -- *With Regards :* Ravinder Kumar B.Tech Final Year Computer Science and Engineering MNNIT Allahabad -- You

[algogeeks] Any help on bits?

2011-07-31 Thread Nikhil Gupta
Given two integers A B. Determine how many bits required to convert A to B. Write a function int BitSwapReqd(int A, int B); -- 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

Re: [algogeeks] Any help on bits?

2011-07-31 Thread prateek gupta
C= A^B then count number of bits set in C. On Sun, Jul 31, 2011 at 5:52 PM, Nikhil Gupta nikhilgupta2...@gmail.comwrote: Given two integers A B. Determine how many bits required to convert A to B. Write a function int BitSwapReqd(int A, int B); -- Nikhil Gupta -- You received this

Re: [algogeeks] Re: FB intern

2011-07-31 Thread Prakash D
@priyanka : thank you On Sun, Jul 31, 2011 at 3:17 PM, saurabh singh saurab...@gmail.com wrote: yup you are right.prakash try some cases and you will get why its necessary. (Yup i agree can be written in an if else way but i like it this way better) On Sun, Jul 31, 2011 at 2:08 PM,

Re: [algogeeks] FB intern

2011-07-31 Thread vijay goswami
int mypow(int x,int m) { if(m==0) return 1; if(m==1) return x; return mypow(x,ceil((float)m/2))*mypow(x,m/2); } On Sat, Jul 30, 2011 at 1:02 PM, arvind kumar arvindk...@gmail.com wrote: Find the least time complexity algorithm(most efficient algo) to find x^m(x to

Re: [algogeeks] Convert number to negative base

2011-07-31 Thread Amol Sharma
@saurabhsingh --- i don't understand python at the moment..can u code the same in c/c++ it would be very kind of you if you do it. or at least explain how are you proceeding... -- Amol Sharma Third Year Student Computer Science and Engineering MNNIT Allahabad On Sun, Jul 31, 2011 at

[algogeeks] max product of a subarray

2011-07-31 Thread nivedita arora
given an array containing +ve n -ve numbers , can someone give efficient algo to find the max cont subarray product. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To

Re: [algogeeks] Any help on bits?

2011-07-31 Thread Abhishek Gupta
int BitSwap(int A,int B) { int num=A^B; int count=0; while(num!=0) { num=num(num-1); count++; } return count; } this will run in O(m) where m is no. of ON bits (1's). is there any other optimal solution for finding no. of 1's in a number? On Sun, Jul 31, 2011 at

Re: [algogeeks] Bugs in a program

2011-07-31 Thread rajeev bharshetty
http://www.softwaretestinghelp.com/priority-and-severity/ On Sun, Jul 31, 2011 at 3:02 PM, Puneet Gautam puneet.nsi...@gmail.comwrote: What is meant by 'priority' and 'severity' of a bug..? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group.

Re: [algogeeks] pointers

2011-07-31 Thread aditi garg
http://ootips.org/yonat/4dev/smart-pointers.html Dis cud be helpful fr smart pointers On Sun, Jul 31, 2011 at 3:06 PM, Puneet Gautam puneet.nsi...@gmail.comwrote: What are smart pointers and what is the concept of pointer to void..? -- You received this message because you are subscribed

Re: [algogeeks] Any help on bits?

2011-07-31 Thread Surya Prakash
can any one please explain me the question clearly with an examplei'm not geting it! thanx 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

Re: [algogeeks] Any help on bits?

2011-07-31 Thread Amol Sharma
compare bits of the number one by one and and count how many are different print the count.. correct if i am wrong !! -- Amol Sharma Third Year Student Computer Science and Engineering MNNIT Allahabad On Sun, Jul 31, 2011 at 6:29 PM, Surya Prakash suryaprakash...@gmail.comwrote: can

Re: [algogeeks] Convert number to negative base

2011-07-31 Thread saurabh singh
I had put comments for the same...The code coming as soon as I reaches my laptop. Do the same as u will do for converting for binary...except divide by -2 each time and donr let the remainder become -ve at any time take the higher integer, On Sun, Jul 31, 2011 at 6:13 PM, Amol Sharma

Re: [algogeeks] Any help on bits?

2011-07-31 Thread Surya Prakash
we can just apply xor operation rightit's more easier!! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to

Re: [algogeeks]

2011-07-31 Thread aditi garg
http://ideone.com/9Txzo U cannot use %d when trying to print address \dey dont fall in range...and iu have modified it...u can chk the output.. i think ull be able to interpret the results...lemme knw if u have any doubt... On Sun, Jul 31, 2011 at 3:18 PM, Shubham Maheshwari

Re: [algogeeks] Any help on bits?

2011-07-31 Thread Nikhil Gupta
@Surya, ^ operator mean XOR operation. On Sun, Jul 31, 2011 at 6:41 PM, Surya Prakash suryaprakash...@gmail.comwrote: we can just apply xor operation rightit's more easier!! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to

Re: [algogeeks]

2011-07-31 Thread aditi garg
This is anothr prog that i ran... http://ideone.com/Kw9xl On Sun, Jul 31, 2011 at 6:43 PM, aditi garg aditi.garg.6...@gmail.comwrote: http://ideone.com/9Txzo U cannot use %d when trying to print address \dey dont fall in range...and iu have modified it...u can chk the output.. i think ull be

Re: [algogeeks] Odd one out

2011-07-31 Thread *$*
Q1-Construct a binary tree , in such a way that if element occured for the first time , insert into tree , if occurs at second time , remove from the list. As all elements except the one need to find are even , at the end of the list , all the tree will contain only one element. Q2- Construct a

Re: [algogeeks] Any help on bits?

2011-07-31 Thread Amol Sharma
yupxor would do the required task eaisly !! -- Amol Sharma Third Year Student Computer Science and Engineering MNNIT Allahabad On Sun, Jul 31, 2011 at 6:42 PM, Nikhil Gupta nikhilgupta2...@gmail.comwrote: @Surya, ^ operator mean XOR operation. On Sun, Jul 31, 2011 at 6:41 PM, Surya

Re: [algogeeks] Convert number to negative base

2011-07-31 Thread saurabh modi
you can read up the http://en.wikipedia.org/wiki/Negative_base#Calculationpart on the wiki page http://en.wikipedia.org/wiki/Negative_base its explained quite effectively. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group,

Re: [algogeeks] Re: adobe written round que

2011-07-31 Thread Ankit Minglani
yeah if it was a divisibility test then the question would have been too trivial .. the last digit after doing itoa will be the remainder . On Sat, Jul 30, 2011 at 11:52 AM, nivedita arora vivaciousnived...@gmail.com wrote: i think solution of ankit is right ! sorry even i forgot tht que ws

[algogeeks] Pointer

2011-07-31 Thread Nikhil Gupta
How to swap two pointers without using a temporary pointer ? -- 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

Re: [algogeeks] Pointer

2011-07-31 Thread pandharinath gorde
use xor ing for the same On Sun, Jul 31, 2011 at 7:15 PM, Nikhil Gupta nikhilgupta2...@gmail.comwrote: How to swap two pointers without using a temporary pointer ? -- Nikhil Gupta Senior Co-ordinator, Publicity CSI, NSIT Students' Branch NSIT, New Delhi, India -- You received this

Re: [algogeeks] Re: Novell - Puzzle

2011-07-31 Thread vijay goswami
the answer is 144 she-calves..the qn asks for calves, not cows and calves..in all there are 233 cows n calves where there are 144 calves n 89 cows On Sun, Jul 31, 2011 at 2:02 PM, Shubham Maheshwari shubham@gmail.comwrote: for the cows ques ... you all are forgetting to add the orginal

Re: [algogeeks] Pointer

2011-07-31 Thread rajeev bharshetty
*#includestdio.h* *int main()* *{* *int i=10;* *int j=20;* *int *a,*b;* *a =i;* *b=j;* *printf(before%d%d\n,*a,*b);* **a^=*b;* **b^=*a;* **a^=*b;* *printf(after%d%d,*a,*b);* *return 0;* *}* * * *This swaps pointers * On Sun, Jul 31, 2011 at 7:15 PM, Nikhil Gupta

Re: [algogeeks] Pointer

2011-07-31 Thread Nikhil Gupta
Whats the logic behind **a^=*b;* **b^=*a;* **a^=*b;* ?? On Sun, Jul 31, 2011 at 7:19 PM, rajeev bharshetty rajeevr...@gmail.comwrote: *#includestdio.h* *int main()* *{* *int i=10;* *int j=20;* *int *a,*b;* *a =i;* *b=j;* *printf(before%d%d\n,*a,*b);* **a^=*b;* **b^=*a;* **a^=*b;*

[algogeeks] Fwd: how 2 solve.........

2011-07-31 Thread prabhu J
-- Forwarded message -- From: Harish Ravichandran chillwithh...@gmail.com Date: Sun, Jul 31, 2011 at 4:23 PM Subject: how 2 solve. To: mitcse08i...@googlegroups.com, mit_cod...@googlegroups.com, algogeeksforge...@googlegroups.com In a chessboard the initial and final

Re: [algogeeks] Pointer

2011-07-31 Thread Nikhil Gupta
http://ideone.com/YHxVe @Rajeev, check this. On Sun, Jul 31, 2011 at 7:28 PM, Nikhil Gupta nikhilgupta2...@gmail.comwrote: Whats the logic behind **a^=*b;* **b^=*a;* **a^=*b;* ?? On Sun, Jul 31, 2011 at 7:19 PM, rajeev bharshetty rajeevr...@gmail.comwrote: *#includestdio.h* *int

Re: [algogeeks] Pointer

2011-07-31 Thread Surya Prakash
suppose if we want to swap 3 and 5 *a=3 *b=5 then, 1st xoring *a and *b and copying back to *a *a=011 *b=101 *a=110 2nd-- *b^=^a --- *b=101

Re: [algogeeks] Convert number to negative base

2011-07-31 Thread saurabh singh
The c code as amol had suggested. http://www.ideone.com/GP7O8 On Sun, Jul 31, 2011 at 6:55 PM, saurabh modi saurabhmodi102...@gmail.comwrote: you can read up the http://en.wikipedia.org/wiki/Negative_base#Calculationpart on the wiki page http://en.wikipedia.org/wiki/Negative_base its

  1   2   >