Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > using of * &

Reply
Thread Tools

using of * &

 
 
Burak
Guest
Posts: n/a
 
      12-04-2007
void DeleteNode(struct node * & node) {
if (node->left == NULL) {
struct node *temp = node;
node = node->right;
delete temp;
} else if (node->right == NULL) {
struct node *temp = node;
node = node->left;
delete temp;
} else {
// In-order predecessor (rightmost child of left subtree)
// Node has two children - get max of left subtree
struct node **temp = &node->left; // get left node of the
original node

// find the rightmost child of the subtree of the left node
while ((*temp)->right != NULL) {
temp = &(*temp)->right;
}

// copy the value from the in-order predecessor to the
original node
node->value = (*temp)->value;

// then delete the predecessor
DeleteNode(*temp);
}
}


i saw this function on wikipedia.
what does * & mean there(struct node * & node) ?

thanx Burak
 
Reply With Quote
 
 
 
 
vippstar@gmail.com
Guest
Posts: n/a
 
      12-04-2007
On Dec 4, 4:16 pm, Burak <burakdurmu...@gmail.com> wrote:
> void DeleteNode(struct node * & node) {
> <body>
>
> i saw this function on wikipedia.
> what does * & mean there(struct node * & node) ?


Nothing, it's invalid.
Wikipedia for that example says:
<http://en.wikipedia.org/wiki/Binary_search_tree#Deletion>
> Here is C++ sample code for a destructive version of deletion. (We assume the node to be deleted has already been located using search.)

 
Reply With Quote
 
 
 
 
pete
Guest
Posts: n/a
 
      12-04-2007
Burak wrote:
>
> void DeleteNode(struct node * & node) {


> delete temp;


> i saw this function on wikipedia.
> what does * & mean there(struct node * & node) ?


That's not C code.

--
pete
 
Reply With Quote
 
Richard Heathfield
Guest
Posts: n/a
 
      12-04-2007
Burak said:

> void DeleteNode(struct node * & node) {


<snip>

> i saw this function on wikipedia.
> what does * & mean there(struct node * & node) ?


It means either that the Wikipedia article, at the time you saw it, had
most recently been edited by someone who doesn't know C[1], or perhaps it
wasn't actually an article about C code. As far as the C language is
concerned, the code you have shown constitutes a syntax error requiring a
diagnostic message from your implementation. In other words, it's
meaningless.


[1] It wouldn't be the first time. Or the second. Or the third...

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
 
Reply With Quote
 
santosh
Guest
Posts: n/a
 
      12-04-2007
Burak wrote:

<snip code>

> i saw this function on wikipedia.
> what does * & mean there(struct node * & node) ?


As vippstar points out, the Wikipedia page clearly mentions that it is
C++ code. So why are you asking in <news:comp.lang.c> instead of
<news:comp.lang.c++>?

 
Reply With Quote
 
Paul Sinnett
Guest
Posts: n/a
 
      12-04-2007
Burak wrote:
> i saw this function on wikipedia.
> what does * & mean there(struct node * & node) ?


It's c++ and it means that node is a reference to a pointer to a node.
It's probably not a good idea to call the type and the variable by the
same name though.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Front Office and Back Office Upgrade =?Utf-8?B?SGFyZGlw?= Microsoft Certification 0 04-08-2006 01:19 PM
Microsoft Office Specialist Study Guide Office 2003 Edition Jimmy Clay Microsoft Certification 2 09-10-2004 12:27 PM
Java library to access Star Office/Open Office? Stan Accrington Java 1 05-13-2004 07:57 AM
Show 4 Records that occur more often...and how often they occur. Miguel Dias Moura ASP .Net 4 05-06-2004 03:40 PM
Office 97 to Office XP User guide upgrade Marc Microsoft Certification 0 04-14-2004 01:31 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57