DEV Community

Innocent Mambo
Innocent Mambo

Posted on


Introduction To Data Structures and Algorithms

Scary topic huh! Well not really. Like every problem, to understand it, we divide it into sub-sections and combine what we've gathered.
Data - Data can be defined as facts or figures, or information that's stored in or used by a computer.

Structures - A structure is used to represent information about something more complicated than a single number, character, or Boolean can do.

Therefore data structures are a way of collecting and organizing data in such a way that we can perform operations on data. Example: Linked list, Graphs, Tree.

Types of Data Structures

  1. Linear Data Structures - Items are arranged in a sequence. Example: Array
  2. Non-linear - Data items are not arranged in a sequence. Example: Tree, Graph
  3. Dynamic - It expands or shrinks depending on the program requirements
  4. Static - Are those whose size and structures associated memory locations are fixed.

Algorithms - They are a set of instructions(finite or logical) that are used to solve a problem
Algorithms are said to be efficient and fast when they take less time to execute and consume less memory.

Properties of an Algorithm

  • Input
  • Output
  • Finiteness
  • Definiteness
  • Correctness

An algorithm generally requires the following components:

  • Instruction Space: A space to store the the executable version of the program.
  • Data Space: Space required to store the constants and variables.
  • Environment Space: Stores the environment information. Data Structures and Algorithms come in handy in problem solving.

A problem can be described as something that has an initial state, goal state and the number of steps taken to achieve from the initial to goal state.
Think of cooking as the problem we are trying to solve, an algorithm would be identifying the ingredients, cutlery, heating equipment.

We can't talk about Algorithms and avoid the topic on Time and Space complexity.

  1. Time complexity is the amount of time a program requires to execute until completion.
  2. Space Complexity is the amount of memory space required by the program during execution.

Top comments (1)