[algogeeks] Difference between assignment operator and copy constructor

2010-06-29 Thread Raj N
Hi, Can anyone tell me the difference between using an assignment operator and copy constructor ? sample s1; sample s2; s2=s1; sample s3(s2); -- 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] crazy

2010-06-29 Thread ankur aggarwal
i think it shud be 1/2.. i will try to prove it... On Mon, Jun 28, 2010 at 8:52 AM, sharad kumar sharad20073...@gmail.comwrote: Problem :- A line of 100 airline passengers is waiting to board a plane. They each hold a ticket to one of the 100 seats on that flight. (For convenience, let's say

Re: [algogeeks] crazy

2010-06-29 Thread sharad kumar
ya its 1/2 proof gvn in www.techinterview.org On Tue, Jun 29, 2010 at 12:37 PM, ankur aggarwal ankur.mast@gmail.comwrote: i think it shud be 1/2.. i will try to prove it... On Mon, Jun 28, 2010 at 8:52 AM, sharad kumar sharad20073...@gmail.comwrote: Problem :- A line of 100 airline

Re: [algogeeks] crazy

2010-06-29 Thread umesh kewat
1/100 On Tue, Jun 29, 2010 at 12:37 PM, ankur aggarwal ankur.mast@gmail.comwrote: i think it shud be 1/2.. i will try to prove it... On Mon, Jun 28, 2010 at 8:52 AM, sharad kumar sharad20073...@gmail.comwrote: Problem :- A line of 100 airline passengers is waiting to board a plane.

[algogeeks] addition using bitwise

2010-06-29 Thread shrinivas
hi friends i m new to this group, i found very interesting and useful discussion here this is code for adding two number without arithmetic operator int add(int a, int b) { do { a=a^b; b=(a^b)b; b=b1;

Re: [algogeeks] a bst

2010-06-29 Thread Raj N
I think it is NULL and we've to check for that condition, good that you mentioned On Tue, Jun 29, 2010 at 3:10 AM, Nivedita Rajani nivedita.raj...@gmail.comwrote: Small Doubt, As stated for Leaf Nodes Right and left pointer is not NULL, What about an internal node with only Left tree

Re: [algogeeks] Difference between assignment operator and copy constructor

2010-06-29 Thread Anand
http://www.codeguru.com/cpp/cpp/algorithms/general/article.php/c9585 On Tue, Jun 29, 2010 at 12:32 AM, Raj N rajn...@gmail.com wrote: Hi, Can anyone tell me the difference between using an assignment operator and copy constructor ? sample s1; sample s2; s2=s1; sample s3(s2); -- You

[algogeeks] Call a function before main() in C

2010-06-29 Thread Varma
Hi All, Is there any way to call our function before main() is called ? I know there is a way in C++ as below , but Is there a standard way in C ? #include iostream.h class CStatic { public: CStatic() { cout Before Main! endl; } ~CStatic() { cout After Main! endl; } }; CStatic cs;

[algogeeks] Re: Bitwise Operators

2010-06-29 Thread Dave
Are you asking how to subtract 1 without using bitwise operators? If so, just use subtraction. Dave On Jun 29, 10:32 am, Anand anandut2...@gmail.com wrote: @ Dave: is it possible to get the previous without using bitwise operator. On Mon, Jun 28, 2010 at 8:29 PM, Gene gene.ress...@gmail.com

Re: [algogeeks] Re: Bitwise Operators

2010-06-29 Thread Anand
Sorry. is it possible to get the previous number using bitwise operator and with out using arithematic operator On Tue, Jun 29, 2010 at 1:56 PM, Dave dave_and_da...@juno.com wrote: Are you asking how to subtract 1 without using bitwise operators? If so, just use subtraction. Dave On Jun

Re: [algogeeks] Project on finding an optimal route given a map.

2010-06-29 Thread Anand
@ Abhishek, Initially to start with let's take every Dept as Nodes and find the shortest route between them. if this works we can extend it further for other areas also. On Mon, Jun 28, 2010 at 10:31 AM, Abhishek Sharma jkabhishe...@gmail.comwrote: @senthil: thanks for the interest.. I did

[algogeeks] Re: Bitwise Operators

2010-06-29 Thread Gene
On Jun 29, 4:58 pm, Anand anandut2...@gmail.com wrote: Sorry. is it possible to get the previous number using bitwise operator and with out using arithematic operator On Tue, Jun 29, 2010 at 1:56 PM, Dave dave_and_da...@juno.com wrote: Are you asking how to subtract 1 without using bitwise

[algogeeks] Re: n ary tree symmetry

2010-06-29 Thread Gene
On Jun 27, 7:32 am, sharad kumar sharad20073...@gmail.com wrote: Algorithm to find if a tree is symmetric? (The tree is a generalized tree with as many child nodes as possible) Here's how to do it with a binary tree. Extension to an n-ary tree is straightforward. boolean is(a, b) { if (a ==

Re: [algogeeks] Re: Bitwise Operators

2010-06-29 Thread shrinivas yadav
@DAVE GANE hi friends can any one explain working of program , i hv seen this code many time but i don't now how it works can any one explain it.. thanks On 6/29/10, Anand anandut2...@gmail.com wrote: @ Dave: is it possible to get the previous without using bitwise operator. On Mon, Jun

[algogeeks] complete binary tree

2010-06-29 Thread sharad kumar
A *complete binary tree* is a binary tree in which every level, *except possibly the last*, is completely filled, and all nodes are as far left as possible write a code which check whether a given tree is complete or not -- You received this message because you are subscribed to the Google

Re: [algogeeks] addition using bitwise

2010-06-29 Thread Priyanka Chatterjee
On 29 June 2010 20:31, Priyanka Chatterjee dona.1...@gmail.com wrote: int add(int a, int b) { do { a=a^b;// sum without carry b=((a^b)b)1;// carry without addition } while(b);//when carry equal to 0 a contains the

Re: [algogeeks] addition using bitwise

2010-06-29 Thread Priyanka Chatterjee
int add(int a, int b) { do { a=a^b;// sum without carry b=((a^b)b)1;// carry without addition } while(b);//when carry equal to 0 a contains the sum return(a); } Explanation: We can add 2 no.s in the

[algogeeks] Re: sort 0's 1's and 2's

2010-06-29 Thread Gene
On Jun 29, 3:26 pm, sharad kumar sharad20073...@gmail.com wrote: how to sort an array containing 0's 1's and 2's in O(n)time and sorting technique must be inplace #define M 3 void sort(int *a, int n) { int i, j, c[M]; for (j = 0; j M; j++) c[j] = 0; for (i = 0; i n; i++) ++c[a[i]];