用php构建quicksort

编程入门 行业动态 更新时间:2024-10-25 06:23:00
本文介绍了用php构建quicksort的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我最近阅读了有关quicksort的文章,并且想知道构建自己的功能以使用quicksort对事物进行排序是否明智,或者它是否效率不高.您认为内置排序功能比自建快速排序功能好吗?

I recently read about quicksort and was wondering whether it would be smart to build my own function to sort things with quicksort or if it would be inefficent. What do you think is the built in sort function better than a selfbuilt quicksort function?

推荐答案

来自 php/sort

注意:与大多数PHP排序一样 函数,sort()使用一个 快速排序的实施.

Note: Like most PHP sorting functions, sort() uses an implementation of » Quicksort.

PHP的核心功能将用c而不是PHP来实现,因此它们通常应该比用PHP可以自己编写的任何东西都要快得多.在某些情况下,编写自己的案例会更快,但是我想这是在您有一个非常具体的案例时,您可以为此做自己的特定优化.我认为这不太可能.

The core PHP functions will be implemented in c, rather than PHP, so they should generally be significantly faster than anything you can write yourself in PHP. There will be cases where it is faster to write your own, but I guess these would be when you have a very specific case and you can make your own specific optimisations for that. I think that is unlikely to be the case here.

更多推荐

用php构建quicksort

本文发布于:2023-11-30 17:15:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1650849.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:php   quicksort

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!