顺序搜索与二分搜索

发布于 2024-08-24 06:20:18 字数 191 浏览 5 评论 0原文

考虑磁盘上的一个文件包含 100 条记录。

对于这两种搜索,

  1. 在文件中查找记录所需的平均比较次数是多少。
  2. 如果记录不在文件中,则比较的次数
  3. 如果记录有 68% 的机会在文件中,则比较的平均次数
  4. 如果文件每块有 25 条记录,则前 3 个问题中的磁盘访问次数

Consider a file on disk containing 100 records.

For both searches, what is

  1. the average number of comparisons needed to find a record in a file.
  2. number of comparisons if the record is not in the file
  3. the average number of comparisons if the record has a 68% chance of being in the file
  4. the number of disk accesses in the previous 3 questions if the file has 25 records per block

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

挽清梦 2024-08-31 06:20:18

您可能想看看这个线程:

线性搜索和二分搜索有什么区别?

--

人们对你投反对票的原因是你只是复制并粘贴了你的作业问题。您没有以任何方式表明您实际上尝试过学习教科书,然后使用 Google 和 SO 进行搜索,然后尝试此问题,然后发布了您的问题。

You might want to have a look at this SO thread:

What is the difference between Linear search and Binary search?

--

The reason people are down-voting you is that you just copied and pasted your homework problem. You have not shown in any way that you have actually tried studying your textbook, then searched using Google and SO, then attempted this problem, and only then posted your question.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文