约瑟夫环问题实验报告_约瑟夫环问题_5个人约瑟夫环

电脑杂谈  发布时间:2017-02-14 11:35:14  来源:网络整理

《数据结构》课程设计档案题 目: 约瑟夫环问题学 院: 信息学院专 业: 网络工程姓 名: 左 琴学 号: 1101010160班 级 信息A1111班指导教师: 万里勇职 称: 讲 师完成日期: 2012年12月摘 要约瑟夫环问题是由古罗马著名的史学家Josephus提出的问题演变而来,所以通常称为Josephus问题。改进约瑟夫环问题的描述是:编号为1,2,…,n的n个人按顺时针方向围坐一圈, 每人有一个密码K(整数),留作其出圈后应报到K后出圈。约瑟夫环问题报数方法采用顺时针报数和逆时针报数交替进行,初始密码可任意确定。求最后剩下的人的编号。这个就是约瑟夫环问题的实际场景。约瑟夫环问题如果采用单循环链表则能很好的解决。循环链表的数据结构,就是将一个链表的尾元素指针指向队首元素。 p- link head解决问题的核心步骤是:先建立一个具有n个链结点,无头结点的循环链表,然后确定第一个报数人的位置,并不断地从链表中删除链结点,直到链表为空。【关键词】约瑟夫环;单循环链表;数据结构;删除结点AbstractJosephus 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第二章 逻辑设计 42.1 循环链表抽象数据类型定义 42.2本程序包含的模块设计 4第三章 详细设计 63.1 主函数 63.2 链表的创建 73.3 出队处理 93.4 约瑟夫环说明模块 103.5菜单模块 10第四章 程序调试与测试 11第五章 结论 14参考文献 15致谢 16附录 17前 言数据结构是一门研究非数值计算的程序设计问题中计算机的操作对象以及它们之间的关系和操作的学科。


本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/jisuanjixue/article-32361-1.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    热点图片
    拼命载入中...