473,322 Members | 1,540 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Help with BST trees that have been templatized

help with my search tree can anyone help me??
i am stuck


template <typename NodeType>
NodeType* CBSTree<NodeType>::Insert(NodeType *newItem,
NodeType *nodePtr)
{

// Base case
if(true == IsTreeEmpty())
{
nodePtr = new NodeType(newItem->m_value);
m_root = nodePtr;
return(m_root);
}else if(nodePtr == NULL)
{



// when I Get here it doesn't assign the address over to the other pointer??
// but i tried individually to put into the tree
// just assigning:
// nodePtr->m_right = new NodeType(newItem->value);
// if i do that it works
// would you please help i can't figure out what i am doing wrong??
//



nodePtr = new NodeType(newItem->m_value);
return(m_root);
}
else if(newItem->m_value < nodePtr->m_value)
{
// Search left
Insert(newItem,nodePtr);
}
else if(newItem->m_value > nodePtr->m_value)
{
// Search right
Insert(newItem,nodePtr->m_right);
}


}
Dec 7 '07 #1
0 865

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: ma740988 | last post by:
Consider the template member function that generates a random number within a range. #include <cstdlib> #include <ctime> #include <iostream> template<typename T> T Random(T bottom, T top) {
1
by: barnesc | last post by:
Hi again, Since my linear algebra library appears not to serve any practical need (I found cgkit, and that works better for me), I've gotten bored and went back to one of my other projects:...
3
by: ptrSriram | last post by:
Can someone help me with an algorithm to merge two binary search trees. One method I thought of was to flatten both the trees into sorted lists(inorder traversal),merge those two sorted lists,...
23
by: mark.moore | last post by:
I know this has been asked before, but I just can't find the answer in the sea of hits... How do you forward declare a class that is *not* paramaterized, but is based on a template class? ...
9
by: Tristán White | last post by:
Hi I am very new to PHP - actually, this is my second day at it, as I've only recently started a new job last week. We're a charity. I have a "No input file selected" problem. A Google search...
1
by: tavianator | last post by:
If I had a class with a templatized constructor, like this: class foo { public: template<typename T> foo(); };
3
by: gary.bernstein | last post by:
I want to call a singleton getInstance function to retrieve a templatized object without knowing what types were used to create the singleton object in the first call to getInstance. How can I do...
4
by: David | last post by:
Hi all, If I have an array with multiple entries that are the same. How can I split them up into separate arrays by this criteria? var myArry =...
2
by: mrstephengross | last post by:
Hi folks! I'm trying to create a function pointer to a templatized, static, overloaded member function. My class (Mgr) has two functions with the same name: "go". The first takes a T reference (T...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.