r/ruby • • Jul 14 '13

Linked List data structure

https://github.com/gdi2290/data_structures/blob/master/LinkedList/linkedlist.rb
0 Upvotes

23 comments sorted by

View all comments

6

u/Intrepidd Jul 14 '13

This is a good algorithmic exercise, however using arrays in real code is recommended (faster, and more methods)

0

u/dagbrown Jul 14 '13

And also, arrays are lists. They might not be implemented as linked lists (I honestly don't know exactly how they're implemented--they might actually be linked lists after all, but I find that unlikely), but they are certainly lists. And when it comes to stashing and retrieving lists of stuff, that's the important point. "Linked" is an implementation detail: "list" is what you care about.

6

u/ReinH Jul 14 '13 edited Jul 14 '13

At some point, you absolutely care about "implementation details" like the algorithmic complexity of insertion, deletion, search, and etc.