Skip to content

apidsl/patterns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

patterns

Algorithmics

Algorithmic concepts | Super Study Guide

Algorithmic concepts

By Afshine Amidi and Shervine Amidi

Overview

Algorithm

Given a problem, an algorithm A\mathcal{A}A is a set of well-defined instructions that runs in a finite amount of time and space. It receives an input III and returns an output OOO that satisfies the constraints of the problem.

As an example, a problem can be to check whether a number is even. In order to do that, an algorithm could be to check whether the number is divisible by 2.

Iteration

An iterative algorithm is an algorithm that runs through a sequence of actions. It is characterized by either a for or a while loop.

Suppose we want to return the sum of all of the elements of a given list. An example of an iterative algorithm would be to sequentially add each element of the list to a variable, and return its final value.

Recursion

A recursive algorithm uses a function that calls itself. It is composed of the following components:

  • Base case: This is the set of inputs for which the outputs are known.
  • Recursive formula: The answer of the current step is based on function calls relying on previous steps, eventually using the base case answer.

Releases

No releases published

Packages

No packages published