Dutch national flag problem

这个题目:separate negative and positive numbers while being stable,也就是给定一个长n数组,空间复杂度为O(1),时间为O(n), 重新排列,使得负数在前半部分,正数在后半部分,且不改变相对顺序;此题有许多变种,比如偶数奇数,在july的博客上多有讨论,自己一直对此有疑问,在stackoverflow上看到一个帖子:

 

How to sort an integer array into negative, zero, positive part without changing relative position?

 

templatetypedef回答:

This is an instance of the Dutch national flag problem studied by Edsger Dijkstra. It's interesting in that no stable solution to this problem is known that runs in O(n) time and O(1) space (or at least, the last time I checked the literature, no known solution to the problem exists).

 

Dijkstra大牛研究过,所以此题无解吗?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值