数论入门符号

You might be taking coding tutorials online, diligently working through labs in boot camp, or maybe you’ve just started your research into what a transition into Software Engineering looks like, and everything is starting to click into place.

您可能正在在线学习编码教程,或者在新兵训练营中努力地工作,或者您刚刚开始研究如何过渡到软件工程,并且一切都已经开始。

Know the difference between an IDE and a Text Editor? Check. Are you able to build a CRUD app using your language of choice? Check. Can you pin down the runtime of an algorithm relative to its input?

知道IDE和文本编辑器之间的区别吗? 检查一下 您是否可以使用自己选择的语言来构建CRUD应用程序 ? 检查一下 您可以相对于算法输入确定算法的运行时间吗?

Uh, hold up. What do you mean by runtime? And what exactly is an algorithm again? In a cold sweat, you Google “Runtime Analysis,” and there it is — Big O Notation.

嗯,快点 您所说的运行时是什么意思? 又是什么算法呢? 汗流Google背,您可以使用Google“运行时分析”,这就是Big O符号。

In programming, we start our learning journey by focusing on the end goal. “If it works, I’m happy,” is a common phrase uttered by many a junior developer. But as you work on larger and more complex projects, understanding how your code scales becomes essential in ensuring that you design elegant and efficient solutions to the problems you face.

在编程中,我们通过专注于最终目标来开始学习之旅。 “如果可行,我很高兴”,这是许多初级开发人员常说的一句话。 但是,当您处理更大,更复杂的项目时,了解代码规模如何对确保您针对遇到的问题设计优雅而有效的解决方案至关重要。

This is where Big O Notation comes into play. Big O Notation allows us to describe the complexity of our code algebraically in a way where we can estimate how fast or slow our code will function when placed under the strain of large amounts of data.

这就是Big O Notation发挥作用的地方。 大O表示法使我们能够以代数方式描述代码的复杂性,在这种方式下,我们可以估计当置于大量数据的压力下时,代码将以多快或慢的速度运行。

Sound complicated? Well, it kind of is, but it’s an essential skill for programmers not only in practice but in the evaluation of our ability (oh yeah, this is going to come up in interviews). So — let’s take a deep breath, shake off that leftover trauma from your days in PreCalc, and dip our toes into the world of Space and Time Complexity.

听起来复杂吗? 是的,但这是程序员的一项基本技能,不仅在实践中,而且在评估我们的能力方面(是的,这将在面试中提出)。 因此-让我们深吸一口气,摆脱掉您在PreCalc中度过的剩余创伤,然后将脚趾浸入时空复杂性世界。

First, let’s be clear about what Big O isn’t. Big O is not going to give you or your team an exact answer on how long a piece of code will take to run. Far from it. As I mentioned earlier, Big O allows us to discuss our code algebraically to get a sense of how quickly it might operate under the strain of large data sets. Luckily, this simplifies things a bit for us newcomers, as it allows us to move our focus from runtime in terms of milliseconds to discussing runtime in relation to the number, and complexity, of operations in our code.

首先,让我们弄清楚Big O不是什么。 Big O不会为您或您的团队提供一段代码要花多长时间的确切答案。 离得很远。 正如我前面提到的,大O允许我们用代数讨论我们的代码,以获得它可能如何Swift的大型数据集的压力下操作 。 幸运的是,这使我们的新手得到了一些简化,因为它使我们可以将重点从运行时(以毫秒为单位)转移到讨论与代码中操作的数量和复杂性有关的运行时。

For example, let’s say we have the following piece of code:

例如,假设我们有以下代码:

def example_search(key, array)   for i in 0...array.length      return "#{key} found!" unless array[i] != key   end   return "#{key} not found :("end

Here, we’re merely looping through a provided array to find a specific key. If that key isn’t found, we’re sure to highlight that as well. It’s a pretty quick operation overall if we’re using an array with five items, but what if we use this method to search for a key in an array 1,000 items long, or even 100,000 items long?

在这里,我们仅循环遍历提供的数组以找到特定的键。 如果找不到该密钥,那么我们也一定要突出显示该密钥。 如果我们使用包含五个项目的数组,总体上来说这是一个相当快的操作,但是如果我们使用此方法在一个数组中搜索关键字,则该关键字长为1000个项目,或者甚至是100,000个项目呢?

Well, with Big O Notation, we can look at our algorithm and see that it will take O(n) time to run. Big O Notation, written as O(blank), show us how many operations our code will run, and how its runtime grows in comparison to other possible solutions.

好了,使用大O表示法,我们可以查看我们的算法,然后看它将花费O(n)时间来运行。 与其他可能的解决方案相比,Big O表示法(写为O(blank))向我们展示了我们的代码将运行多少个操作以及其运行时间如何增长。

Our example code runs at O(n) because in the worst-case if our key isn’t found the first time our code runs, it might have to continue looping through the entire array until we can determine if the key is there or not and its runtime will continue growing at a constant rate.

我们的示例代码在O(n)上运行,因为在最坏的情况下,如果第一次运行我们的代码时找不到我们的密钥,则可能必须继续循环遍历整个数组,直到我们确定密钥是否存在为止并且其运行时间将继续以恒定速度增长。

Why did I emphasize worst-case? We always want to focus on the maximum amount of time a process could take to understand the outer limits of our code to avoid bad solutions. It reassures us that a solution won’t take longer than we expect, and empowers us to feel confident that our code won’t lead to runtime issues in the future.

为什么我要强调最坏的情况 ? 我们始终希望将精力集中在一个过程上,以了解我们的代码的外部限制,以避免错误的解决方案所花费的最长时间。 它向我们保证,解决方案所用的时间不会比我们预期的长,并且使我们有信心,我们的代码将来不会导致运行时问题。

So how does a runtime of O(n) compare to other run times, and what other runtimes can we expect for different types of solutions? Well, every algorithm is going to have its own runtime, but you can expect to see the following run fairly commonly:

那么O(n)的运行时与其他运行时相比如何?对于不同类型的解决方案,我们还能期待其他哪些运行时? 嗯,每种算法都有自己的运行时,但是您可以期望看到以下运行相当普遍:

  • O(log n)O(log n)
  • O(n)上)
  • O(n * log n)O(n *对数n)
  • O(n²)O(n²)
  • O(n!)上!)

For now, don’t worry about how to calculate these yet (we’re just taking baby steps for the moment). All you need to know for now is that the list above is ordered by efficiency — algorithms that run at O(log n) run much faster than algorithms that run at O(n!). You can find a graph demonstrating this below:

目前,您不必担心如何计算这些(我们目前只是采取一些小步骤)。 您现在只需要知道,上面的列表是按效率排序的-以O(log n)运行的算法比以O(n!)运行的算法运行快得多。 您可以在下面找到一个演示此图的图形:

Graph of Possible Runtimes (source: https://bit.ly/31XKRXO)
可能的运行时间图(来源: https : //bit.ly/31XKRXO )

Ultimately, this is a simplification, and things are rarely so neat. But, with practice and further research, you’ll begin to develop a better understanding of how Big O run time can be determined for specific algorithms, and how they compare to other possible solutions.

最终,这只是一个简化,事情很少如此整洁。 但是,通过实践和进一步的研究,您将开始更好地理解如何确定特定算法的Big O运行时间,以及它们如何与其他可能的解决方案进行比较。

结论 (Conclusion)

And that’s it — a quick primer on what Big O Notation, and why it is so essential for Software Engineers. If you only remember a few things from this article, it should be these:

就是这样-Big O Notation的快速入门,以及为什么它对软件工程师如此重要。 如果您只记得本文中的一些内容,应该是:

  • Algorithm speed isn’t discussed in actual runtime but Big O Notation.在实际运行时中并未讨论算法速度,而是使用Big O符号。
  • Big O Notation is important because it allows us to discuss the efficiency of our code and compare solutions without getting caught up in complex calculations.大O符号很重要,因为它使我们能够讨论代码的效率并比较解决方案,而不会陷入复杂的计算中。
  • We always focus on the worst-case when using Big O Notation to ensure that we choose the most efficient solution at scale.

    使用Big O表示法时,我们始终专注于最坏的情况 ,以确保我们选择最有效的解决方案。

  • Scale influences speed significantly, and even though an O(n) solution might be faster than an O(log n) solution at first, that changes quickly as you add more data to the equation.比例会显着影响速度,尽管起初O(n)解决方案可能比O(log n)解决方案快,但随着向方程中添加更多数据,其变化很快。

Hopefully, you walk away from this article feeling empowered to tackle this subject on your own. As I mentioned earlier, Big O Notation and Space & Time Complexity are subjects that truly essential for Software Engineering, and your understanding of them could be what leads you to land your dream job.

希望您能摆脱本文,感到自己有能力自行解决此问题。 正如我前面提到的,“大O符号”和“时空复杂性”是软件工程真正必不可少的主题,您对它们的理解可能会导致您获得理想的工作。

Good luck!

祝好运!

翻译自: https://medium.com/dataseries/a-quick-primer-on-big-o-notation-c99ccc7ddbae

数论入门符号


http://www.taodudu.cc/news/show-2057094.html

相关文章:

  • 数论入门 思考
  • 数论入门 2021-2-28
  • 数论入门 素数
  • 数论入门(python)
  • 数论分块入门
  • 数论入门学习笔记
  • 超简单的数论入门题
  • 数论入门基础
  • 数论入门笔记
  • 数论入门篇
  • 基础数论入门
  • 数论入门学习
  • 数论入门书籍推荐
  • 基础数论(入门)
  • 详解数论从入门到入土
  • 数论入门
  • 数论基础入门
  • 反激电源基本原理和简单的使用例程 学习笔记
  • 基于matlab仿真的功率因数测定方法研究,基于MATLAB的单相全控整流电路功率因数测定.pdf...
  • dqo变换_一种基于dqo变换改进的电流检测新方法
  • 开关电源matlab仿真文件,基于PI控制方式的7A开关电源的MATLAB仿真.doc
  • matlab半波整流怎么做,基于Matlab的单相半波可控整流电路的设计与仿真.doc
  • 电力电子典型电路
  • 企业应如何改善设备功率因数,有效规避罚款
  • matlab如何仿真递推型dft算法,并联型有源滤波器的设计与仿真
  • 基于PSIM及其DLL模块的单相全桥并网逆变器仿真
  • 变频器基础:变频器工作原理与常用功能
  • matlab中单相整流器,应用Matlab仿单相PWM整流器的一种简单方法
  • 直流电机驱动电路整理笔记
  • 电力电子技术笔记(1)

数论入门符号_大o符号快速入门相关推荐

  1. 如何从零基础入门并精通PS?PS如何快速入门?

    本文由:"学设计上兔课网"原创,图片素材来自网络,仅供学习分享 如何从零基础入门并精通PS?PS如何快速入门?ps作为时下最受欢迎的p图软件,经常有同学私信问兔课菌:零基础自学ps ...

  2. keras入门教程 1.线性回归建模(快速入门)

    Keras入门教程 1.线性回归建模(快速入门) 2.线性模型的优化 3.波士顿房价回归 (MPL) 4.卷积神经网络(CNN) 5.使用LSTM RNN 进行时间序列预测 6.Keras 预训练模型 ...

  3. python数据结构_大O符号_学习笔记(1)

    1.概念 :大O符号是用来表达一个算法的复杂程度的,是一个数量级 2.代码 a = 1 b = 2 c = 3 for i in range(n):for j in range(n):x = i*iy ...

  4. css下拉框带三角符号_创建带有符号的下拉列表

    css下拉框带三角符号 To make data entry easier, you can create a drop down list in an Excel cell, using data ...

  5. JQuery 基础 || 目前 jQuery 有三个大版本||JQuery快速入门

    1. 概念: 一个JavaScript框架.简化JS开发 jQuery是一个快速.简洁的JavaScript框架,是继Prototype之后又一个优秀的JavaScript代码库(或JavaScrip ...

  6. web前端网页设计作业_网页前端设计快速入门技巧

    我最近收到部分在校学生的邮件,很多在临近毕业实习这段时间,面临着找工作,表示压力非常大,也不知道如何去选择,大多数都是处于迷茫期,问我怎么办?也有想学前端的,问我怎么才能够快速的入门? 先说我自己吧, ...

  7. 从新手到高手 c++全方位学习_股票新手怎样快速入门?关于散户学习炒股的几点建议...

    对于完全没有接触过股票也不懂金融基础知识的新手来说,想要在短时间内成为炒股高手是很困难的.在希财君看来,股票投资也是一个需要慢慢积累经验的技术活,除了运气逆天的人,极少有新手可以在入门阶段稳定的盈利. ...

  8. 180天Linux小白到大神-Linux快速入门

    01.Linux快速入门 01.Linux快速入门 1.计算机组成原理 1.1 什么是计算机 1.2 为什么要有计算机 1.3 计算机五大组成部分 1.3.1 CPU 1.3.2 内存/硬盘 1.3. ...

  9. kafka分区与分组原理_大数据技术-Kafka入门

    在大数据学习当中,主要的学习重点就是大数据技术框架,针对于大数据处理的不同环节,需要不同的技术框架来解决问题.以Kafka来说,主要就是针对于实时消息处理,在大数据平台当中的应用也很广泛.大数据学习一 ...

  10. java为什么不能输入钢筋符号_搜狗输入法钢筋符号咋样输入?

    2017-12-26 钢筋符号怎么输入? 钢筋符号输入: 钢筋按力学性能,主要分为一级钢筋.二级钢筋.三级钢筋等,日常使用最多的也就是这三种钢筋了,下面具体来看看这三种钢筋的符号在word.excel ...

最新文章

  1. Git远程仓库地址变更
  2. ESP8266 D1-UNO-R3开发板的初步测试
  3. MultiResUNet笔记
  4. FPGA篇(九)关于ASCII码
  5. java inflaterinputstream_java.util.zip.InflaterInputStream.available()方法示例
  6. iOS MMDrawerController源码解读(一)
  7. linux lanmp 安装教程,linux服务器一键安装包lanmp系列教程之一
  8. Oracle常用sql语句(一)
  9. 终于要跟大家见面了,Flink 面试指南
  10. 最新!Vicor 270V-28V DCM5614以96%效率提供1300W功率
  11. python构建字典实现英文大写字母与ascii编码的转换_Python:将复杂的字符串字典从Unicode转换为ASCII...
  12. 女人,向《奋斗》中的夏琳米莱们学习什么
  13. SQL Server 备份与恢复之八:还原数据库
  14. 风格和个性!一组微质感图标设计灵感
  15. leetcode python3 简单题26. Remove Duplicates from Sorted Array
  16. markdown转换html源码,利用Nodejs+Express将Markdown转换为HTML(附源码)
  17. ti嵌入式linux设计外包,基于嵌入式Linux的PMP系统设计与实现
  18. 天猫手机一战成名? 塑造品牌 完胜京东
  19. ASP.NET在Web窗体上输出九九乘法表
  20. Windows11下Edge浏览器登录工行农行并使用K宝U盾

热门文章

  1. 局域网打印机一键共享工具_AppStore今日推荐分享 支持局域网设备共享的抓包工具...
  2. android tv 应用安装器,论Android智能电视盒子必装应用之——QQ音乐TV版
  3. Servlet的面试题
  4. 软考初级程序员---题目(五)
  5. 超强OCR文字识别软件首选ABBYY FineReader
  6. JAVA生成企业组织机构代码、营业执照代码、税务登记号码、统一社会信用代码并校验
  7. Debian10: 安装iF.SVNAdmin
  8. c语言 段错误 linux
  9. java pkcs8_java中公钥,私钥,pkcs1格式,pkcs8格式互转
  10. php安装ziparchive扩展,记一次PHP扩展-ZipArchive安装