DEV Community

Cover image for CS Series πŸ‘©β€πŸš€ #4 : Intro to Data Structures and Algorithms
Abdulrahman
Abdulrahman

Posted on

CS Series πŸ‘©β€πŸš€ #4 : Intro to Data Structures and Algorithms

04 - Intro to Data Structure and Algorithms

image

  • An algorithm is every function you created in Golang or any other programming language you programmed in. Any steps (programming statements) you wrote to solve a problem. And all programming problems is about processing data. So, in Computer Science there is field of Algorithms. which focuses on dealing with processing data at scale, and analyzing the performance of an algorithm to solve programming problems such as sorting, searching, removing and so on.

05

  • So before we talk about Algorithms, let's talk about a data that a program might have
  • First of all any data in a program has a type. A data type help us define 2 things
    • a domain of allowed values
    • a set of operations on these values
  • And a program compiler will through a compilation error if we misuse a data type, for example performing multiplication on chars
    • z = x*y is not allowed
    • true/false is not allowed

06

Atomic / Simple Data

  • Have no component parts. E.g int, char , float, etc

Data Structur

  • types that can be broken into parts. for example a Person object consist of two properties : name and an age, both of them are atomic data types (string, int respectively )
    • object β‡’ broken into properties
    • array β‡’ broken into indeces
  • So a data structure is a data type whose values
    • can be decomposed into a set of atomic data or another data structure (2D Array)
    • include a structure involving the component parts (a fixed technique on how to search, store, remove and so on)
    • Possible Structures: Set, Linear, Tree, Graph

Abstract Data Types (ADTs)

  • Provide a level of Abstraction : I want to use a data structure but I don't want to know how it's implemented, for example in Golang you can append to a slice but you don't care of the implementation at the time of using the slice data structure

How to create your own data structure

While designing ADTs, a designer has to deal with two types of questions:

  • What values are in the domain? What operations can be performed on the values of a particular data type?
  • How is the data type represented?
  • How are the operations implemented?

Top comments (0)