江苏大学数据结构上机实验报告(2)

2018-12-06 21:22

left=leaf(r->leftchild); right=leaf(r->rightchild); return left + right;

}

/* if (r->rightchild == NULL) count++; else

{ leaf(r->leftchild); leaf(r->rightchild); }*/

}

//return count;

}

void bintreelink::levelorder(bintreenode*r) { linkqueue*queue=NULL; bintreenode*p=NULL; if (r != NULL) queue->enquene(p->data); while (!queue->isempty())

{ queue->delquene(p->data); cout<data<<\ if (p->leftchild != NULL) { levelorder(p->leftchild); }

if (p->rightchild != NULL) { levelorder(p->rightchild); }

}

}

Linkqueue.h

#pragma once #include #include%using namespace std; class linkqueue {

protected:

node*front, *rear; public:

linkqueue(); ~linkqueue(); bool isempty(); void delquene(char e);

void enquene(char e);

};

Linkqueue.cpp

#include \

linkqueue::linkqueue() { front = rear = new node;

}

bool linkqueue::isempty() {

if (front == rear) return 0; else

return 1; }

void linkqueue::delquene(char e) { if (!isempty()) { node*p = front->next; e = p->data;

front->next = p->next; if (rear == p)

rear = front; delete p;

}

}

void linkqueue::enquene(char e) { node*p;

p = new node(e, NULL); if (p) {

rear->next = p;

}

rear = rear->next; } }


江苏大学数据结构上机实验报告(2).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:调研报告:关于全市职业教育发展和改革的调查研究

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: