This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
NewerOlder