Choosing data structures

With this many data structures to choose from, it can be hard to know which one to choose during a specific problem. There are some rules to follow, and here is a short summary of the main characteristics of the individual data structures.

Arrays

Arrays are efficient if you have to know the size of the collection beforehand. That means the size is fixed, and if you want to change the size, you have to create a new array and copy the elements over. On the other hand, random access is very fast; it can be done in constant time.

Lists

Lists are implemented using linked lists, which are items linked together using pointers. This means that traversing a linked list is not super-efficient, because a lot of pointers have to be followed. ...

Get F# for Quantitative Finance now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.