简体   繁体   English

后端或前端中的二叉树实现

[英]Binary trees implementation in the back-end or front-end

I've learned about Binary trees and how it makes searching alot efficient. 我已经了解了二叉树及其如何使搜索效率更高。 I know databases support Binary tree searching, and there are libraries you can utilize to make this type of search in languages like javascript and python. 我知道数据库支持二叉树搜索,并且可以使用一些库以javascript和python等语言进行这种类型的搜索。 My question is, would there be a common case where you'd have to implement in the front-end or back-end a binary tree search (you setup a classes like tree and node)? 我的问题是,是否有一种常见的情况,您必须在前端或后端实施二叉树搜索(您需要设置树和节点之类的类)? Given example you have RESTful APIs that you can get or insert data, would your javascript or backend language need a Binary tree implementation? 给定示例,您具有可以获取或插入数据的RESTful API,那么您的JavaScript或后端语言是否需要Binary树实现?

Probably not, I'm no expert, you would typically see more advanced trees like B-trees in database and filesystem implementations. 可能不是,我也不是专家,您通常会在数据库和文件系统实现中看到更高级的树,例如B树

This is kind of an ambiguous question because there's always some odd problem out there that can really benefit from such, but you typically want to optimize the database to avoid implementing something like a tree yourself. 这是一个模棱两可的问题,因为总会有一些奇怪的问题真正可以从中受益,但是您通常希望优化数据库以避免自己实现像树这样的事情。

Edit: By optimizing database to avoid trees, I am referring to things like design, query optimization, and limiting results. 编辑:通过优化数据库以避免树,我指的是诸如设计,查询优化和限制结果之类的东西。

You want your front-end to be as responsive as possible so using trees would imply you have large amounts of data, which will inevitably slow down your UI. 您希望您的前端尽可能地响应,因此使用树将意味着您拥有大量数据,这不可避免地会降低UI速度。 You're better off limiting the amount of data and paginating the results; 您最好限制数据量并分页结果。 to understand why think of the application through a user's eyes - if it doesn't feel like it's working... then it must be broken. 以了解为什么要通过用户的眼光来考虑该应用程序-如果感觉它不起作用,则必须将其损坏。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM