DEV Community

Cover image for Data Structures and Algorithms - Part I
Jonny
Jonny

Posted on • Updated on

Data Structures and Algorithms - Part I

What is a Data Structure

In simple terms, a data structure is a way of organizing and storing data. It's a collection of data types. It's a way of accessing and organizing items in terms of memories.

Types of Data Structures

There are mainly two types of data structures:

Types of DS

  • Primitive data structure: is a kind of data structure derived from the programming language. They are predefined and atomic in nature. They can only hold a single type and value in a specific memory location. e.g. integer, character, boolean, float, double, long, pointer, etc.

  • Non-primitive data structure: is a kind of data structure that are created using the primitive data structures, meaning they are user defined. They can hold multiple values in a chained or random memory locations. e.g. arrays, stacks, queues, linked lists, trees, graphs, etc.

Classifications of Non-primitive data structures

Non-primitive

  1. Linear data structures
  2. Non-linear data structures

1. Linear Data Structure

Is a type of data structure where the arrangement of all the elements of the data are in sequential order. Each element of the data is arranged linearly such that its attached to the previous and next elements. e.g. arrays, linked lists, queues, and stacks.

  • Static data structure: data structures with a fixed memory size. The size of the data needs to be known in advance, meaning the user cannot change the size of the data after the program runs. However, the value or the data itself can be changed. One of the advantages of static data structure is having fast access to the data. Since static data structures are contiguous, there is no need to worry about the memory location of the data. It can easily be found using indexes. The disadvantages of static data structure would be having a slower insertion and deletion process.

  • Dynamic data structure: data structures with dynamic or flexible size. The memory is allocated at run time, therefore the size of the data does not need to be know in advance. The advantages would be having faster insertion and deletion process. The disadvantage would be slower access to the data.

2. Non-linear Data Structure

Is a type of data structure where the arrangement of all the elements of the data are not in sequential order. e.g. trees, graphs.

Data Structure Diagram

Conclusion

Data Structure is the process of manipulating data. It's a way of organizing and storing data. There are many data structures. However, using appropriate data structures is always needed to save time while storing, retrieving or processing data.

Now we know what data structures are, let's move on to algorithms (Click here)

Thank you!

Jonny

Top comments (0)