freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

數(shù)據(jù)結(jié)構(gòu)第一版習題參考答案-資料下載頁

2025-06-22 17:06本頁面
  

【正文】 preorder(rootrchild)。 break。 case 10: if(isempty(root)) printf(\nTree is empty!)。 else printf(\nTree is not empty)。 break。 case 11: printf(\nSum of leaves is:%d,Leaf_rec(root))。break。 case 12: printf(\nAfter swap,tree is: )。 swap(root)。 preorder(root)。 break。 case 13: if(isfull(root)==0) printf(Bintree is full!!\n)。 else printf(Bintree isn39。t full!!\n)。 break。 case 14: printf(please input the node :)。 fflush(stdin)。 temp14=getchar()。 if(parent(root,temp14)==NULL) printf(Not exist)。 else printf(the node39。s parent is %c,parent(root,temp14)data)。 break。 case 15: printf(Please input the node :)。 fflush(stdin)。 temp14=getchar()。 printf( length of the path is :%d,root_to_p(root,temp14))。 break。 case 16: printf(Please input first node :)。 fflush(stdin)。 temp161=getchar()。 printf(Please input second node :)。 fflush(stdin)。 temp162=getchar()。 printf(Common parent:)。 printf(%c,Ancestor(root,temp161,temp162))。 break。 default : printf(Sorry,error value!!!please retry!!!)。 } } getch()。}第八章 圖,試:(1)畫出此圖;(2)寫出從頂點A開始的DFS遍歷結(jié)果;(3)寫出從頂點A開始的BFS遍歷結(jié)果;解:(1)(2)ABCFEGD(3)ABCDFGE: ①ADBECGFIH ②ABDECFGIH ③DEABCFGIH ④DABECGFIH頂點VeVl活動elle關(guān)鍵活動V000a(01)000√V166a(02)022V245a(13)660√V31313a(23)451V42222a(25)451V52525a(34)13130√a(35)13152a(45)22220√,試寫出以下算法:(1)求一個頂點的度;(2)往圖中插入一個頂點;(3)往圖中插入一條邊;(4)刪去圖中某頂點;(5)刪去圖中某條邊;解:define m 20 /*預(yù)定義圖的最大頂點數(shù)*/define NULL 0include int visited[m]。typedef char datatype。 /*頂點信息數(shù)據(jù)類型*/typedef struct node{ /*邊表結(jié)點*/ int adjvex。 /*鄰接點*/ struct node *next。}edgenode。typedef struct vnode{ /*頭結(jié)點類型*/ datatype vertex。 /*頂點信息*/ edgenode *firstedge。 /*鄰接鏈表頭指針*/}vertexnode。typedef struct{ /*鄰接表類型*/ vertexnode adjlist[m]。 /*存放頭結(jié)點的順序表*/ int n,e。 /*圖的頂點數(shù)與邊數(shù)*/}adjgraph。 void createadjgraph(adjgraph *g)/*無向圖的鄰接表創(chuàng)建算法*/{ int i,j,k。 edgenode *s。 printf(Please input n and e:\n)。 scanf(%d,%d,amp。gn,amp。ge)。 /*輸入頂點數(shù)與邊數(shù)*/ getchar()。 printf(Please input %d vertex:\n,gn)。 for(i=0。ign。i++) { fflush(stdin)。 scanf(%c,amp。gadjlist[i].vertex)。 /*讀入頂點信息*/ gadjlist[i].firstedge=NULL。 /*邊表置為空表*/ } printf(Please input %d edges:\n,ge)。 for(k=0。kge。k++) /*循環(huán)e次建立邊表*/ { scanf(%d,%d,amp。i,amp。j)。 /*輸入無序?qū)Γ╥,j)*/ s=(edgenode *)malloc(sizeof(edgenode))。 sadjvex=j。 /*鄰接點序號為j*/ snext=gadjlist[i].firstedge。 gadjlist[i].firstedge=s。 /*將新結(jié)點*s插入頂點vi的邊表頭部*/ s=(edgenode *)malloc(sizeof(edgenode))。 sadjvex=i。 /*鄰接點序號為i*/ snext=gadjlist[j].firstedge。 gadjlist[j].firstedge=s。 /*將新結(jié)點*s插入頂點vj的邊表頭部*/ }} print(adjgraph *g)/*打印出鄰接表*/{ edgenode *temp。 int i。 printf(\nadjgraph :\n)。 for(i=0。ign。i++) { printf(V[%d]:%c,i,gadjlist[i].vertex)。 for(temp=gadjlist[i].firstedge。temp!=NULL。temp=tempnext) printf(%d,tempadjvex)。 printf(NULL\n)。 }}int depth(adjgraph *g,datatype a)/*.(1)求一個頂點的度*/{ int i,j。 edgenode *temp。 for(i=0。ign。i++) if(gadjlist[i].vertex==a) break。 if(i=gn) printf(\n%c not exist!!!,a)。 for(j=0,temp=gadjlist[i].firstedge。temp!=NULL。temp=tempnext,j++)。 return j。} void insert_node(adjgraph *g)/*.(2)往圖中插入一個頂點(插在尾部)*/{ datatype temp。 printf(Please input the node :)。 fflush(stdin)。 temp=getchar()。 gadjlist[gn].vertex=temp。 gadjlist[gn].firstedge=NULL。 gn++。} void insert_edge(adjgraph *g)/*(3)往圖中插入一條邊*/{ int i,j。 edgenode *s。 printf(\nPlease input the edge:\n)。 fflush(stdin)。 scanf(%d,%d,amp。i,amp。j)。 s=(edgenode *)malloc(sizeof(edgenode))。 sadjvex=j。 /*鄰接點序號為j*/ snext=gadjlist[i].firstedge。 gadjlist[i].firstedge=s。 /*將新結(jié)點*s插入頂點vi的邊表頭部*/ s=(edgenode *)malloc(sizeof(edgenode))。 sadjvex=i。 /*鄰接點序號為i*/ snext=gadjlist[j].firstedge。 gadjlist[j].firstedge=s。 /*將新結(jié)點*s插入頂點vj的邊表頭部*/ ge++。} void delete_vertex(adjgraph *g)/*刪除圖中某頂點*/{ edgenode *temp。 datatype a。 int h,i,j。 printf(\nPlease input the vertex you want delete:\n)。 fflush(stdin)。 a=getchar()。 for(h=0。hgn。h++) if(gadjlist[h].vertex==a) { gadjlist[h].vertex=39。\00139。 gadjlist[h].firstedge=NULL。 break。 } for(i=0。i=gn。i++) for(temp=gadjlist[i].firstedge。tempnext。temp=tempnext) { if(tempadjvex==h) gadjlist[i].firstedge=tempnext。 if(tempnextadjvex==h) tempnext=tempnextnext。 }} void delete_edge(adjgraph *g)/*刪去圖中某條邊*/{ edgenode *temp。 int i,j。 printf(\nPlease input the edge:\n)。 fflush(stdin)。 scanf(%d,%d,amp。i,amp。j)。 for(temp=gadjlist[i].firstedge。tempnext。temp=tempnext) if(tempnextadjvex==j) { tempnext=tempnextnext。 break。 } for(temp=gadjlist[j].firstedge。tempnext。temp=tempnext)
點擊復(fù)制文檔內(nèi)容
環(huán)評公示相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1