数据结构课程设计报告java+哈夫曼树.docx

上传人:b****2 文档编号:2468469 上传时间:2022-10-29 格式:DOCX 页数:28 大小:628.47KB
下载 相关 举报
数据结构课程设计报告java+哈夫曼树.docx_第1页
第1页 / 共28页
数据结构课程设计报告java+哈夫曼树.docx_第2页
第2页 / 共28页
数据结构课程设计报告java+哈夫曼树.docx_第3页
第3页 / 共28页
数据结构课程设计报告java+哈夫曼树.docx_第4页
第4页 / 共28页
数据结构课程设计报告java+哈夫曼树.docx_第5页
第5页 / 共28页
点击查看更多>>
下载资源
资源描述

数据结构课程设计报告java+哈夫曼树.docx

《数据结构课程设计报告java+哈夫曼树.docx》由会员分享,可在线阅读,更多相关《数据结构课程设计报告java+哈夫曼树.docx(28页珍藏版)》请在冰豆网上搜索。

数据结构课程设计报告java+哈夫曼树.docx

数据结构课程设计报告java+哈夫曼树

 

计算机科学与技术学院

课程设计说明书

 

题目:

双向循环链表操作的实现

哈夫曼树

课程:

数据结构

院(部):

计算机科学与技术学院

专业:

班级:

学生姓名:

学号:

指导教师:

完成日期:

2016/12/29

山东建筑大学计算机科学与技术学院

课程设计任务书一

设计题目

双向循环链表操作的实现

已知技术参数和设计要求

1.建立一个空表。

2.在第i个位置插入新的元素x。

3.删除第i个位置上的元素。

4.取第i个位置上的元素。

5.返回元素x第一次出现在双向循环链表中的位置号。

6.求双向循环链表的长度,即元素个数。

7.输出双向循环链表中所有的元素值。

8.实现双向循环链表的就地逆置。

设计内容与步骤

1、设计存储结构

2、设计算法

3、编写程序,进行调试

4、总结并进行演示、讲解

设计工作计划与进度安排

起止时间:

12月22日-12月12月15日

地点:

中心机房

设计考核要求

1、考勤20%

2、课程设计说明书40%

3、成果展示40%

山东建筑大学计算机科学与技术学院

课程设计任务书二

设计题目

哈夫曼树

已知技术参数和设计要求

1、建立一棵哈夫曼树。

2、建立内部类节点,初始化初值

3、重写equals方法。

4、译码方法

5、广度遍历

6、main函数运行

设计内容与步骤

1、设计存储结构

2、设计算法

3、编写程序,进行调试

4、总结并进行演示、讲解

设计工作计划与进度安排

起止时间:

12月25日-12月29

工作内容:

哈夫曼的编码和译码

地点:

中心机房

设计考核要求

1、考勤20%

2、课程设计说明书40%

3、成果展示40%

指导教师(签字):

教研室主任(签字)

双向循环链表操作的实现

一、问题描述

1、建表

 

2、插入

 

3、删除

 

4、就地逆置

二、数据结构

建表

publicCreate(intn)throwsException{

this();

Scannersc=newScanner(System.in);

for(intj=0;j

insert(n,sc.next());

}

插入

publicvoidinsert(inti,Objectx)throwsException{

Nodep=head.next;

intj=0;

while(!

p.equals(head)&&j

p=p.next;

j++;

}

if(j!

=i&&!

p.equals(head))

thrownewException("插入位置不对");

Nodes=newNode(x);

p.pr.next=s;

s.pr=p.pr;

s.next=p;

p.pr=s;

}

删除

publicvoidremove(inti)throwsException{

Nodep=head.next;

intj=0;

while(!

p.equals(head)&&j

p=p.next;

++j;

}

if(j!

=i)

thrownewException("删除位置不对");

p.pr.next=p.next;

p.next.pr=p.pr;

}

返回元素

publicObjectget(inti)throwsException{

Nodep=head.next;

intj=0;

while(!

p.equals(head)&&j

p=p.next;

++j;

}

if(j>i||p.equals(head)){

thrownewException("第"+i+"个元素不在");

}

returnp.data;

}

计算长度

publicintlength(){

Nodep=head.next;

intlength=0;

while(!

p.equals(head)){

p=p.next;

++length;

}

returnlength;

}

查找位置

publicintindexOf(Objectx){

Nodep=head.next;

intj=0;

while(!

p.equals(head)&&!

p.data.equals(x)){

p=p.next;

++j;

}

if(!

p.equals(head))

returnj;

else

return-1;

}

遍历

publicvoiddisplay(){

Nodenode=head.next;

while(!

node.equals(head)){

System.out.print(node.data+"");

node=node.next;

}

System.out.println();

}

就地逆置

publicvoidtrs(){

Nodep=head.next;

while(p!

=head){

Nodeq=p;

Noder=p.next;

q.next=q.pr;

q.pr=r;

p=p.pr;

}

Nodes=head.pr;

head.pr=head.next;

head.next=s;

}

三、逻辑设计

1、思路:

(1)建立节点类Node,定义data、pr、next;

(2)建立一个空双向链表;

(3)向空双向链表中存入元素值

(4)利用insert、remove等方法对链表进行操作;

(5)建立main方法,并捕获抛出的异常。

2、模块划分:

函数描述

调用的函数

Main

Remove(int)、insert(int,int)、creat()、trs()、length()、get()、display()

Insert(int,int)

\

Remove(int)

\

Length()

\

Get(int)

Inverse()

Diasplay()

\

creat()

insert(int,int)

Trs()

3、函数或类的具体定义和功能

(1)Node类:

定义节点类;

(2)creat()方法:

建立一个空链表;

(3)creat(int)方法:

在空链表的基础上建立一个链表;

(4)Insert(int,object)方法:

在双向链表中指定位置插入指定的结点;

(5)Remove(int)方法:

删除指定的位置的结点;

(6)Length()方法:

链表求长;

(7)Get(int)取出某个位置的结点;

(8)trs():

链表的就地逆置;

(9)indexof():

返回元素x第一次出现在双向循环链表中的位置号;

(10)Display():

显示当前的双向链表;

(11)Main():

主函数。

四、编码

packageOne;

importjava.util.Scanner;

classNode{

publicObjectdata;

publicNodepr;

publicNodenext;

publicNode(){

this(null);

}

publicNode(Objectdata){

this.data=data;

this.pr=null;

this.next=null;

}

}

publicclassCreate{

publicNodehead;

publicCreate(){

head=newNode();

head.pr=head;

head.next=head;

}

//尾插法

publicCreate(intn)throwsException{

this();

Scannersc=newScanner(System.in);

for(intj=0;j

insert(n,sc.next());

}

publicvoidinsert(inti,Objectx)throwsException{

Nodep=head.next;

intj=0;

while(!

p.equals(head)&&j

p=p.next;

j++;

}

if(j!

=i&&!

p.equals(head))

thrownewException("插入位置不对");

Nodes=newNode(x);

p.pr.next=s;

s.pr=p.pr;

s.next=p;

p.pr=s;

}

publicvoidremove(inti)throwsException{

Nodep=head.next;

intj=0;

while(!

p.equals(head)&&j

p=p.next;

++j;

}

if(j!

=i)

thrownewException("删除位置不对");

p.pr.next=p.next;

p.next.pr=p.pr;

}

publicObjectget(inti)throwsException{

Nodep=head.next;

intj=0;

while(!

p.equals(head)&&j

p=p.next;

++j;

}

if(j>i||p.equals(head)){

thrownewException("第"+i+"个元素不在");

}

returnp.data;

}

publicintlength(){

Nodep=head.next;

intlength=0;

while(!

p.equals(head)){

p=p.next;

++length;

}

returnlength;

}

publicintindexOf(Objectx){

Nodep=head.next;

intj=0;

while(!

p.equals(head)&&!

p.data.equals(x)){

p=p.next;

++j;

}

if(!

p.equals(head))

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > PPT模板 > 艺术创意

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1