Data Structures

and Introduction to Linear and Non-Linear Data Structures

Introduction to Data Structures

Data Structures are an integral part of programming in any language. They are very important for storing, organizing, managing, analyzing and updating the data efficiently.

There are 2 Types of Data Structures :

1. Linear Data Structures : In this, the data is stored in sequential manner, that is 1 after another. There is at max 1 preceding and succeeding element in Linear data structures. For example, Arrays, Linked Lists, Stacks, Queues, Strings etc.

2. Non-Linear Data Structures : In this, the data is stored in such a way that there is no definite order. There can be any number of children. For example, Trees and Graphs.

We will only see the data structures included in std::collections module in this section

Static and Non-Static Data Structures

1. Static Data Structures : These are data structures, that have been allocated fixed size of memory. For example, arrays. We can not grow or shrink the memory allocated to an array. ( We can do reallocation, that is allocate a new memory altogether, copy the contents from previous allocation, and free the previous allocation )

2. Dynamic Data Structures : These are data structures that can be allocated memory at runtime. For example, Linked Lists. These are much slower in access time, but simpler and easier to write and maintain, especially for applications like stacks, queues, trees etc.


I will keep this article short and to the point. We will see some built in data structures and how to use them in Rust in next articles.

Thank You