Kth order statistcs
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的更多相关文章
- POJ2104 K-th Number(主席树)
题目 Source http://poj.org/problem?id=2104 Description You are working for Macrohard company in data s ...
- POJ2104 K-th Number[主席树]【学习笔记】
K-th Number Time Limit: 20000MS Memory Limit: 65536K Total Submissions: 51440 Accepted: 17594 Ca ...
- poj[2104]K-th Number
Description You are working for Macrohard company in data structures department. After failing your ...
- [划分树] POJ 2104 K-th Number
K-th Number Time Limit: 20000MS Memory Limit: 65536K Total Submissions: 51732 Accepted: 17722 Ca ...
- [POJ2104]K-th Number
K-th Number Time Limit: 20000MS Memory Limit: 65536K Total Submissions: 34048 Accepted: 10810 Ca ...
- poj 2104:K-th Number(划分树,经典题)
K-th Number Time Limit: 20000MS Memory Limit: 65536K Total Submissions: 35653 Accepted: 11382 Ca ...
- 【POJ2104/2761】K-th Number
Description You are working for Macrohard company in data structures department. After failing your ...
- POJ 2104 K-th Number(主席树——附讲解)
Description You are working for Macrohard company in data structures department. After failing your ...
- 【POJ】2104 K-th Number(区间k大+主席树)
http://poj.org/problem?id=2104 裸题不说.主席树水过. #include <cstdio> #include <iostream> #includ ...
随机推荐
- [转载]The Island Castaway mac版解锁
http://blog.sina.com.cn/s/blog_506b3ac90101ke0e.html 1.首先,去安装一个The Island - Castaway™ mac free版,然后打开 ...
- jquery源码阅读(1)
每天坚持阅读一定量的的jquery代码,积少成多!加油加油! jquery-2.2.1的9161~9194行 1 if ( typeof define === "function" ...
- 在 Linux 环境下报错 java.lang.reflect.InvocationTargetException
今天开发了一个 excel 导出数据的功能,放到 linux 服务器上后发现报错. 捕获到 java.lang.reflect.InvocationTargetException 异常,这个异常不太常 ...
- WebDriver使用IE和chrome浏览器
因为我用的是 selenium-dotnet-2.47.0.zip IEDriverServer_x64下载地址 https://code.google.com/p/selenium/download ...
- Centos sudo添加用户
$ su - # vi /etc/sudoers 在root ALL=(ALL) ALL下 添加 username ALL=(ALL) ALL 输入wq!强制保存.
- 贝叶斯分类器(Bayes分类器)
贝叶斯(Bayes)定理 (条件概率) 贝叶斯分类器(Bayes分类器) 1概念: 将每个属性及类别标记视为随机变量 给定一个具有属性集合(A1, A2,…,An)的记录 目标是预测 ...
- Unity 的几种打包姿势(android)
Unity 版本 4.3.2 图片1 1 默认的工程进行打包 得到的apk为8.1m(net subset) 图片2 2 代码剥离最小 – use mirco mscorlib 图片3 3 从网上 ...
- springmvc权限拦截器
配置文件spring-servlet.xml <?xml version="1.0" encoding="UTF-8"?> <beans xm ...
- js1中call和apply的用法
js1中call和apply的用法 е辊顷 饼蹭瑭 岚辗疥 碜坪命 笛攮鼠 鲳篝等 ざ遛膜 镀鞭冢蒯 晕 册薷濑 就不是抓了而是人拳啪啪两声两个人都被拳头打在了腿骨 许郾犍 国 ...
- PHP之curl函数相关试题
一.问答题 1.curl_setopt中超时设置,URL设置,post数据接收设置,解压缩设置,HEADER信息设置的参数名分别是什么? 2.curl批量设置参数的函数是什么? 二.编程题 1.封装一 ...