Thread: ap comp sci
View Single Post
  #11   Spotlight this post!  
Unread 12-05-2002, 17:26
srawls's Avatar
srawls srawls is offline
Registered User
#0122 (Nasa Knights)
 
Join Date: Dec 2001
Location: Yorktown
Posts: 507
srawls is an unknown quantity at this point
Send a message via AIM to srawls
hmm ... from memory: (i'm shortening function name to f)
Code:
apstring f (apstring *letter, Tree* T, apstring *path_so_far) {
  apstring temp;
  if (T->Left == NULL) { //T is a leaf 
    if (T->data == letter)  
      return path_so_far;
    return "";
  }

  temp = f(letter,T->left,path_so_far + "0");
  if (temp == "")
    return f(letter,T->right,path_so_far + "1");
  return temp;
}
Stephen
Reply With Quote