单对双链表(single vs double Linked list)
我的问题是,单个和双链表是否具有相同的操作运行时间,如表所示。 我会认为在删除案例中,双链表会更好,因为我们可以访问上一个。 因为单链表的O(n)表错了吗?
如果它们都是相同的,这种相似性是否也适用于圆形的?
谢谢。
There is a table I found below
My question is whether or not it is true that a single and double linked list have the same operation run times like the table seems to show. I would think in the deletion case for example, a double linked list would be better since we have access to previous. So is the table wrong on that being O(n) for singly linked lists?
If they are all the same, does this similarity hold for a circular one as well?
Thanks.
原文:https://stackoverflow.com/questions/39761014
最满意答案
成员未在任何地方初始化。
//initialize member = new member[15]; // 15 is just an example.
另一方面,如果大小不固定,则应考虑使用
List
。List<member> members = new ArrayList<member>();
在onclick方法中,
members.add(new member());
并访问项目,
member m = members.get(0); // first item in the list
要迭代所有项目,
for(member m : members){ // m is your member object }
member is not initialized in anywhere.
//initialize member = new member[15]; // 15 is just an example.
On the other hand, if the size is not fixed, you should consider using
List
instead.List<member> members = new ArrayList<member>();
and in onclick method,
members.add(new member());
And to access the items,
member m = members.get(0); // first item in the list
To iterate all items,
for(member m : members){ // m is your member object }
相关问答
更多-
据我所知,你试图添加新的按钮,我会建议使用非依赖按钮超链接来运行你的模块。 单击插入形状 - 矩形左右 - 并使用Selection.OnAction =“YourWorkBook'!YOURSUB” OK, I sort of figured it out. I had for some reason decided to use an ActiveX command button, instead of a plain old Form one. This seems to have made thin ...
-
创建一个按钮,每次单击都会更改Label ForeColor(Creating a button that changes Label ForeColor with each click)[2023-03-21]
这应该适合你。 Private Sub btnTextColor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTextColor.Click Static m_Rnd As New Random lblWelcome.ForeColor = Color.FromArgb(255, m_Rnd.Next(0, 255), m_Rnd.Next(0, 255), m_Rnd.Next(0 ... -
Object构造函数返回一个对象的实例,该对象的类型适合传入的值。 在你的情况下,你传入一个字符串原始值,所以你得到一个String对象。 (请注意,在JavaScript字符串原始值和String实例是两种不同的值。很难说,因为当情况需要时,JavaScript会自动将字符串原语包装在String包装器中。) typeof运算符为String实例返回“object”。 The Object constructor returns an instance of an object whose type is ...
-
在给出了另一个答案之后,我想我可以说这里使用的IoC容器仅仅SimpleIoC来自MvvmLight的SimpleIoC,并且为了在每个GetInstance(...)上获得一个新的VM实例,您只需传递一个唯一的密钥尝试解析虚拟机的实例。 所以你可以切换 var adventurerWindowVM = SimpleIoc.Default.GetInstance
(); 至 var adventurerWindowVM = SimpleIoc.Default.Get ... -
点击时创建模态(Creating modals on click)[2022-08-12]
当您从DOM树中移除#myModal并使用该ID创建一个新元素时,您的modal不会更新,因此仍然指向已移除的元素。 我建议你重构你的代码如下: 你将处理变量modal和span所有内容移动到一个单独的函数中(我将它initModal )。 你让initModal显示模态(即设置modal.style.display = 'block' )。 您可以使initModal返回modal ,以便在初始化后可以轻松地应用背景颜色等自定义设置。 你设置了btn.onclick = initModal 。 所有的应用 ... -
将此行从JsonTaskComplete移到类级别,使其成为类字段: ArrayList
wallpapersList = new ArrayList (); 现在执行此操作以获取OnItemClickListener的壁纸 Wallpaper obj = wallpapersList.get(position); move your this line from JsonTaskComplete to class level to make it clas ... -
selenium.click("//a[@title='Click for the Manual Class LOV']/img"); selenium.click("//a[@title='Click for the Manual Class LOV']/img");
-
点击事件中的ngFor对象(ngFor object in click event)[2022-09-10]
不要在输出绑定中使用插值 (click)="addToList(trooper)" Don't use interpolation within output binding (click)="addToList(trooper)" -
希望这可以帮助: $(document).off('click','.parent').on('click', '.child1', function(event) { alert("click1"); }); $(document).off('click','.parent').on('click', '.child2', function(event) { alert("click2"); }); Hope this helps: $(document).off('click','.pare ...
-
我的评论中的Folloup。 点击鼠标后,退出该功能。 真的没有比这更多。 public class Ball : MonoBehaviour { Rigidbody2D body; float mousePosInBlocks; bool wasDropped = false; void Start () { body = GetComponent
(); body.isKinematic = true; ...