由买买提看人间百态

topics

全部话题 - 话题: treap
(共0页)
d**********x
发帖数: 4083
1
来自主题: JobHunting版 - Haker Rank Median...
那题目貌似就没卡复杂度。。。枉我昨天下班后还捏着鼻子写了个treap。。。结果证
明是输出格式错了,只过了两三个case的可以考虑检查一下输出格式
思路大致就是用order statistics tree。每次查询都是O(logn)。手写最大问题在于没
法定制容器的行为。。。
好吧,然后想了一下,如果用两个heap加一个map的话也是可以的,因为只是查询
median,没有要求随机查询kth元素,所以还是写复杂了
附上代码,treap是个随机平衡树,可以拿去用。
#include
#include
#include
#include
using namespace std;
template
class Treap {
public:
class Node {
public:
Node(const T& value)
: value_(value),
left_(NULL),
right_(NULL),... 阅读全帖
f*****d
发帖数: 36
2
来自主题: JobHunting版 - Oracle SDET onsite 面经
1. Given a sorted dictionary of an alien language, find order of characters
2. discuss deeper into java arrayList and linkedList
How to create one chunkList have both of their advantage? My idea is to
implement it with a linkedlist but each node is an arrayList of adjusted
capacity.
when to use which one
how does java implement arrayList?
3. lunch interview
talking about current and past projects, which is the hardest one you have
ever met and some common behavior questions
4. design problem
add... 阅读全帖
b********6
发帖数: 35437
3
来自主题: JobHunting版 - 大G家的一道新题,来讨论讨论
这个结构怎么样,可以存两个信息,tree按时间排,heap按值排。这样可以实现add,
remove的logn,get max的O(1),但是不能同时get min, 建两个treap可以解决问题不
过面试的时候应该不能用
https://en.wikipedia.org/wiki/Treap
l***i
发帖数: 1309
4
来自主题: JobHunting版 - 关于external sort/search & 234tree/rb tree
multiway merge is not hard, if you know AVL tree or treap, you could get
away with 2-3-4 tree or Red-black tree as they do similar things.
e********2
发帖数: 495
e********3
发帖数: 229
6
来自主题: JobHunting版 - 问一道面试设计题
这个treap如何应用到这道题上?
比如:
名字 call times
abc 50
abcd 100
abd 200
怎么通过call times在trie中进行排序?
(共0页)