什么时候应该使用链表的真实世界示例? [英] What are real world examples of when Linked Lists should be used?

查看:36
本文介绍了什么时候应该使用链表的真实世界示例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

另一位程序员提到,在他的职业生涯中,他们还没有找到在任何专业软件中使用链表数据结构的用例.我想不出任何好的例子.他主要是 C# 和 Java 开发人员

Another programmer was mentioning that they haven't found a use case for using a linked list data structure in any professional software in his career. I couldn't think of any good examples off the top of my head. He is mostly a C# and Java developer

谁能举例说明这是解决特定现实世界问题的正确数据结构?

Can anyone give some examples where this was the correct data structure to solve a particular real world problem?

相关: 什么是链表的实际示例?>

推荐答案

一个真实世界的例子是 FIFO 队列.一个简单的基于数组的列表对此非常不利,因为您需要在一端添加并在另一端删除,并且这些操作之一将是 O(n) 使用基于数组的列表(除非您添加额外的逻辑到使用开始和结束索引),而两者都是 O(1) 和链表,无需额外的努力.

A real-world example would be a FIFO queue. An simple array-based list is pretty bad for that because you need to add at one end and remove at the other end, and one of those operations will be O(n) with an array-based list (unless you add extra logic to work with a start AND end index), while both are O(1) with a linked list without extra effort.

这篇关于什么时候应该使用链表的真实世界示例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆