最佳适应算法和最坏适应算法_算法:好,坏和丑陋

最佳适应算法和最坏适应算法

by Evaristo Caraballo

通过Evaristo Caraballo

算法:好,坏和丑陋 (Algorithms: The Good, The Bad and The Ugly)

Who has been in Free Code Camp without having the experience of spending hours trying to solve Algorithms?

谁曾参加Free Code Camp,却没有花费大量时间尝试求解算法

At Free Code Camp, we wanted to know why that was the case, and what more we could do to help you a bit.

在Free Code Camp,我们想知道为什么会这样,以及我们还能做些什么来帮助您。

We made two different analyses to have a better idea of what was going on. Data were collected between Nov 2014 to Dec 2015.

我们进行了两种不同的分析,以更好地了解正在发生的事情。 数据收集时间为2014年11月至2015年12月。

One of those analyses consisted of tracking the number of times people pasted their code to be checked by others in relevant Gitter chatrooms. We got data from the Gitter API. After some clean-up we tried to get the names of the functions of each challenge from posted messages at the Help chatroom. Although the data are not precise, it’s a good approximation of what could be happening.

这些分析之一是跟踪人们在相关的Gitter聊天室中粘贴代码以供其他人检查的次数。 我们从Gitter API获取数据。 进行一些清理后,我们尝试从帮助聊天室中发布的消息中获取每个挑战的功能名称。 尽管数据不精确,但是可以很好地近似所发生的事情。

The chart above speaks clearly on its own: algorithms like palindromes, title case, seek and destroy, longest word, reverse string, mutation or chunky monkey are those where many people ask for assistance.

上面的图表清楚地说明了自己:回文,标题大小写,查找和销毁,最长的单词,反向字符串,变异或矮胖的猴子之类的算法是许多人寻求帮助的算法。

Another analysis we made was to take the average time per page that each camper spent on each challenge, using Google Analytics data.

我们进行的另一项分析是使用Google Analytics(分析)数据获取每个露营者在每项挑战上花费的平均每页时间。

Again, the ugly ones are challenges like palindromes, but there are other ones that also look ugly (let’s say 1/4 of the average time per level over the same average time) specially for basic and intermediate levels, like Spinal Tap Case, Pig Latin, Search and Replace, Common Multiple, Sum All Primes, Steamroller, Friendly Date Range, Pairwise, and others.

同样,丑陋的挑战是诸如回文集之类的挑战,但是还有其他挑战看起来也很丑陋(例如,在同一平均时间内每个级别的平均时间的1/4), 特别是对于基础水平和中级水平而言 ,例如Spinal Tap Case,Pig拉丁语,搜索和替换,公倍数,所有素数之和,Steamroller,友好日期范围,成对和其他。

Looking at the results, can we suggest the factors that are affecting the performance of campers with the algorithms?

从结果来看我们能否通过算法提出影响露营者性能的因素

The most apparent reasons, given in a tentative ordering, are:

按暂定顺序给出的最明显的原因是:

  • Campers are finding hard to deal specially with strings, and Regex is a bad word, no matter the level!

    营员发现很难对付 ,而正则表达式无论级别高低都是一个坏词!

  • There are some numeric challenges that are making camper’s life difficult, particularly those which are suitable for recursive calls.

    有一些数字难题使露营者的生活变得困难,尤其是那些适合递归调用的难题。

  • Another common problem is dealing with nested collections of arrays/objects.

    另一个常见的问题是处理数组/对象的嵌套集合

  • Difficulty with concepts and definitions is usual. For example, the concept of “symmetric difference” (with a Free Code Camp algorithm with the same name) is usually troubling because many campers don’t understand the concept properly, despite the inclusion of a widely accepted mathematical definition.

    通常很难理解概念和定义 。 例如,“对称差异”的概念(使用具有相同名称的Free Code Camp算法)通常令人不安,因为尽管包含了广泛接受的数学定义,但许多营员仍无法正确理解该概念。

Similarly, looking at the last chart you may be wondering why the time per page seems not to reflect the difficulty of the problem? One explanation could be that the basic and intermediate algorithms are been taken by campers who are just learning to code or seeing JavaScript for the first time. However this is a tentative explanation and may require more analyses.

同样,查看最后一个图表,您可能想知道为什么每页时间似乎不能反映问题的难度 ? 一种解释可能是,基本算法和中间算法是由刚开始学习编码或第一次看到JavaScript的营员采用的。 但是,这只是一个初步的解释,可能需要更多的分析。

If you are reading this and you have already suffered with some of the algorithms, you will realize that you are not alone. For those who are starting with algorithms, I would recommend the following:

如果您正在阅读本文,并且已经受了某些算法的困扰,您将意识到自己并不孤单。 对于那些开始使用算法的人,我建议以下内容:

  • Try to see if you can solve the easiest first: you might find some practice solving those that could help you to deal with the more difficult ones later…

    尝试先看看是否可以解决最简单的问题:您可能会找到一些解决方法,可以帮助以后解决更困难的问题……
  • Try to understand the problem! Start by asking what the problem is about.

    尝试了解问题! 首先询问问题所在。
  • Research. Check b0oks, references, and other online courses. And Share. We are offering a lot of help with likely a similar problem like yours. Ask in the chatroom. Send a message to CamperBot. Look at the Wiki. Try pair programming. Visit a Campsite and code with other campers in person. In one of the CodePens I made for this article, I also included links to the Free Code Camp wiki, so you can have a first overview of the problem and how it is normally solved.

    研究。 检查书,参考书和其他在线课程。 和分享。 对于像您这样的类似问题,我们提供了很多帮助。 在聊天室提问。 发信息给CamperBot。 看一下Wiki。 尝试配对编程。 参观营地并亲自与其他营员进行编码。 在我为本文编写的CodePens之一中,我还提供了指向Free Code Camp Wiki的链接,因此您可以初步了解该问题以及通常如何解决该问题。
  • You may already know that the problem is difficult: now the next step is trying to understand why and what make it so hard. This approach is key for algorithmic problem solving, and programming in general. Study, ask, and try again.

    您可能已经知道问题很棘手:现在,下一步就是尝试了解导致问题变得如此困难的原因原因 。 这种方法对于解决算法问题和一般编程至关重要。 研究,询问,然后重试。

  • The data we used for these analyses were for last year: this year SaintPeter and friends have been working hard in modify the curriculum, so you may notice a difference in your performance if you work through the improved Basic JavaScript section. If you haven’t done the updated curriculum it may be helpful to revisit that section.

    我们用于这些分析的数据是去年的:今年, 圣彼得和朋友们一直在努力修改课程表,因此,如果您在改进的“基本JavaScript”部分中工作,您可能会发现性能有所不同。 如果您还没有完成更新的课程表,那么重新访问该部分可能会有所帮助。

  • My bonus advice? Yes, try really hard yourself but… read other peoples’ code, too. When you read a book about JavaScript to learn programming, that is exactly what you are doing. Learn to reverse engineer existing code and to modify it to suit your needs. Why? First, no point in re-inventing the wheel. Second, you learn a lot by understanding the work of those who already solved the problem. Remember: you will find that most of the time you will be reusing modified snippets of a previous code into a new one. So no shame in reading other’s codes. That is part of the nature of Open Source, by the way…

    我的奖金建议? 是的,你要自己努力,但是……也要阅读其他人的代码。 当您阅读有关JavaScript的书以学习编程时,这就是您正在做的事情。 学习对现有代码进行反向工程并进行修改以满足您的需求。 为什么? 首先,重新发明轮子毫无意义。 其次,通过了解已经解决问题的人员的工作,您学到了很多东西。 请记住:您会发现大多数时候您将把先前代码的修改片段重用到新代码中。 因此,在阅读他人的代码时不会感到羞耻。 顺便说一下,这是开放源代码本质的一部分。

Happy Coding!

编码愉快!

I’m also working on related visualizations at bl.ocks.org/evaristoc.

我还在bl.ocks.org/evaristoc上进行相关的可视化工作。

This analysis just scratches the surface of what we can learn from Free Code Camp’s open data. Join our Data Science chat room and help us make sense of all these data.

这种分析只是从表面上我们可以从Free Code Camp的开放数据中学到什么。 加入我们的数据科学聊天室 ,帮助我们理解所有这些数据。

翻译自: https://www.freecodecamp.org/news/algorithms-the-good-the-bad-and-the-ugly-e63db0a9cfb3/

最佳适应算法和最坏适应算法

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值