这是求什么?
现在让 B(n) 为进行 bubbleSort 对 n 个元素进行排序所需的时间。令 Q(n) 为快速排序对 n 个元素进行排序所需的时间。令 M(n) 为归并排序所需的时间。对 n 个元素进行排序。在 Word 文档或文本文件中,创建一个包含以下数据的表格,您的程序将使用您在 1) 2) 3) 和 4) 中开发的函数生成该数据。
n B(n) B(n)/n^2 ......... etc i just need to know what this is asking for
1000
2000
4000
8000
16000
有一个问题 B(n) 在此要求什么?我已经完成编码,它显示了比较次数和交换次数。我需要一个秒表来计时吗?!?!
我只是不明白它的要求
Now let B(n) be the time it takes to sort n elements for bubbleSort. Let Q(n) be the time it takes for quickSort to sort n elements. Let M(n) be the time it takes for mergeSort. to sort n elements . In a Word document or in a text file, create a table of the following data which your program(s) will produce using the functions you developed in 1) 2) 3) and 4).
n B(n) B(n)/n^2 ......... etc i just need to know what this is asking for
1000
2000
4000
8000
16000
one question what is B(n) asking for in this ? I already finish coding and it shows me number of comparison and number of swaps. Do i need a stop watch to time it or something?!?!
I just dont get what it is asking for
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果你想要取得好成绩:
你的作业提到了你创建的一个程序,大概实现了你列出的算法。添加一些计时代码,在对 1000、2000、4000、8000、16000 个项目执行排序之前和之后打印系统计时。然后减去差值,并将所用时间填入答案表中。
然后按照其他人所说的去做,并使用理论上的“大 O”答案创建一个新的答案表。
理想情况下,您可以将两者叠加为图表,以突出理论与实现之间的差异。
If you're after a good grade:
Your homework mentions a program you have created, presumably that implements the algorithms you listed. Add some timing code that prints system ticks before and after performing a sort with 1000,2000,4000,8000,16000 items. Then subtract the difference, and put the time taken into your answer table.
Then do what the other guys say, and create a new answer table with the theoretical "Big O" answers.
Ideally you'd overlay both as a graph to highlight the difference between theory and your implementation.
据我了解,这个问题要求您说明算法需要对每个输入集执行多少次操作。
例如,如果插入排序是 O(n^2),那么您将有
For what I understand the question asks you to state how many operations would the algorithms need to perform for each of the input sets.
For example, if insertion sort is O(n^2), you'd have
您可以使用与时间相关的函数来实现秒表。
然而,根据我的经验,此类作业通常要求比较次数而不是实际时间。实际时间会因环境而异。
You could implement a stopwatch, using time related functions.
However, from my experience, such homework assignments usually ask for number of comparisons and not actual time. Actual time will vary from Environment to Environment.
“使用您在 1) 2) 3) 和 4) 中开发的函数”,
如果您在 1、2、3、4 中开发了 B(n),那么您必须对 B(n) 有非常精确的定义——使用这些函数而不是此处建议的函数。它们应该看起来像带有整数系数和幂的 n 多项式。
"using the functions you developed in 1) 2) 3) and 4)"
you must have very precise definitions of B(n) if you developed them in 1, 2, 3, 4 -- use those rather than those suggested here. they should look like polynomials over n with integer coefficients and powers.