Can you convert this coding into MIPS void Tree::Tree(char* name,char* desc,int level,char* parentName) { //find the parent Node* location = FindLoc(parentName, root); //the parent was found if(location) { int index = 0; while(location->child[index] && (index + 1) < child_max) ++index; if(!location->child[index]) { location->child[index] = new Node(); location = location->child[index]; location->data.SetName(name); location->data.SetDesc(desc); location->data.SetLevel(level); } } else cout<< "Parent not found!"<child[i]) { temp = FindLoc(parentName, root->child[i]); if(temp) return temp; } } else return temp; }
Can you convert this coding into MIPS
void Tree::Tree(char* name,char* desc,int level,char* parentName)
{
//find the parent
Node* location = FindLoc(parentName, root);
//the parent was found
if(location)
{
int index = 0;
while(location->child[index] && (index + 1) < child_max)
++index;
if(!location->child[index])
{
location->child[index] = new Node();
location = location->child[index];
location->data.SetName(name);
location->data.SetDesc(desc);
location->data.SetLevel(level);
}
}
else
cout<< "Parent not found!"<<endl;
}
//Finds the parent of the new child to be added to the tree
Tree::Node* Tree::FindLoc(char* parentName, Node* root)
{
Node* temp = NULL;
if(root)
{
for(int i = 0; i < child_max; ++i)
if(root->child[i])
{
temp = FindLoc(parentName, root->child[i]);
if(temp) return temp;
}
}
else return temp;
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps