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

正文內(nèi)容

[理學]第四章線性表(編輯修改稿)

2024-11-15 01:05 本頁面
 

【文章內(nèi)容簡介】 DT Node 3. 單鏈表基本操作算法 (1) Node類聲明: template class T class Node { private: Node T * next。 public: T data。 // 構(gòu)造函數(shù) Node ( const Tamp。 item , Node T * ptrnext = NULL)。 // 在當前結(jié)點之后插入指針 p 所指結(jié)點 void InsertAfter(Node T *p)。 // 刪除當前結(jié)點的后繼結(jié)點 Node T * DeleteAfter(void)。 // 返回指向當前結(jié)點的后繼結(jié)點的指針 Node T * NextNode(void) const。 }。 (2) Node類的實現(xiàn) ① 構(gòu)造函數(shù) template class T Node T :: Node(const Tamp。 item , Node T * ptrnext): data(item),next(ptrnext) { } ② 返回當前結(jié)點的 next 域的值 C++: template class T Node T * Node T :: nextNode(void) const { return next 。 } ADL: 算法 NextNode() NextNode1[取當前結(jié)點的下一個結(jié)點 ] p ?next(this). ▌ ③ 在當前結(jié)點之后插入結(jié)點 p //ADL描述 算法 InsertAfter( this , p ) IA1 [將當前結(jié)點的 next域值賦給 P的 next域 ] next( p) ? next( this) . IA2 [將 P賦給當前結(jié)點的 next域 ] next( this) ? p . ▌ … FAT HAT … this GAT p ④ 刪除當前結(jié)點的后繼結(jié)點 //ADL描述 算法 DeleteAfter( this . tempptr) DA1 [this的 next域值 = NULL? ] IF next( this) = NULL THEN tempptr ? NULL ELSE( tempptr ? next( this) . next( this) ? next( tempptr) ) . ▌ … FAT HAT … this GAT tempptr (3) 構(gòu)造鏈表 //ADL描述 ① 創(chuàng)建一個 data域值為 item,next 域值為 nextptr的結(jié)點。 算法 GetNode( item , nextptr . newNode) GN1 [為新結(jié)點申請空間 ] newNode ? AVAIL . GN2 [為結(jié)點諸域賦值 ] data( newNode) ? item. next( newNode) ? nextptr. ▌ item NewNode nextptr ② 在頭指針為 head 的鏈表中,插入一個 data 域為 item 的新結(jié)點作為該鏈表的表頭結(jié)點。 算法 InsertFront( head , item) IF1 [調(diào)用函數(shù) GetNode] GetNode( item, head. newNode) . IF2 [head指向新結(jié)點 ] head ? newNode. ▌ 表頭插入結(jié)點演示 HAT head GAT ∧ item newNode head head (4)遍歷鏈表 遍歷鏈表演示 算法 PrintList( head) //輸出頭指針為 head的鏈表 ,每輸出 5個元素換行 PL 1 [取表頭 , 計數(shù)器初始化 ] currptr ? head . count ? 0 . a c b head currptr ∧ PL 2 [遍歷并輸出鏈表結(jié)點的 data值 ] WHILE( currptr ≠ NULL) DO ( PRINT( data( currptr)) . count ? count + 1. IF( MOD( count, 5) = 0 ) THEN PRINT . currptr ? next( currptr) . ) ▌ a c b head currptr currptr currptr currptr ∧ (5)表尾插入結(jié)點 表尾插入 結(jié)點演示 算法 InsertRear( head , item ) // 在頭指針為 head的鏈表尾部插入 data域值 // 為 item的結(jié)點; IR1 [取頭指針 ] currptr ? head . a c b head currptr ∧ IR2 [currptr = NULL? ] IF currptr = NULL THEN InsertFront( head , item) head=NULL currptr=NULL head item head NULL IR2 [currptr = NULL? ] IF currptr = NULL THEN InsertFront( head , item) ELSE ( WHILE( nex
點擊復(fù)制文檔內(nèi)容
教學課件相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號-1