Data Structures and Algorithms in Dart

This is a beginner-friendly series where I will be sharing my knowledge of algorithms and data structure in the Dart programing language.

This is the first part of the series, and the goal is to make you familiar with the major concepts in data structure and algorithms.

These are what you are going to learn from this part:

  • Data.
  • Data structures.
  • Algorithms
  • The concept of scalability
  • Time Complexity.

Let’s start with the meaning of data; data is basically the quantities, characters, or symbols on which operations are performed by a computer. -Oxford dictionary. Data can be stored, modified, transmitted, etc.

In the Dart programming language, data can be in the form of a string, boolean, or numbers (integers, doubles, floats, etc). For example; you can store the name of your friend like this:

String name = "Ayo"; 
print(name); //Ayo

This data can be modified, transmitted, and used by the computer program.

AData structure is simply a special way in which we store, retrieve, organize and process our data. Having sound knowledge of data structure will help you understand the best way to store your data and achieve an optimum result. In Dart we have so many options when dealing with data, some of them include List, Map, Set, etc.

You can easily store your data as a list by creating a list of the item you want to store. For example, I want to store the name of football clubs in England.

var clubs = ["Liverpool", "Arsenal", "Chelsea", "City"]print(clubs) // [Liverpool, Arsenal, Chelsea, City]

I can easily add, retrieve and remove items from the list.

I can also choose Map as my preferred data structure and it will still perform a similar function even though it is a different data structure.

var footballClub = {
'clubs': ['Liverpool', 'Arsenal', 'Chelsea', 'City'],

};
print(footballClub["clubs"]); // ['Liverpool', 'Arsenal', 'Chelsea', 'City']

The 3 aforementioned data structures share some similarities and differences. Knowing which one to use is the reason why we study data structure. For example; when you are searching for an item in a Set, it is faster relative to a List but items in a List are ordered but items in a Set are unordered. To learn more about this and the various operations that can be performed by these data structures, check out the dart language documentation.

Algorithms simply mean a set of procedures used for performing a task. It can be an algorithm for uploading an image on Twitter or an algorithm for moving your mouse across your computer screen. Algorithms are essential in software development because they ensure our software works the way we want it to work. This is why many top companies will test your algorithm skills before considering employment.

Another reason why we learn algorithms and data structures is to ensure our software scales: This brings us to the concept of Scalability.

Scalability is the concept that describes the ability of software to respond to user demands by decreasing or increasing its capacity or performance.

Using the right data structures and algorithms will ensure your software scales. To check for scalability of algorithms the memory usage and execution time are measured.

Execution time refers to the duration of time it takes for the algorithm to process a specific amount of data and memory usage is the amount of storage space it consumes during the process.

Time complexity is the measure of time taken for an algorithm to be executed and it is denoted using the famous Big O notation.

In the next part of this series, we will discuss the various types of time complexities, how to identify them and how to represent them using the Big 0 notation.

Thank you for reading till the end, I will like to read your contribution in the comment section and I look forward to seeing you in the next part.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Victor Ayodeji Ogundola

Victor Ayodeji Ogundola

I'm a Software Engineer whose major interest is creating mobile applications. I have over three years of experience working with Flutter and Android SDK