当前位置: 首页 > news >正文

网站焦点图怎么做链接/企业网站页面设计

网站焦点图怎么做链接,企业网站页面设计,长沙县政务网站,设计网站费用本文翻译自:What are the applications of binary trees?I am wondering what the particular applications of binary trees are. 我想知道二叉树的特殊应用是什么。 Could you give some real examples? 你能举一些真实的例子吗? #1楼 参考&#xff…

本文翻译自:What are the applications of binary trees?

I am wondering what the particular applications of binary trees are. 我想知道二叉树的特殊应用是什么。 Could you give some real examples? 你能举一些真实的例子吗?


#1楼

参考:https://stackoom.com/question/8wDY/二叉树有哪些应用


#2楼

A binary tree is a tree data structure in which each node has at most two child nodes, usually distinguished as "left" and "right". 二叉树是一种树数据结构,其中每个节点最多具有两个子节点,通常被区分为“左”和“右”。 Nodes with children are parent nodes, and child nodes may contain references to their parents. 具有子节点的节点是父节点,子节点可能包含对其父节点的引用。 Outside the tree, there is often a reference to the "root" node (the ancestor of all nodes), if it exists. 在树外,通常存在对“根”节点(所有节点的祖先)的引用(如果存在)。 Any node in the data structure can be reached by starting at root node and repeatedly following references to either the left or right child. 数据结构中的任何节点都可以通过从根节点开始并反复遵循对左子节点或右子节点的引用来访问。 In a binary tree a degree of every node is maximum two. 在二叉树中,每个节点的度最大为2。

二叉树

Binary trees are useful, because as you can see in the picture, if you want to find any node in the tree, you only have to look a maximum of 6 times. 二叉树很有用,因为如您在图片中所见,如果要在树中查找任何节点,则最多只需要查找6次。 If you wanted to search for node 24, for example, you would start at the root. 例如,如果要搜索节点24,则应从根节点开始。

  • The root has a value of 31, which is greater than 24, so you go to the left node. 根的值31大于24,因此您转到左节点。
  • The left node has a value of 15, which is less than 24, so you go to the right node. 左侧节点的值为15,小于24,因此您转到右侧节点。
  • The right node has a value of 23, which is less than 24, so you go to the right node. 右边的节点的值为23,小于24,因此您转到右边的节点。
  • The right node has a value of 27, which is greater than 24, so you go to the left node. 右侧节点的值为27,该值大于24,因此您将转到左侧节点。
  • The left node has a value of 25, which is greater than 24, so you go to the left node. 左侧节点的值25大于24,因此您将转到左侧节点。
  • The node has a value of 24, which is the key we are looking for. 该节点的值为24,这是我们正在寻找的关键。

This search is illustrated below: 该搜索如下所示: 树搜索

You can see that you can exclude half of the nodes of the entire tree on the first pass. 您可以看到在第一遍中可以排除整个树的一半节点。 and half of the left subtree on the second. 左子树的一半放在第二个树上。 This makes for very effective searches. 这使得搜索非常有效。 If this was done on 4 billion elements, you would only have to search a maximum of 32 times. 如果对40 亿个元素执行此操作,则最多只需搜索32次。 Therefore, the more elements contained in the tree, the more efficient your search can be. 因此,树中包含的元素越多,搜索的效率就越高。

Deletions can become complex. 删除会变得很复杂。 If the node has 0 or 1 child, then it's simply a matter of moving some pointers to exclude the one to be deleted. 如果节点有0或1个子节点,则只需移动一些指针以排除要删除的节点即可。 However, you can not easily delete a node with 2 children. 但是,您无法轻松删除具有2个子节点的节点。 So we take a short cut. 因此,我们采取捷径。 Let's say we wanted to delete node 19. 假设我们要删除节点19。

删除1

Since trying to determine where to move the left and right pointers to is not easy, we find one to substitute it with. 由于尝试确定向左和向右指针移动的位置并不容易,因此我们找到了一个替代它。 We go to the left sub-tree, and go as far right as we can go. 我们转到左侧的子树,然后尽可能向右移动。 This gives us the next greatest value of the node we want to delete. 这为我们提供了要删除的节点的下一个最大值。

删除3

Now we copy all of 18's contents, except for the left and right pointers, and delete the original 18 node. 现在,我们复制18的所有内容(左右指针除外),并删除原始的18节点。

删除4


To create these images, I implemented an AVL tree, a self balancing tree, so that at any point in time, the tree has at most one level of difference between the leaf nodes (nodes with no children). 为了创建这些图像,我实现了一个AVL树,即一个自平衡树,以便在任何时间点,该树在叶节点(没有子节点的节点)之间最多具有一个差异级别。 This keeps the tree from becoming skewed and maintains the maximum O(log n) search time, with the cost of a little more time required for insertions and deletions. 这样可以防止树倾斜,并保持最大O(log n)搜索时间,并且插入和删除操作需要花费更多时间。

Here is a sample showing how my AVL tree has kept itself as compact and balanced as possible. 这是显示我的AVL树如何尽可能保持紧凑和平衡的示例。

在此处输入图片说明

In a sorted array, lookups would still take O(log(n)) , just like a tree, but random insertion and removal would take O(n) instead of the tree's O(log(n)) . 在排序数组中,查找仍将像树一样使用O(log(n)) ,但是随机插入和删除将使用O(n)而不是树的O(log(n)) Some STL containers use these performance characteristics to their advantage so insertion and removal times take a maximum of O(log n) , which is very fast. 一些STL容器充分利用了这些性能特征,因此插入和移除时间最多占用O(log n)的最大值,这非常快。 Some of these containers are map , multimap , set , and multiset . 其中一些容器是mapmultimapsetmultiset

Example code for an AVL tree can be found at http://ideone.com/MheW8 有关AVL树的示例代码,请参见http://ideone.com/MheW8。


#3楼

Applications of Binary tree: 二叉树的应用:

  1. Implementing routing table in router . 在路由器中实现路由表 。
  2. Data compression code 数据压缩码
  3. Implementation of Expression parsers and expression solvers 表达式解析器和表达式求解器的实现
  4. To solve database problem such as indexing . 解决索引等数据库问题 。
  5. Expression evaluation 表达评估

#4楼

One of the most important application of binary trees are balanced binary search trees like: 二进制树的最重要应用之一是平衡的二进制搜索树,例如:

  • Red-Black trees 红黑树
  • AVL trees AVL树
  • Scapegoat trees 替罪羊树

These type of trees have the property that the difference in heights of left subtree and right subtree is maintained small by doing operations like rotations each time a node is inserted or deleted. 这些类型的树具有以下性质:通过在每次插入或删除节点时进行诸如旋转之类的操作,可以使左子树和右子树的高度差保持较小。

Due to this, the overall height of the tree remains of the order of log n and the operations such as search, insertion and deletion of the nodes are performed in O(log n) time. 因此,树的整体高度保持为log n的顺序,并且在O(log n)时间内执行诸如搜索,插入和删除节点之类的操作。 The STL of C++ also implements these trees in the form of sets and maps. C ++的STL还以集合和映射的形式实现这些树。


#5楼

In C++ STL, and many other standard libraries in other languages, like Java and C#. 在C ++ STL和许多其他语言的标准库中,例如Java和C#。 Binary search trees are used to implement set and map. 二叉搜索树用于实现集合和映射。


#6楼

The main application is binary search trees . 主要应用是二叉搜索树 。 These are a data structure in which searching, insertion, and removal are all very fast (about log(n) operations) 这些是数据结构,其中搜索,插入和删除都非常快(关于log(n)操作)

http://www.lbrq.cn/news/1410535.html

相关文章:

  • 怎么做像知乎一样的网站/网站域名费一年多少钱
  • wordpress二级菜单代码/谷歌搜索优化seo
  • 深圳交易网站建设/网络营销产品
  • ppt图标网站链接怎么做/中国最大的企业培训公司
  • 东莞金融网站建设/最新今日头条
  • 织梦后台点击网站主页/搜索引擎优化涉及的内容
  • 公司网页制作哪家强/seo投放营销
  • 建网站内容/整站seo排名
  • 网站营销应该怎么做/搜索引擎营销的优缺点及案例
  • wordpress评论cdn刷新/汕头seo代理
  • 深圳网站建设 东毅虎/免费网络推广平台
  • 海南做网站的公司/网站网络推广公司
  • 网站开发 明细/seo效果最好的是
  • 深圳网站推广优化/个人网页在线制作
  • 临朐整站优化/网页百度网盘
  • 高唐网站建设服务商/win7运行速度提高90%
  • 做阅读任务挣钱的网站/app推广地推接单网
  • 网站ip改变 备案/网站seo优化建议
  • html全屏网站/百度浏览器下载安装2023版本
  • 网站pc端和手机端分离怎么做/网站seo推广营销
  • 云南微网站搭建费用/怎么搭建自己的网站
  • 网站建设未验收会计账务处理/成都网站推广公司
  • 网络搏彩网站做代理/快速排名精灵
  • 上海门户网站制作/百度市场应用官方app
  • 营销型网站建设合同范本/微博推广方式
  • 中科院网站做的好的院所/网站查询信息
  • 做网站运营需要学什么条件/自己做网站需要什么条件
  • led照明企业网站模板/免费发布信息不收费的网站
  • 网站设计过时/互联网推广运营是干什么的
  • 所得税汇算清缴在哪个网站做/如何优化网页加载速度
  • 48.Seata认识、部署TC服务、微服务集成
  • C语言网络编程TCP通信实战:客户端↔服务器双向键盘互动全流程解析
  • 机器学习05-朴素贝叶斯算法
  • Spark03-RDD02-常用的Action算子
  • IC验证 AHB-RAM 项目(一)——项目理解
  • Mac(四)自定义按键工具 Hammerspoon 的安装和使用