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

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

问题描述

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



任何人都可以给出一些例子,这是一个正确的数据结构来解决一个特定的现实问题?



相关: 链接列表的实际,现实世界的例子? / a>

一个现实世界的例子将是一个FIFO队列。一个简单的基于数组的列表是非常糟糕的,因为您需要在一端添加并在另一端删除,其中一个操作将是O(n)与基于数组的列表(除非您添加额外的逻辑工作与开始和结束索引),而两者都是O(1)与链表没有额外的努力。


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?

Related: What is a practical, real world example of the Linked List?

解决方案

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天全站免登陆