computer 版 (精华区)

发信人: remember (Learning C++), 信区: program
标  题: Re: 找第n个最小数
发信站: 听涛站 (2001年10月14日12:34:37 星期天), 站内信件

 ok....可以看到,这个程序在最坏情况下是O(n^2),
 平均时间应该是O(n),对否?
 要是要求最坏情况下是O(n)呢?

 btw: 你的签名档、昵称弄的我每次都觉得看不见部分东西(我用的是Sterm)

【 在 gutentag ( Bonjour && deeply in LOVE on the web ) 的大作中提到: 】
: //用JAVA 写的,手头只有这个
: public class find {       
:     private static int[] numbers = {5, 6, 3, 2, 4, 7, 1, 9, 8 };
:     public static void main (String args[ ]){
:         System.out.println(find_n_smaller(0, numbers.length-1, numbers, 3));
:     } 
: //因为JAVA不支持指针操作,所以把参数改成数组元素的起止索引号
:     private static int find_n_smaller(int s, int f, int[] num, int n) {
:         int j=s, k=s+1, l=f, t;
: .................(以下省略)

--
    洛阳亲友如相问  一片冰心在玉壶
※ 修改:·remember 於 10月14日13:45:44 修改本文·[FROM: 匿名天使的家]
※ 来源:·听涛站 tingtao.dhs.org·[FROM: 匿名天使的家] 
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:1.093毫秒