“Algorithms and Data Structures Tutorial - Full Course for Beginners” by FreeCodeCamp.org

Abstract

Following along to a FreeCodeCamp Video covering algorithms and data structures.

Terms

  1. Algorithm - A set of steps or instructions for completing a task. in CS it more often means the set of steps a program takes to finish a task.
  2. Algorithmic thinking - Solving problems by breaking it down step by step and applying an specific strategy
  3. Time complexity - Simply the amount of time an algorithm takes to solve the problem
  4. Space complexity - the amount of memory required to run the algorithm

Timestamps

Algorithms

“the set of steps a program takes to finish a task.”

  • Simple search, Linear search, Sequential search
  • Binary Search

Data structures

Notes

  • lots of ways to solve the same problem
  • not enough to know all the different algorithms, you also need to know when to apply them
  • algorithmic thinking is more important than knowing all the common algorithms
  • Algorithms must have a clear problem statement.
  • each step in your algorithm must be atomic and unable to be broken down further
  • algorithms should produce a result even if that result is null

Intro

Algorithmic thinking

To apply an algorithm:

  1. gain an understanding of the problem at hand
  2. break the problem into several steps
  3. apply the appropriate algorithm

Guess the number

guys strat was to brute force by guessing each number starting at 1 and moving up. therefore hewill need as many guesses as the number is, if the number is 10 he needs to guess 10 times.

girls strat was much more methodic, guessing a number in the halfway point (5) and when she is told thats too low she guesses a number halfway between 6 and 10 (8), too low so she guesses 9 and then 10. in this example **she only needed to guess 4 times. **

Algorithm Requirements

  • Ingredients
    • clearly defined problem statement
    • input
    • output
  • other requirements
    • Algorithm steps must be in a very specific order
    • the steps must be distinct/atomic
    • the algorithm should produce a result
    • the algorithm should complete in a finite amount of time

Efficiency is measured by time and space.

  • time complexity
  • space complexity

you can measure how long it takes in the:

  • Best case
  • worst case
  • Average
xychart-beta
title "Algorithm time complexity"
x-axis "N" 10 --> 100
y-axis "Steps" 10 --> 100
line [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
KeyAnswer
InputA sorted list of
OutputThe position in the list of the target value we are searching for or a output indicating the target does n
Problem statement
Steps 1. Goto the middle element of the ordered list.
2. compare the current element to the target element.
3. if current element = target element then return the current element and end.
4. if current element < target element then ment then ment
Steps in specific order?
Each step is distinct?
Algorithm produces a result?
**Algorithm completes in a in a finite amount