计算暴力方法的操作次数

发布于 2024-07-10 02:26:35 字数 352 浏览 3 评论 0原文

我是一名大三学生,我有一门叫做算法设计与分析的课程。 课程很酷,但教练却不是。 我不明白暴力破解以及如何计算操作次数以及如何计算时间复杂度(最差、最佳、平均),我试图在网上搜索它,但每次我都以大o结束我不想要的符号和分而治之。 如果你们中的任何人都可以从此链接下载讲师幻灯片并查看我在说什么...

幻灯片

我真的需要你的帮助,我保证我会尽力而为

I'm a junior student and I had a course called The Design and Analysis of Algorithms. The course is cool but the instructor is not. I don't understand the brute force and how to count the number of operations and how to count the time complexity (worst, best, avg), I tried to search for it on the net but each time I end with the big-o notation and the divide and conquer which I don't want. If any of you guys can download the instructor slide from this link and see what I'm talking about ....

the slide

I really need your help on this , and I promise I will do my best

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

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

发布评论

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

评论(4

一口甜 2024-07-17 02:26:35

蛮力是一类“算法”(或者简单地说是“做事的方式”),你不会试图变得聪明,只是愚蠢的搜索。 示例:如果您想在电话簿中查找电话号码,聪明的解决方案是观察所有条目均按姓氏排序,然后直接查找正确的字母等。蛮力解决方案是读取从头开始检查电话簿,检查每个名字,并在找到正确的名字时停止。

Brute force is a class of "algorithms" (or plainly "way of doing things") where you don't try to be clever, just dumb search. Example: if you want to look up a phone number in the phone book, the clever solution would be to observe that all entries are sorted by last name, and directly look up the correct letter, etc. The brute force solution would be to read the phone book from the start, checking every single name and stopping when the right name is found.

呢古 2024-07-17 02:26:35

You might get a bit out of watching the first few lectures of this series on algorithms.

不如归去 2024-07-17 02:26:35

暴力破解是测试特定问题的所有可能配置并测试其中之一是否与解决方案的属性匹配的任务。

考虑 4 位 PIN 码。 如果丢失,可以测试从 0000 到 9999 的所有可能的代码,以找到正确的代码。 这是一种暴力强迫。

同样的东西可以用来解决一些计算机科学问题,例如 0/1 背包问题,其中小偷想要找出要偷什么。 每个对象都有值 v[i] 和权重 w[i]。 他或她想要找出提供最大价值且权重小于“W”的组合。 该问题的一种可能的解决方案是考虑对象的所有组合并找到每个组合的值和权重,然后选择最佳的组合。

Brute forcing is the task of testing all possible configurations of a specific problem and testing if one of them matches the properties of a solution.

Consider a 4 digit pin code. If you lose it, you can test all possible codes from 0000 to 9999 to find the correct code. This is a kind of brute forcing.

The same thing can be used to solve some computer science problems such as 0/1 knapsack problem in which, a thief wants to find out what to steal. Every object has value v[i] and weight w[i]. He or she wants to find out the combination that provides maximum value and has less weight than "W". A possible solution to this problem is to consider all combinations of objects and find the value and the weight of each combination and then select the optimal one.

余生再见 2024-07-17 02:26:35

我可以举例说明选择排序和冒泡排序如何计算时间复杂度以及如何计算操作以及什么是旅行商问题

选择排序算法 可以从 Wikipedia 获取伪代码冒泡排序。 时间复杂度是根据算法运行的次数计算,直到它得到了正确的答案。

旅行推销员问题是计算机科学中的一个经典问题,它通过计算出算法的执行时间来相互关联问题的答案。

以机智:

问题是:给定多个城市以及从任何城市到任何其他城市的旅行成本,访问每个城市一次然后返回出发城市的成本最低的往返路线是什么?< /p>

如果我尝试使用算法来暴力破解最佳路线,那么在任何比最简单路线更大的路线上都会花费很长的时间。 这就是 Big(O) 的用武之地,它向我展示了我选择的每种算法将如何影响我获得答案所需的时间。

我根据您为其他答案留下的评论发布了这个答案。 就其价值而言,Big-O 表示法正是您想要的,它指示您的算法执行所需的时间。

Can I have an example on the selection sort and bubble sort how to count the time complexity and how to count the operations and what is the traveling salesman problem

The Selection sort algorithm is available in pseudocode from Wikipedia, as is the Bubble Sort. The time complexity is computed by the number of times it takes the algorithm to run through until it gets the right answer.

The Traveling Salesman problem is a classic problem in computer science that interrelates the algorithm's execution time by figuring out the answer to the question.

To wit:

The problem is: given a number of cities and the costs of traveling from any city to any other city, what is the least-cost round-trip route that visits each city exactly once and then returns to the starting city?

If I try to use an algorithm to brute-force the best route, it'll take a really long time on any route bigger than the simplest route. That's where Big(O) comes in, it shows me how each algorithm I'd choose would affect how long it'd take me to get the answer.

I posted this answer based off of the comments you left for other answers. For what it's worth, Big-O notation is exactly what you want, it's the indicator of how long your algorithm will take to execute.

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