文件名称:jinbiaosai

  • 所属分类:
  • 游戏
  • 资源属性:
  • [Java] [源码]
  • 上传时间:
  • 2016-12-02
  • 文件大小:
  • 1kb
  • 下载次数:
  • 0次
  • 提 供 者:
  • Y**
  • 相关连接:
  • 下载说明:
  • 别用迅雷下载,失败请重下,重下不扣分!

介绍说明--下载内容均来自于网络,请自行研究使用



如果要在n个数据中挑选出第一大和第二大的数据(要求输出数据所在位置和值),使用什么方法比较的次数最少?我们可以从体育锦标赛中受到启发。



如图【1.png】所示,8个选手的锦标赛,先两两捉对比拼,淘汰一半。优胜者再两两比拼...直到决出第一名。



第一名输出后,只要对黄色标示的位置重新比赛即可。



下面的代码实现了这个算法(假设数据中没有相同值)。



代码中需要用一个数组来表示图中的树(注意,这是个满二叉树, 不足需要补齐)。它不是存储数据本身,而是存储了数据的下标。 第一个数据输出后,它所在的位置被标识为-1-If you want to pick out the largest and second largest data (requires output data location and value), the number of what method to use to compare data in the least in n? We can be inspired sports tournament. [1.png] As shown, the eight players of the tournament, the first to catch on twenty-two competition, eliminated half. Competition winner ... until then twenty-two decided at first. After the first output, as long as the yellow mark to the position of a re-match. The following code implements this algorithm (assuming the data is not the same value). The code needs to use an array to represent the figure of the tree (note that this is a full binary tree, filled less than required). It is not stored in the data itself, but the index data storage. After the first data output, its location is identified as-1
(系统自动生成,下载前可以参看下载内容)

下载文件列表





TEST5.java

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度更多...
  • 请直接用浏览器下载本站内容,不要使用迅雷之类的下载软件,用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.

相关评论

暂无评论内容.

发表评论

*主  题:
*内  容:
*验 证 码:

源码中国 www.ymcn.org