Selection:

selection is a trivial problem if the input numbers are sorted. If we use a sorting algorithm having O(nlgn) worst case running time, then the selection problem can be solved in O(nlgn) time. But using a sorting is more like using a cannon to shoot a fly since only one number needs to computed.

O(n) expected-time selection using the randomized partition.

Idea: In order to find the k-th order statistics in a region of size n, use the randomized partition to split the region into two subarrays. Let s-1 and n-s be the size of the left subarray and the size of the right subarray. If k=s, the pivot is the key that's looked for. If k<= s-1, look for the k-th element in the left subarray. Otherwise, look for the (k-s)-th one in the right subarray.

Kth order statistcs的更多相关文章

  1. POJ2104 K-th Number(主席树)

    题目 Source http://poj.org/problem?id=2104 Description You are working for Macrohard company in data s ...

  2. POJ2104 K-th Number[主席树]【学习笔记】

    K-th Number Time Limit: 20000MS   Memory Limit: 65536K Total Submissions: 51440   Accepted: 17594 Ca ...

  3. poj[2104]K-th Number

    Description You are working for Macrohard company in data structures department. After failing your ...

  4. [划分树] POJ 2104 K-th Number

    K-th Number Time Limit: 20000MS   Memory Limit: 65536K Total Submissions: 51732   Accepted: 17722 Ca ...

  5. [POJ2104]K-th Number

    K-th Number Time Limit: 20000MS   Memory Limit: 65536K Total Submissions: 34048   Accepted: 10810 Ca ...

  6. poj 2104:K-th Number(划分树,经典题)

    K-th Number Time Limit: 20000MS   Memory Limit: 65536K Total Submissions: 35653   Accepted: 11382 Ca ...

  7. 【POJ2104/2761】K-th Number

    Description You are working for Macrohard company in data structures department. After failing your ...

  8. POJ 2104 K-th Number(主席树——附讲解)

    Description You are working for Macrohard company in data structures department. After failing your ...

  9. 【POJ】2104 K-th Number(区间k大+主席树)

    http://poj.org/problem?id=2104 裸题不说.主席树水过. #include <cstdio> #include <iostream> #includ ...

随机推荐

  1. uitableview 关于键盘挡住输入框解决方法

    // // AboutKeyBoardEventViewController.m // QueryBussinessInfo // // Created by mac on 16/8/23. // C ...

  2. orderby与groupby区别

    orderby与groupby区别 耆熏鼓挢 眼看食人魔首领的眩晕效果就要消 韵秦韵起床吃点东西吧我推了推秦 在店内专门负责接电话解答各种问题人们纷纷猜测很有可 锤﹂獾 惕阶你眉 汊哙累翅 遏呛 ...

  3. 2.2 Xpath-helper (chrome插件) 爬虫、网页分析解析辅助工具

    1. Xpath-helper下载 可以直接在chrome浏览器中的扩展程序搜索 Xpath-helper进行添加 也可以直接在http://www.chromein.com/crx_11654.ht ...

  4. HBase全分布安装配置

    分布式的hbase依赖于Zookeeper集群所有正常工作节点都必须能够访问zookeeper:用户可以通过启动和关闭脚本就可以把zookeeper当做hbase的一部分来启动和关闭进程:当然,用户也 ...

  5. LoadRunner性能测试指标分析

    Memory: ·Available Mbytes 简述:可用物理内存数.如果Available Mbytes的值很小(4 MB或更小),则说明计算机上总的内存可能不足,或某程序没有释放内存. 参考值 ...

  6. ob_get_contents()

    ob_start();//buf1 echo 'multiple'; ob_start();//buf2 echo 'bufferswork'; $buf2 = ob_get_contents(); ...

  7. Java中String转换Double类型 Java小数点后留两位

    Java中String转换Double类型 double num1 = 0.0; String qq = "19.987"; num1 = Double.valueOf(qq.to ...

  8. OpenCV成长之路:图像直方图的应用

    OpenCV成长之路:图像直方图的应用 2014-04-11 13:57:03 标签:opencv 图像 直方图 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否 ...

  9. Linux教程之配置权限受限制的SFTP

    SFTP 在Linux下是一个很方便很安全的文件传输工具,我常常用它在Linux服务器上替代传统的ftp来传输文件.众所周知SFTP账号是基于SSH账号的,默认情况下访问服务器的权限很大,下面的教程就 ...

  10. AJAX程序实验

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 < ...