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 ...
随机推荐
- bootstrap validator html attributes 选项
常用的html属性:data-fv-message="The username is not valid"data-fv-notempty="true"data ...
- CVE-2014-4115漏洞分析(2014.11)
CVE-2014-4115漏洞分析 一.简介 该漏洞是由于Windows的Fastfat.sys组件在处理FAT32格式的硬盘分区存在问题.攻击者利用成功可导致权限提升. 影响的系统包括: Windo ...
- 2.2 Xpath-helper (chrome插件) 爬虫、网页分析解析辅助工具
1. Xpath-helper下载 可以直接在chrome浏览器中的扩展程序搜索 Xpath-helper进行添加 也可以直接在http://www.chromein.com/crx_11654.ht ...
- swift 手势之UIPanGestureRecognizer
- javaWeb知识的回顾
16年7月毕业,现在工作也有3个多月了.一直是在做一些增删改查,技术上没有太大的突破,自己总结下原因,还是原理理解的不够透彻,地基没打好就盖不成高楼. 在51cto上找到了佟刚老师的视频,快进游览一遍 ...
- POJ 2239 Selecting Courses
二分图的最大匹配.课程和时间可以看做二分图. #include<cstdio> #include<cstring> #include<cmath> #include ...
- 常用CSS样式 持续更新
+ CSS + a标签 - 去除a标签下划线 a{ text-decoration:none; } - 未被访问状态下的a标签去除下划线 a:link{ text-decoration:none; } ...
- C#项目转php工作记录
1.Visual Studio Ultimate 2012 静态激活密钥 RBCXF-CVBGR-382MK-DFHJ4-C69G8 http://blog.csdn.net/jpzy520/arti ...
- Sikuli:创新的图形化编程技术
Sikuli是一种使用截图进行UI自动化测试的技术.Sikuli包括sikul脚本,基于Jython的API以及sikuli IDE.Sikuli可以实现任何你可以在显示器上看到ui对象的自动化,你可 ...
- hdu_1536_S-Nim(DFS_SG博弈)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1536 题意:首先输入K ,表示一个集合的大小 , 之后输入集合, 表示对于这对石子只能去这个集合中的元 ...