Searching other element in struct in Binary Search Tree in
来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/13 22:18:22
Searching other element in struct in Binary Search Tree in
i have already implemented whole code...the BST is sorted by ID.But what can i do to find the highest number of other element?
struct TNode {
int id;
char name[100];
float balance;
TNode * left;
TNode * right;
};
bool addCustomer (TNode ** root,char * name,int id,float bal){
if (*root == NULL){
TNode * newNode = (TNode*)malloc(sizeof (TNode));
if (newNode == NULL)
return false;
newNode->id = id;
strcpy (newNode->name,name);
newNode->balance=bal;
newNode->left = NULL;
newNode->right = NULL;
*root = newNode;
}else if ((*root)->id < id){
addCustomer (&((*root)->right),name,id,bal);
}else if ((*root)->id > id){
addCustomer (&((*root)->left),name,id,bal);
}
return true;
}
//add customer function sort the BST with ID
TNode * findCustomer(TNode * root,int id){
if (root == NULL){
return NULL;
}else{
if (root->id < id){
return (findCustomer (root->right,id));
}else{
if (root->id > id){
return (findCustomer (root->left,id));
}else{
return root;
}
}
}
}
TNode * findRichestCustomer(TNode * root){
//i want to find the node that have highest amount...what should i put in here?
}
these are my codes.i am just beginner in C language...
i don't know what should i write inside the findRichestCustomer function with just one parameter passed.
need help...
i have already implemented whole code...the BST is sorted by ID.But what can i do to find the highest number of other element?
struct TNode {
int id;
char name[100];
float balance;
TNode * left;
TNode * right;
};
bool addCustomer (TNode ** root,char * name,int id,float bal){
if (*root == NULL){
TNode * newNode = (TNode*)malloc(sizeof (TNode));
if (newNode == NULL)
return false;
newNode->id = id;
strcpy (newNode->name,name);
newNode->balance=bal;
newNode->left = NULL;
newNode->right = NULL;
*root = newNode;
}else if ((*root)->id < id){
addCustomer (&((*root)->right),name,id,bal);
}else if ((*root)->id > id){
addCustomer (&((*root)->left),name,id,bal);
}
return true;
}
//add customer function sort the BST with ID
TNode * findCustomer(TNode * root,int id){
if (root == NULL){
return NULL;
}else{
if (root->id < id){
return (findCustomer (root->right,id));
}else{
if (root->id > id){
return (findCustomer (root->left,id));
}else{
return root;
}
}
}
}
TNode * findRichestCustomer(TNode * root){
//i want to find the node that have highest amount...what should i put in here?
}
these are my codes.i am just beginner in C language...
i don't know what should i write inside the findRichestCustomer function with just one parameter passed.
need help...
Yes. All fingerprints are different. The law enforcement agencies use fingerprints to identify the real criminals. The fingerprints are also used in checking the identities of visitors, tourists, and employees.
Searching other element in struct in Binary Search Tree in
英语翻译set/binary search tree/priority queue(with values in asc
in search of searching for与in search of 有何区别?
search \in search of
英语翻译A binary tree(二叉树) is similar to a tree in which every n
in searching to do
Binary Search Tree的缩写是什么阿?
in search 与research
in one's search
in search of
in search of造句
(in favor of) (in search of) (in