English 中文(简体)
如何建立有时限的数据结构
原标题:How to create a data structure with run time limits

I need to implement a data structure that supports insertion deletion and search in O(log(n)) and extracting a special object in O(1). My Data structure needs to hold vehicles sorted by their ID and every vehicle has a field which represents the time until the next service. I need to extract the vehicles that needed to be services next in O(1). All suggestions are welcome.

我的理解是,我需要两个单独的数据结构,我想有1个系统和1个优先事项。 以其他参数分类,但持有同一点的复印件。 我面临的问题是,当我试图从“定点”结构中删除时,我仍把垃圾放在其他数据结构上(优先位置)。

最佳回答

一个散列台将比奥洛(n)更有利于插入、删除和搜索。 这假定,在你成长桌子时,你永远不必重述一切。 困难部分是在O(1)时间找到“灰色”车辆。

根据执行情况,min heap将在O(1)和O(log(n)之间(摊销)插入你,并确定最低项目为O(1)。 从蒸汽中删除一个项目是O(log(n))作业,但 勘测/em>在肥皂中任意使用的项目多于O(log(n))。

如果我执行,我就使用两个单独的数据结构:一个散列桌和一个min。 理由是,散列表提供了非常迅速的插入、删除和寻找,而且根据服务时间做出了规定。 唯一符合你最初要求的地方是清除一辆汽车,因为这需要寻找一个任意的物品。

实际上,尽管可能很幻觉,但还是有可能把两个数据结构结合起来,以便你的桌子能够储存(参考实际数据)而不是实际数据物体。 只要他知道自己是哪里(即有父母一方以及左派和正确的儿童点),那么你就能够利用散坐桌寻找 no子,从头上消除 no子。

问题回答

暂无回答




相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?