基于单向循环链表的约瑟夫环设计详细分解.docVIP

  • 30
  • 0
  • 约 25页
  • 2018-04-27 发布于湖北
  • 举报

基于单向循环链表的约瑟夫环设计详细分解.doc

长春建筑学院 基于单向循环链表的约瑟夫环Design of Joseph ring way circular linked list based on 学 院: 电气信息学院 班 级: 计算机1201班 学 号: 1座机电话号码 姓 名: 卢玉琨 指导老师: 常大俊 摘 要 约瑟夫环问题是由古罗马著名的史学家Josephus提出的问题演变而来,所以通常称为Josephus问题。改进约瑟夫环问题的描述是:编号为1,2,…,n的n个人按顺时针方向围坐一圈, 每人有一个密码K(整数),留作其出圈后应报到K后出圈。报数方法采用顺时针报数和逆时针报数交替进行,初始密码可任意确定。求最后剩下的人的编号。这个就是约瑟夫环问题的实际场景。约瑟夫环问题如果采用单循环链表则能很好的解决。循环链表的数据结构,就是将一个链表的尾元素指针指向队首元素。 p- link head解决问题的核心步骤是:先建立一个具有n个链结点,无头结点的循环链表,然后确定第一个报数人的位置,并不断地从链表中删除链结点,直到链表为空。 【关键词】约瑟夫环;单循环链表;数据结构;删除结点 Abstract Josephus ring problem is evolved by the question that raised by Josephus,the famous historican of ancient Rome.SO it always be called Josephus Problem.The description of improving Josephus problem is :people was numbered 1,2,3,...,n sitted as a clockwise direction around circle,each with a password of K integer ,reserved for the ring should be reported K out of the ring .The report adapted the method that changed alternately with the clockwise and anticlockwise, the initial password can be determined.Solving the number of the last person.This is the real sense of the Joseph central problems. Joseph central problems can be well-solved if it adapted the circular linked list .The configuration of the list is just pointed to the first team elements with the Omoto So pointer. P- link head.The core process to solving the problem is:Firstly established a no-head-node circular linked list which have n chain nodes.Then determined the location of the first person.And striked out the chain nodes constantly until the chain table was empty. [Keywords] Joseph ring; circular linked list; data structure; deleting node 目 录 前言 1 第一章 问题分析 2 1.1 设计目的 2 1.2 设计内容 2 1.3 设计要求 2 1.4 设计思想 第二章 逻辑设计 4 2.1 循环链表抽象数据类型定义 4 2.2本程序包含的模块设计 4 第三章 详细设计 6 3.1 主函数 6 3.2 链表的创建 7 3.3 出队处理 9 3.4 约瑟夫环说明模块 10 3.5菜单模块 10 第四章 程序调试与测试 11 第五章 结论 14 参考文献 15 致谢 16 附录 17 前 言 数据结构是一门研究非数值计算的程序设计问题中计算机的操作对象以及它们之间的关系和操作的学科。该课程设计的目的是通过课程设计的综合训练,以培养分析和编程等实际动手能力,是系统掌握数据结构这门课程的主要内容。 本次课程设计的内容是用单循环链表模拟约瑟夫环问题,循环链表是一种首尾相接的链

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档