Skip to content

Instantly share code, notes, and snippets.

View MichaelDCooper's full-sized avatar

Michael Cooper MichaelDCooper

  • Spotify
  • Los Angeles, CA
  • 10:03 (UTC -07:00)
View GitHub Profile
1. Write pseudocode for bubble sort.
FUNCTION bubbleSort(data)
SET swapped to false
FOR i = FIRST index of data to LAST index of data - 1
IF data[i] > data [i + 1]
SET tmp to data[i]
set data[i] to data [i+1]
set data [i+1] to tmp
1. What is a real-life scenario that uses linear search?
Looking for a user transaction receipt in a linked list.
2. What is a real-life scenario that uses binary search?
Searching for an item in inventory, through a sorted list containing millions
of inventory items.
3.Given the alphabetically sorted collection in this checkpoint, how many iterations
1. Define and compare recursion and iteration.
Recursion is when a function will call itself until a condition is met. iteration
is when each value in a date structure is passed through a loop until a condition
is met or every value within the data structure has passed through the loop.
2. Name five algorithms that are commonly implemented by recursion.
1. Factorial Algorithm.
1. What is time complexity and what is its relation to algorithms?
Time complexity is a measure of how long an algorithm takes to run.
2. What is runtime?
Runtime is the actual period of time it takes a program to run.
3. How is the runtime of an algorithm calculated?
1. Using proper pseudo-code, describe the following primitive algorithms:
-Making coffee;
-Washing dishes;
-A choice of your own.
FUNCTION makeCoffee
SET kettleOn to true
WHILE coffeeAmount < 22g && coffeeAmount
@MichaelDCooper
MichaelDCooper / graphs_and_trees_answers.txt
Created February 12, 2019 04:23
Bloc Graph and Tables Answers
1.What is a binary tree and what makes it unique to other trees?
A binary tree is a tree data structure where each branch points to two values,
one with a value greater than the branches value to the right, and one of lesser
value to the left.
2.What is a heuristic?
A heuristic is a guess that an algorithm makes to solve a problem quickly.