第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

C語(yǔ)言二叉查找樹

C語(yǔ)言二叉查找樹

C語(yǔ)言二叉查找樹問題,在?return searchBST( T->rchild, val, f, p); 處出錯(cuò),求教出錯(cuò)原理,這里應(yīng)該涉及了雙重指針的問題,我理不清。#include <stdio.h>#include <malloc.h>#define OK 1#define TRUE 1#define ERROR -1#define FALSE 0typedef int ElemType;typedef struct Node{? ? ElemType data;? ? struct Node *lchild,*rchild;}NODE,*PNODE;//prompt error info and exit.void errorInfo(char str[]){? ? printf("%s\n",str);? ? exit(-1);}//prompt error if there is an error in locating memoryvoid mallocErr(PNODE p){? ? if(NULL==p)? ? ? ? errorInfo("Error in locating memory.");}//search binary sort treeint searchBST(PNODE T,int val,PNODE *f,PNODE *p){? ? if(!T)? ? {? ? ? ? *p = *f;? ? ? ? return FALSE;? ? }? ? else if(val == T->data)? ? {? ? ? ? *p = T;? ? ? ? return TRUE;? ? }else if(val < T->data)? ? {? ? ? ? printf("run this code 52\n");? ? ? ? *f = T;? ? ? ? return searchBST(T->lchild,val,f,p);? ? }else? ? {? ? ? ? printf("run this code 56\n");? ? ? ? *f = T;? ? ? ? printf("run this code 58\n");? ? ? ? printf("T->data : %d \n",T->data);? ? ? ? //運(yùn)行到此處出錯(cuò)? ? ? ? return searchBST( T->rchild, val, f, p);? ? }}int insertBST(PNODE *T,int val){? ? PNODE p = NULL, s = NULL,f = NULL;? ? int res = 0;? ? res = searchBST(*T,val,&f,&p);? ? if(!res) //val does not exist in the array.? ? {? ? ? ? s = (PNODE)malloc(sizeof(NODE));? ? ? ? mallocErr(s);? ? ? ? s->data = val;? ? ? ? if(!p) //p is null? ? ? ? {? ? ? ? ? ? printf("run this code 75\n");? ? ? ? ? ? printf("Create Tree with val:%d\n",val);? ? ? ? ? ? *T = s;? ? ? ? }else if(val < p->data)? ? ? ? {? ? ? ? ? ? printf("run this code 79\n");? ? ? ? ? ? printf("Insert Key To Tree(left):%d\n",val);? ? ? ? ? ? p->lchild = s;? ? ? ? }else? ? ? ? {? ? ? ? ? ? printf("run this code 84\n");? ? ? ? ? ? printf("Insert Key To Tree(right):%d\n",val);? ? ? ? ? ? p->rchild = s;? ? ? ? }? ? ? ? return TRUE;? ? }else ? //val already exists in the array.? ? {? ? ? ? return FALSE;? ? }}int main(){? ? PNODE T = NULL, p = NULL;? ? insertBST(&T,100);? ? insertBST(&T,199);? ? return 0;}
查看完整描述

1 回答

?
SapereAudor

TA貢獻(xiàn)22條經(jīng)驗(yàn) 獲得超11個(gè)贊

建議你直接問老師,然后再自己整理一遍。

查看完整回答
1 反對(duì) 回復(fù) 2017-10-09
  • 1 回答
  • 0 關(guān)注
  • 1871 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)