[algogeeks] Can de-reference operator * be overloaded?

2010-07-23 Thread Tech Id
Is it possible to overload the operator * used to dereference
pointers?
Can you give a practical example of the same?

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



[algogeeks] function

2010-07-23 Thread tarak mehta
fun(){
int fun1(void);
...
}
what is the data type of fun1() here??

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



[algogeeks] Re: function

2010-07-23 Thread Tech Id
Its a pointer to a function whose input is void and which returns an
int.
If fun1 declared outside fun(), would there be any change?


On Jul 23, 7:13 pm, tarak mehta tarakmeht...@gmail.com wrote:
 fun(){
 int fun1(void);
 ...}

 what is the data type of fun1() here??

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



[algogeeks] unset leftmost bit

2010-07-23 Thread Tech Id
Write a C function that unsets the leftmost set bit of an integer in
less than order (n)
n here is 32 (bit-length of an integer)
Hint: do some bit-tricks

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



Re: [algogeeks] Can de-reference operator * be overloaded?

2010-07-23 Thread Amit Mittal
yes...all smart pointers does that.

On Fri, Jul 23, 2010 at 5:41 PM, Tech Id tech.login@gmail.com wrote:

 Is it possible to overload the operator * used to dereference
 pointers?
 Can you give a practical example of the same?

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



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



[algogeeks] Re: Get the number of pairs of “ones ” in a given integer. Eg: if the integer is 7 (binary: 011 1), then the number of pairs of ones is 2

2010-07-23 Thread Dave
Count the number of one bits in n  (n  1). Algorithms to count the
one-bits in an integer appear here frequently, and also are well
known.

Dave

On Jul 22, 2:09 pm, vijay auvija...@gmail.com wrote:
 Get the number of pairs of “ones” in a given integer. Eg: if the
 integer is 7 (binary: 0111), then the number of pairs of ones is 2

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



Re: [algogeeks] pointer and array

2010-07-23 Thread ravi gupta
On Sat, Jul 24, 2010 at 9:40 AM, tarak mehta tarakmeht...@gmail.com wrote:

 int arr[]={1,2,3,4};
 k=sizeof(arr)/sizeof(*arr);
 value of k=4;

 however


 void hell(int arr[]);
 main()
 {
int arr[]={1,2,3,4};
hell(arr);
 }
 void hell(int arr[])
 {
 printf(%d,sizeof(arr)/sizeof(*arr));
 }


 output of hell() is 1. why???

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

 When array is passed as an argument, only a pointer to the first element of
the array is passed. Therefore the parameter int arr[] in void hell(int
arr[]) is just a pointer, hence the result .
I hope it answers your query.

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



[algogeeks] Re: unset leftmost bit

2010-07-23 Thread Debajyoti Sarma
for(i=sizeof(int)*8-1;i=0;i--)
{
if((numberi)1)
{
number=number^(1i);
break;
}
}

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



[algogeeks] BST

2010-07-23 Thread Priyanka Chatterjee
Given a binary search tree of n nodes, find two nodes whose sum is equal to
a given number k in O(n) time and constant space.
(ignoring recursion stack space)

I have got O(nlogn) time , O(1) space  and O(n) time, O(n) space. Please
help me out with O(n) time and O(1) space.


-- 
Thanks  Regards,
Priyanka Chatterjee
Final Year Undergraduate Student,
Computer Science  Engineering,
National Institute Of Technology,Durgapur
India
http://priyanka-nit.blogspot.com/

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



[algogeeks] Re: BST

2010-07-23 Thread Priyanka Chatterjee
Given a binary search tree of n nodes, find two nodes whose sum is equal to
 a given number k in O(n) time and constant space.
 (ignoring recursion stack space)

 I have got O(nlogn) time , O(1) space  and O(n) time, O(n) space. Please
 help me out with O(n) time and O(1) space.


 --
 Thanks  Regards,
 Priyanka Chatterjee
 Final Year Undergraduate Student,
 Computer Science  Engineering,
 National Institute Of Technology,Durgapur
 India
 http://priyanka-nit.blogspot.com/


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