摩尔斯电码

The other night I was watching some videos by 2 Youtube channels I really like. The first one was Tom Scott’s video on why the Prime Meridian isn’t exactly at 0 degrees. I noticed that he happened to be filming from the same exact place that my profile photo for all my social accounts (including medium) are taken. It was a fun coincidence and it was also nice to know I had visited the Prime Meridian without knowing it.

前一天晚上,我观看了我真正喜欢的2个Youtube频道的一些视频。 第一个是汤姆·斯科特(Tom Scott)的视频,其中介绍了为何本初子午线并非精确地位于0度。 我注意到他恰巧是在拍摄我所有社交帐户(包括媒体)的个人资料照片的同一地点拍摄的。 这是一个有趣的巧合,很高兴知道我在不知道的情况下拜访了本初子午线。

The next video I watched was by the other Youtube channel I enjoy, Vsauce. It was on Morse Code. There was another fun coincidence in this video as well. In the very beginning, he defines what a palindrome is, and uses ‘racecar’ as an example. his explanation was almost word for word how I described it in my previous blog post on the 2 parts of solving an algorithm. It was weird seeing something I had just studied and written about, pop up again soon after.

我观看的下一个视频是我喜欢的另一个YouTube频道Vsauce。 这是在摩尔斯电码上。 该视频中还有另一个有趣的巧合。 从一开始,他就定义了回文是什么,并以“赛车”为例。 他的解释几乎是逐字逐句的,我在​​上篇博客中关于解决算法的两个部分是如何描述的。 看到我刚刚学习和写过的东西很奇怪,然后又突然出现。

I continued watching his video and he explained some interesting history and facts about morse code. In Morse Code, every character is made up of a combination of dots ‘.’ and dashes ‘-’. He explained that it was developed so the most common characters had the simplest or shortest make-up in morse code.

我继续观看他的视频,他解释了一些有关莫尔斯电码的有趣历史和事实。 在摩尔斯电码中,每个字符都由点“。”的组合组成。 和破折号“-”。 他解释说,它是经过开发的,因此最常见的字符在摩尔斯电码中的构成最简单或最短。

Later on, Michael from Vsauce introduced some nemonic devices that can help you learn or understand Morse Code. One of these devices was, as he described it ‘a flow chart looking thing’. Here’s what it looked like.

后来,来自Vsauce的Michael推出了一些nemonic设备,可帮助您学习或理解摩尔斯电码。 正如他所描述的,这些设备之一就是“流程图看的东西”。 这是它的样子。

This wasn’t just ‘a flow chart looking thing’, this was a binary tree. It’s a connection of nodes with each node having one or two children, and storing a value. What a coincidence, I have just been learning about this data structure for my technical challenges. It turns out there is a term for this coincidence. It is called the Baader Meinhof Phenomenon, and it describes a situation in which you come across something for the first time, and then see it again shortly after in an unrelated way.

这不仅仅是一个“看似流程图的东西”,而是一棵二叉树。 它是节点的连接,每个节点有一个或两个子节点,并存储一个值。 碰巧的是,我刚开始学习有关此数据结构的技术挑战。 事实证明,这个巧合有一个名词。 它被称为Baader Meinhof现象,它描述了一种情况,在这种情况下,您第一次碰到某些东西,然后不久就以不相关的方式再次看到它。

What was so interesting about this particular binary tree is that every value to the left of a given node, adds one more dot in morse code, in relation to its parent, and every value to the right adds one more dash. This means that we can write a function that takes in any valid Morse Code string, decodes it, and returns its decoded message.

这个特定的二叉树的有趣之处在于,给定节点左侧的每个值都相对于其父级在摩尔斯电码中增加了一个点,右侧的每个值又增加了一个破折号。 这意味着我们可以编写一个函数,该函数接受任何有效的摩尔斯电码字符串,对其进行解码,然后返回其解码后的消息。

decode(morse){        morse = morse.split(' / ') //['... .- --', '... .. .']        let message = ''        for(let word of morse){            let chars = word.split(' ') //['...', '.-', '--']            let decoded = ''            for(let char in chars){   // '...'                  let node = this.root                for(let symb in chars[char]){ // '.' '.' '.'                    if(chars[char][symb] === "-") node = node.right                    else if(chars[char][symb] === '.')                         node = node.left                    else console.log('error')                }                decoded = decoded + node.data            }            message = message + decoded + " "        }        return message    }

With this as a function within our Binary Tree class, we can call tree.decode on a valid Morse Code string and return its english counterpart. When we call decode, we split the string apart by words and we define a variable to store the returned decoded message. Then we iterate through our array of words. We then split each word by a space, which allows us to have an array of characters for every word in the message. Following that, we define a variable to hold our word we are iterating with. We then grab the root of our morse tree, and iterate through every morse symbol of our letter. If the symbol is a dash, we move to the node to our right, if it is a dot, we move to the left. After we finish our iteration, we know that the value of our node is the character that our symbols resembled. We add every node data to our word variable. After we finish our letter iteration, we add our completed word and a space to our message variable. Finally, we return our decoded message.

将此作为Binary Tree类中的函数,我们可以在有效的摩尔斯电码字符串上调用tree.decode并返回其英文对应物。 调用解码时,我们将字符串按单词分开,然后定义一个变量来存储返回的解码消息。 然后,我们遍历单词数组。 然后,我们用空格分隔每个单词,这使我们可以为消息中的每个单词使用字符数组。 之后,我们定义一个变量来保存要迭代的单词。 然后,我们抓住莫尔斯树的根,遍历字母的每个摩尔斯符号。 如果符号是一个破折号,我们将移至右侧的节点,如果它是一个点,则将移至左侧。 完成迭代后,我们知道节点的值就是我们的符号类似的字符。 我们将每个节点数据添加到我们的word变量中。 完成字母迭代后,将完成的单词和空格添加到消息变量中。 最后,我们返回解码后的消息。

By implementing this function, we can see that Vsauce was right, and this tree decodes morse code, and we can decode it with our understanding of trees and their traversal. Thank you for reading, I hope you found this as interesting as I did!

通过实现此功能,我们可以看到Vsauce是正确的,并且该树可以解码摩尔斯电码,并且可以通过对树及其遍历的理解来对其进行解码。 感谢您的阅读,希望您能像我一样有趣!

翻译自: https://medium.com/dev-genius/morse-code-binary-trees-and-the-baader-meinhof-phenomenon-c0aa27876369

摩尔斯电码


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

相关文章:

  • Python实现摩尔斯电码和英文互译
  • 摩尔斯电码转换python编码_python转换字符串为摩尔斯电码的方法
  • java 摩尔斯电码_使用Java进行摩尔斯电码转换
  • 摩尔斯电码转换python编码_摩尔斯电码到英文python3
  • 摩尔斯电码转换
  • 摩斯密码是什么?
  • 注塑机数据采集震雄CPC6
  • 注塑成型(注射模塑成型)
  • 工业物联网 凌顶发布注塑机通讯协议Euromap 63 的 OPCUA 驱动组件
  • MES系统功能助力注塑行业降本增效
  • 富强鑫注塑机KEBA网口采集方案
  • 常用计算机品牌,常用各大品牌注塑机电脑密码
  • 宝捷信注塑机PS系列采集方案
  • 恩格尔注塑机数据采集
  • 注塑机摆放间距多少合适_选用注塑机的基本原则
  • 影视后期制作需要用到哪些软件?
  • 苹果电脑上好用的4款摄影后期修饰剪辑工具
  • 软件测试判断题
  • 软件测试期末复习
  • DxO PhotoLab 2.2.2完整精华汉化版|顶级RAW数码后期软件
  • 摄影后期软件darktable介绍、汉化、使用说明(Lightroom免费替代品)
  • 做影视后期常用的行业软件
  • 5个月的ui设计培训,都学习什么内容|优漫教育
  • 涪陵计算机二级培训机构排名,涪陵计算机培训_众鑫教育信得过的品牌
  • 【每日早报】2019/0604
  • 培训机构和在线教程还能不能信任?
  • Mac最佳视频编辑器推荐
  • 在线教育的内容研发和技术的迭代创新
  • Configuration Manager 2012 R2基础知识
  • 老男孩教育Linux运维培训32期决心书

摩尔斯电码_摩尔斯电码二叉树和baader meinhof现象相关推荐

  1. python实现贝叶斯优化_贝叶斯优化的并行实现

    python实现贝叶斯优化 The concept of 'optimization' is central to data science. We minimize loss by optimizi ...

  2. python实现贝叶斯回归_贝叶斯线性回归(Bayesian Linear Regression)

    贝叶斯线性回归(Bayesian Linear Regression) 标签(空格分隔): 监督学习 @ author : duanxxnj@163.com @ time : 2015-06-19 本 ...

  3. pytorch贝叶斯网络_贝叶斯神经网络:2个在TensorFlow和Pytorch中完全连接

    pytorch贝叶斯网络 贝叶斯神经网络 (Bayesian Neural Net) This chapter continues the series on Bayesian deep learni ...

  4. java 贝叶斯抠图_贝叶斯抠图

    贝叶斯抠图,主要是利用贝叶斯定理来进行点颜色的概率计算. 一.前景色和背景色关系 对于前景色,背景色以及当前显示的颜色,存在下面的一个关系: 其中F表示前景色,B表示背景色,C表示当前颜色,α则表示不 ...

  5. php+摩尔斯电码,如何在Symfony 3中使用PHP编码和解码摩尔斯电码(翻译摩尔斯电码)...

    本文概述 莫尔斯电码是一种通过键入一系列电子脉冲(短脉冲(称为"点")和长脉冲(" _")表示)来发送文本消息的方法.尽管你可能认为此代码仅在电影中使用, 但是 ...

  6. 朴素贝叶斯 半朴素贝叶斯_使用朴素贝叶斯和N-Gram的Twitter情绪分析

    朴素贝叶斯 半朴素贝叶斯 In this article, we'll show you how to classify a tweet into either positive or negativ ...

  7. 二项分布_贝塔分布(multivariate Beta distribution)_多项分布_狄利克雷分布(Dirichlet distribution)_贝叶斯理论公式浅述

    二项分布_贝塔分布(multivariate Beta distribution)_多项分布_狄利克雷分布(Dirichlet distribution)_贝叶斯理论公式浅述 参考书籍<统计学习 ...

  8. 机器学习朴素贝叶斯算法_机器学习中的朴素贝叶斯算法

    机器学习朴素贝叶斯算法 朴素贝叶斯算法 (Naive Bayes Algorithm) Naive Bayes is basically used for text learning. Using t ...

  9. 朴素贝叶斯算法及贝叶斯网络详述

    1.贝叶斯定理 先验概率P(A):在不考虑其他的情况下,A事件发生的概率. 条件概率P(B|A):A事件发生的情况下,B事件发生的概率. 后验概率P(A|B):在B事件发生之后,对A事件发生的概率的重 ...

最新文章

  1. 2019年中国科创板全面解读报告
  2. 找回MySQL的root密码
  3. Swif语法基础 要点归纳(一)
  4. ASP.NET Core Web Api之JWT(一)
  5. mysql 漏洞如何修复_Mysql漏洞修复方法思路及注意事项
  6. unity案例 mysql lua_通过Xlua实现unity热更新的一个小例子
  7. 有一个写代码很厉害的老板是怎样一种体验?
  8. SQL SERver2005中row_number() 的用法
  9. ConceptDraw Office Pro v8.0.2 Keygen
  10. 龙举直播电商api开发
  11. android aso优化工具,App Store移动应用ASO优化工具:MobileDevHQ
  12. 视频源与广播电视制式
  13. ssh 整合TOMCAT启动遇到错误
  14. [BZOJ3503]-[CQOI2014]和谐矩阵-高斯消元
  15. Tkinter 常用控件复选框
  16. 初次创建andriod项目出现的问题
  17. 大学英语精读第三版(第五册)复习笔记——文章内容摘要
  18. Html中怎么用CSS让ul中多个li标签不换行横排显示
  19. ODT(old driver tree)详解(带例题)
  20. 微信小程序 获取手机号 JavaScript解密示例代码详解

热门文章

  1. 生活是一种态度,得失是一种心境
  2. python - one day
  3. 小傻蛋的妹妹跟随小甲鱼学习Python的第一节001
  4. 智联招聘的用户要注意了,这个问题可是关系到工作的机会的
  5. 怎样判断三角形的顶点是逆时针方向还是顺时针方向
  6. html5 oa首页免费,免费的在线oa
  7. `Computer-Algorithm` 有向无环图DAG
  8. 黑马程序员01_String
  9. el-table滚动条被挡住的问题
  10. linux网络电视盒安装,网络电视盒怎么安装 网络电视盒安装步骤【详细介绍】...