@elibelly

@elibelly

@elibelly

# The study of problem solving

Looking at a problem and working out a way a computer might be able to help you solve it.

@elibelly

1. The scientific and practical approach to computation and its applications.
2. The systematic study of the feasibility, structure, expression, and mechanization of the methodical procedures (or algorithms) that underlie the acquisition, representation, processing, storage, communication of, and access to information.

# More formally...

@elibelly

we want to, like, get information or do stuff to it soo how do we science that and then make computers do all the work real fast

@elibelly

@elibelly

# What is an algorithm ?

An unambiguous set of steps to complete a task or computation

It is very much like a recipe for a computer

@elibelly

# Algorithm: Find the max

Problem: Given a list of positive numbers, we need to return the largest number on the list.

Input: A list, "L", of positive numbers. This list must contain at least one number.

Output: A number, "n", which will be the largest number of the list.

1. Set "max" to 0.
2. For each number x in the list L, compare it to max. If x is larger, set max to x.
3. "max" is now set to the largest number in the list.

@elibelly

# Algorithms & Computer Science

1. Does an algorithm actually exist to do a thing?
2. Are we totally sure that the algorithm works for all possible inputs?
3. How long does the algorithm take to run?
4. How much memory space does it require?
5. Once we know it’s possible to solve a problem with an algorithm, is the algorithm the best possible one. Can the problem be solved more quickly?

@elibelly

# Time Complexity

The amount of time an algorithm takes to run in relation to the number of inputs

@elibelly

# Big O Notation

A mathematical notation that describes a  measure of the execution of a function as the inputs approach infinity

O( ? )

Example: O( 1 ) , O( n ), O( log n ) where n represents the number of inputs

@elibelly

@elibelly

# Let's say you want to watch a box set....

10 episodes 10 hours 16 hours

@elibelly

# Let's say you want to watch a box set....

10 episodes 10 hours 16 hours
50 episodes 50 hours 16 hours

@elibelly

# Let's say you want to watch a box set....

10 episodes 10 hours 16 hours
50 episodes 50 hours 16 hours
n episodes n hours 16 hours
Time complexity O( n ) O( 1 )

Conclusion: Ordering Online is a more scalable algorithm!

@elibelly

## What is the time complexity of searching for a maximum number in an array?

[ 34, 7, 0, 4, 12, 11, 104, 3, 19 ]

@elibelly

# Data Structures

A data structure is a particular way of organizing data in a computer so that it can be used efficiently

• Array*
• Stack*
• Queue*
• Tree*
• Heap
• Graph*
• Hash Map

@elibelly

## Queue

pop()

push(book)

dequeue()

//remove

👀peek()

🤔isEmpty()

👀peek()

🤔isEmpty()

### LIFO

Last In, First Out ordering

### FIFO

First In, First Out ordering

@elibelly

## Graphs

Node-based data structures. A tree is a type of graph.

@elibelly

@elibelly

• Search
• Sort
• Insert
• Find
• Delete

@elibelly

# Algorithm: Find the max

Problem: Given a list of positive numbers, we need to return the largest number on the list.

Input: A list, "L", of positive numbers. This list must contain at least one number.

Output: A number, "n", which will be the largest number of the list.

1. Set "max" to 0.
2. For each number x in the list L, compare it to max. If x is larger, set max to x.
3. "max" is now set to the largest number in the list.

@elibelly

## Binary Search Tree

[ 3, 5, 20, 11, 8 ]

[ 8, 3, 11, 5, 20 ]

3

20

11

8

5

Time Complexity O(n)

Time Complexity O(log n)

## Unbalanced Tree

[ 20, 11, 8, 5, 3 ]

Time Complexity O(1)

20

11

8

5

Time Complexity O(n)

@elibelly

@elibelly

# THANKS!

@elibelly

#### Get your CS degree in 10 minutes*

By Eli Schütze Ramírez

### Get your CS degree in 10 minutes*

Brief introduction to some Computer Science concepts for codebar monthlies.

• 609