二叉排序樹的基本操作的實現_第1頁
二叉排序樹的基本操作的實現_第2頁
二叉排序樹的基本操作的實現_第3頁
二叉排序樹的基本操作的實現_第4頁
二叉排序樹的基本操作的實現_第5頁
已閱讀5頁,還剩5頁未讀 繼續免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、participation in and contribution to the organizational accident investigation unit leadership, supervision of "four no" (the cause of the accident is not clear left off; those responsible for the accident and should be educated without education left off; responsible for the accidents did

2、 not address left off; do not take preventive measures did not miss) the implementation of the principle of completed accident statistics, analysis, reporting and evaluation comments; (F) to contribute to the safety recommendations or observations for the granting of recognition, reward; to have tho

3、se responsible for the accident, criticism and punishment recommendations or opinions; (VII) participation in engineering and project design review, construction team qualification and acceptance, and work relating to scientific research achievement appraisal. 23rd: safety supervisory personnel term

4、s of reference: (a) the right to enter production areas, construction sites, control rooms, control room to examine the security situation; (B) the right to prevent illegal operations, in violation of, acts in violation of production labor discipline; (C) the right to request the protection of the s

5、cene of the accident; the right to investigate the accident to any person within the company and extract raw data; right to take pictures of the accident scene, sound recordings, videos, etc; (D) survey of accident analysis and dealing with different opinions, reflect the right to deliver to the sup

6、ervisor or security oversight bodies; for violations of rules, procedures, hide or impede the investigation of the accident is entitled to reflect corrected or leapfrog. The fifth Festival rules and regulations article 24th: units of the company to the State and relevant safety regulations issued by

7、 the superior, standards, regulations, procedures, systems, accident prevention measures must be strictly implemented. Units may formulate rules in practice in the follow-up or supplementary regulations, but shall not be in conflict with higher provisions, shall not be less than the higher standards

8、 required. 25th: units of the company should establish a sound system to ensure safety of the procedure, as follows: (a) according to the regulation, issued by the superior system, technical measures against accidents and equipment manufacturer's manual, operation procedures for enterprises of v

9、arious kinds of equipment, systems, approved by the Chief Executive; (B) issued under the parent's maintenance procedures and regulations, development of enterprise maintenance management systems; according to the canonical description technical regulations and equipment manufacturing, productio

10、n of primary and secondary equipment maintenance procedures and quality standards, by the General Engineering .、Measures to prevent accidents when you need to modify the procedures of the enterprise, should be to supplement or to amend the relevant provisions of regulations, written notice to the pe

11、rsons concerned; (B) procedures should be carried out once a year to review, revise, and notify the person in writing; does not need to be revised, should also issue a review and the signature of the individual "can continue their" written notice concerned personnel; (C) field procedures o

12、nce every 3-5 years a comprehensive二叉排序樹的根本操作的實現revision, approved and issued. Field practice for additions or changes, should strictly carry out the approval process. 27th: the Corporation's regular publication list of point system in force; Enterprise published annually a list of the unit'

13、s current point system, and complete list of all procedures relating to the systems. 28th: companies working in other organizations, individuals must be executed in strict two votes (and operational), three systems (shift system, mobile inspection system, regular rotation of test equipment) and the

14、equipment defect management system; operation must strictly implement the system of safe construction and safe technology to give the low-down. If necessary, strictly implement the eight jobs, votes to ban homework. 29th: the operation records shall not be less than 12 months, the remaining long-ter

15、m preservation archives (not less than 8 years). Sixth joint anti-accident measures planned and security technology protection measures article 30th: carbon company must prepare annual accidents per year action plan technical protection measures and security schemes. 31st: carbon annual anti-acciden

16、t measures planned to voice security technology protection measures planned by the company's leading organization, production and technical departments, safety supervision departments participate in the development.Article 32nd anti-accident measures plan should be based on national and superior

17、s issued accident prevention measures, need to address significant deficiencies, and improve equipment reliability improvement measures as well as the accident prevention measures of the unit system. Anti-accident measures plan should be included in the maintenance or reconstruction plans, special e

18、xpenses and establish account for security costs. Article 33rd: security technology protection measures should be based on country, industry, standards issued by the group in order to "scientific development, people-oriented" as the starting point, reduce employee stress, improve working c

19、onditions and prevent personal injury accidents, prevention of occupational diseases, promoting the standardization of safety facilities, improve the level of fire protection and other aspects of the preparation. Project safe construction measures of construction should be in accordance with the spe

20、cific circumstances of the project, operation methods, construction machines, industrial hygiene, the environment and other aspects of the preparation. Article 34th: safety, security, risk analysis, supervision, management, reliability analysis, the result should be the formulation of anti-accident

21、measures planned an important basis of technical protection measures and security schemes. Emergency plan for flood, earthquake, Typhoon and other required items, can be used as a basis for designing and updating of anti-accident measures plan. 35th: carbon companies should prioritize anti-accident

22、measures planned, security technology protection measures required funds. Security technology protection measures required funds extracted from security costs each year, special use. Article 36th: safety supervision Department is responsible for the supervision of anti-accident一 設計要求1. 問題描述 從磁盤讀入一組數

23、據,建立二叉排序樹并對其進行查找、遍歷、插入、刪除等根本操作。2. 需求分析建立二叉排序樹并對其進行查找,包括成功和不成功兩種情況。二 概要設計為了實現需求分析中的功能,可以從以下3方面著手設計。1. 主界面設計為了方便對二叉排序樹的根本操作,設計一個包含多個菜單項選擇項的主控制子程序以實現二叉排序樹的各項功能。本系統的主控制菜單運行界面如圖1所示。圖1二叉排序樹的根本操作的主菜單2. 存儲結構的設計本程序主要采二叉樹結構類型來表示二叉排序樹。其中二叉樹節點由1個表示關鍵字的分量組成,還有指向該左孩子和右孩子的指針。3. 系統功能設計本程序設置了5個子功能菜單,其設計如下。1) 建立二叉排序樹

24、。根據系統提示,輸入節點的關鍵字,并以0作為結束的標識符。該功能由Bstree Create()函數實現。2) 插入二叉排序新的節點信息。每次只能夠插入一個節點信息,如果該節點已經存在,那么不插入。該功能由Bstree Insert(y)函數實現。3) 查詢二叉排序樹的信息。每次進行查詢,成功那么顯示“查詢到該節點,不成功那么“顯示查詢不到該節點“該功能由Bstree Search()函數實現。4) 刪除二叉排序樹的節點信息。可以對二叉排序樹中不需要的節點進行刪除,刪除的方式是輸入關鍵字,查詢到該節點后刪除。該功能由Bstree Delete()函數實現。 5) 遍歷二叉排序樹。遍歷二叉排序樹

25、可以顯示該二叉排序樹的全部節點信息。該功能由void Traverse()實現。三 模塊設計1. 模塊設計本程序包含兩個模塊:主程序模塊和二叉排序樹操作模塊。其調用關系如圖2主程序模塊二叉排序樹操作模塊 圖2模塊調用示意圖2. 系統子程序及其功能設計本系統共設計了5個子程序,個程序的的函數名及其功能說明如下:1) Bstree Create(); /創立二叉排序樹2) Bstree Insert(Bstree tree,int key); /插入3) Bstree Search(Bstree tree,int key); /查找4) void Traverse(Bstree tree); /遍

26、歷5) Bstree Delete(Bstree tree,int key); /刪除信息3. 函數主要的調用關系圖本系統9個子程序見的主要調用關系圖3.Main()Main()Insert()Search( )Traverse ()Delete ()四 詳細設計1. 數據類型定義本系統采用二叉樹結構存儲節點信息,節點定義如下: typedef struct Bstnodeint key;struct Bstnode *lchild,*rchild;Bstnode,* Bstree;2. 主要子程序的詳細設計1) 二叉排序樹的創立函數,主要用來建立二叉排序樹。 Bstree Create()

27、int key;Bstree tree=NULL; /初始化空樹scanf("%d",&key); while(key!=0)tree=Insert(tree,key); /逐個插入節點scanf("%d",&key);return tree;2) 二叉排序插入函數如下: Bstree Insert(Bstree tree,int key)Bstree p=tree;Bstree s,f;while (p!=NULL)f=p; if(key=p->key) return tree; if(key<p->key) p=p-

28、>lchild; else p=p->rchild;s=(Bstree)malloc(sizeof(Bstnode);s->key=key;s->lchild=NULL;s->rchild=NULL;if(tree=NULL) return s; /新節點為二叉排序樹的根if(key<f->key) f->lchild=s; else f->rchild=s; return tree; 3) 二叉排序樹查詢函數如下: Bstree Search(Bstree tree,int key)Bstree p=tree; int flag=0; w

29、hile(p!=NULL) if(p->key=key) printf("查詢到該節點!");flag=1;return(p);break;if (key<p->key) p=p->lchild; else p=p->rchild; if(flag=0)printf("查詢不到關鍵字為%d的節點!",key);return NULL; 五 測試分析1. 二叉排序樹的建立首先進入主菜單,如圖1。在主菜單下,用戶根據菜單的選項輸入1,然后按照提示建立二叉排序樹,并以0未結束符。運行的結果如圖4. 圖4二叉排序樹的建立2. 遍歷二

30、叉樹的節點信息在主菜單下,用戶選擇4,可以打印出全部的節點信息。運行的結果如圖5. 圖5遍歷二叉排序樹3. 插入節點信息信息在主菜單下,用戶選擇2,可以插入一個新的節點信息。運行的結果如圖6.圖6插入新的節點4. 查詢二叉樹的節點信息在主菜單下,用戶選擇3,首先通過輸入關鍵字查詢相關信息。運行的結果如圖7. 圖7查詢節點信息5. 刪除二叉樹的節點在主菜單下,用戶選擇5,可以通過輸入要刪除的關鍵字來刪除該節點的全部信息。運行的結果如圖8. 圖8刪除二叉排序樹的節點 在主菜單下,用戶輸入6并回車,即退出“二叉樹根本操作程序。六 原程序清單#include<stdio.h>#includ

31、e<stdlib.h>#include<malloc.h>/*二叉排序樹的數據結構*/typedef struct Bstnodeint key;struct Bstnode *lchild,*rchild;Bstnode,* Bstree;Bstree Create(); /創立二叉排序樹Bstree Insert(Bstree tree,int key); /插入Bstree Search(Bstree tree,int key); /查找void Traverse(Bstree tree); /遍歷Bstree Delete(Bstree tree,int key

32、); /刪除/*創立二叉排序樹*/Bstree Create() int key;Bstree tree=NULL; /初始化空樹scanf("%d",&key); while(key!=0)tree=Insert(tree,key); /逐個插入節點scanf("%d",&key);return tree;/*插入*/ Bstree Insert(Bstree tree,int key)Bstree p=tree;Bstree s,f;while (p!=NULL)f=p; if(key=p->key) return tree;

33、if(key<p->key) p=p->lchild; else p=p->rchild;s=(Bstree)malloc(sizeof(Bstnode);s->key=key;s->lchild=NULL;s->rchild=NULL;if(tree=NULL) return s; /新節點為二叉排序樹的根if(key<f->key) f->lchild=s; else f->rchild=s; return tree;/*查找*/Bstree Search(Bstree tree,int key)Bstree p=tree;

34、 int flag=0; while(p!=NULL) if(p->key=key) printf("查詢到該節點!");flag=1;return(p);break;if (key<p->key) p=p->lchild; else p=p->rchild; if(flag=0)printf("查詢不到關鍵字為%d的節點!",key);return NULL; /*遍歷*/void Traverse(Bstree tree)if(tree) Traverse(tree->lchild); printf("%

35、4d",tree->key); Traverse(tree->rchild); /*刪除*/Bstree Delete(Bstree tree,int key)Bstree p=tree; Bstree f,s,q; f=NULL;while(p) /查找關鍵字為key的節點if(p->key=key) break; f=p; if(p->key>key) p=p->lchild;else p=p->rchild;if (p=NULL) return tree; if (p->lchild=NULL)|(p->rchild=NUL

36、L) if(f=NULL) if(p->lchild=NULL) tree=p->rchild;else tree=p->lchild;else if (p->lchild=NULL) if(f->lchild=p) f->lchild=p->rchild; else f->rchild=p->rchild; else if(f->lchild=p) f->lchild=p->lchild; else f->lchild=p->lchild; free(p);else q=p;s=p->lchild; while(s->rchild)q=s;s=s->rchild; if(q=p) q->lchild=s->lchild;p->key=s->key; free(s);return tree;/*/void main() system("color 1E");Bstree tree,p;int key1,key2,key3;int select,flag;printf("#n");printf("|

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論