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
Assignment 1: | |
browser -> server: HTTP POST https://fullstack-exampleapp.herokuapp.com/new_note | |
server -> browser: requests browser to submit GET request to /notes | |
browser -> server: HTTP GET https://fullstack-exampleapp.herokuapp.com/notes | |
server -> browser: HTML code | |
browser -> server: HTTP GET https://fullstack-exampleapp.herokuapp.com/main.css | |
server -> browser: main.css | |
browser -> server: HTTP GET https://fullstack-exampleapp.herokuapp.com/main.js | |
server -> browser: main.js |
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
> Run the commands sort, wc and uniq on the commands.js file. Explain how they work and what the output was. | |
A: The sort command organizes the output file alphabetically and by line. The most indented lines get sorted first, alphabetically. The outermost line with no indentations get sorted the last. The sort command on commands.js file start of with the two breaks that are most indented and alphabetically on top, followed by the most indented next letter, and so forth. The wc command prints out the total lines of code in the file, followed by total words and total byte count of the file. The commands.js file has 36 lines of code, 73 words, and 780 byte count. The uniq command sorts each line in a file and only returns the lines that are different from the one above it. If a file has a duplicate code in consecutive lines, uniq removes the duplicate code. The commands.js had no duplicate consecutive lines so all code written was returned as is. | |
> Using the pipe (|) connect at least two commands and run it on |
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
> What is a Node module? | |
A: A Node module is a set of function that need to be included in our application. They are considered to be the same as JavaScript libraries that can be imported and exported into your app. | |
> What is the main difference between exports and module.exports? | |
A: The main difference between exports and module.exports is that exports is a reference to module.exports and cannot reassign the module.exports object. So when exports is assigned a function, that function does not overwrite the module.exports object but can be seen as module.exports.function. | |
> Why is using exports recommended? | |
A: Using exports is recommended unless you want your app to be a specific object type. Using exports gives more fluidity over types of objects used in the app. |
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
> How do you find related data held in two separate data tables? | |
A: Related data held in two separate data tables can be found with the JOIN clause where the ON statement is either true or false. | |
> Explain, in your own words, the difference between an INNER JOIN, LEFT OUTER JOIN, and RIGHT OUTER JOIN. Give a real-world example for each. | |
A: | |
INNER JOIN: default join clause and method of combining two tables. It produces one row in the results table where values from both tables is combined where the ON statement returns true. If we have a table with student names, id and username and another table which have student comments id and username. If I wanted to find out which student wrote which comment, I would use inner join to combine student name with student comments by finding out if the id match in both tables. | |
LEFT OUTER JOIN: This returns all rows from the table that is joined first or the left and only return matching records from the right table. I would use this if I wanted to get all names of the |
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
> Write out a generic SELECT statement. | |
A: | |
SELECT * | |
FROM table | |
WHERE id > 1; | |
> Create a fun way to remember the order of operations in a SELECT statement, such as a mnemonic. | |
A: SELECT: Sally | |
FROM: Flew | |
WHERE: West |
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
> List the commands for adding, updating, and deleting data. | |
A: For adding data, first create a table with the CREATE command. Then add initial data to table with INSERT INTO command. To update data, use the UPDATE command to modify existing data. To delete data, use DELETE to delete an entry from table. Use ALTER TABLE to add, update, or delete a column. Use DROP TABLE to delete an entire table from database. | |
> Explain the structure for each type of command. | |
A: | |
1. CREATE TABLE: when using this command, the table name is specified, along with column names and data types for each column. | |
2. INSERT INTO: this command is given the column names as parameters and after stating VALUES adding values of the specific data types in paranthese for each row. | |
3. UPDATE: use SET to specify which column is targeted and providing value to be updated and WHERE to specify which row is targeted. | |
4. DELETE FROM: use this to delete an entire row of data by using WHERE to specify which row or rows. | |
5. ALTER TABLE: |
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
id | title | author | |
------+------------------------------------------+--------------------- | |
1259 | Eloquent Ruby | Russell A. Olson | |
1593 | JavaScript: The Good Parts | Douglas Crockford | |
8982 | Designing Object-Oriented Software | Rebecca Wirfs-Brock | |
7265 | Practical Object-Oriented Design in Ruby | Sandi Metz |
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
> Write pseudocode for bubble sort. | |
A: | |
FUNCTION bubbleSort(collection) | |
DO | |
swapped = false | |
FOR each i on 0 to collction length - 1 | |
IF collection[i] > collection[i + 1] then | |
swap( collection[i], collection[i + 1]) | |
swapped = true | |
END IF |
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
> What is a real-life scenario that uses linear search? | |
A: A real-life scenario would be looking through a phonebook for the first "Smith." We would look through each entry and check to see if it's "Smith" until the first "Smith" is found. | |
> What is a real-life scenario that uses binary search? | |
A: A real-life scenario would be searching for your book in a library. If you have 10 racks of books organized in alphabetical order, and you don't know which racks contains your book, check the middle rack. If not found, eliminate half of the racks based on alphabetical order of your book and search the middle of the halved racks. Continue the process until the book is found. | |
> Given the alphabetically sorted collection in this checkpoint, how many iterations would it take to find the value G using linear search? | |
A: It would take seven iterations, since the for loop would go through each letter and check if it is the correct one. Since G is the seventh letter in the collection, it would go through seven 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
> Define and compare recursion and iteration. | |
A: Iteration is when a function utilized a loop to repeat a process. Compared to recursion when a function calls itself within a function to repeat a process. They are both used for repeating a process but one (recursion) has performance issues while the other can be complicated to program. | |
> Name five algorithms that are commonly implemented by recursion. | |
A: Fibonacci sequence, factorial, mergesort, quicksort, reversing a string. | |
> When should you use recursion, and when should you avoid recursion? Give examples for each. | |
A: Recursion should be used when there are sub-problems that need to be solved before the problem can be solved. Recursion is best used in problems with tree-like structures, such as binary search, mergesort, Quicksort, etc because they would need stacks in any case. For algorithms like the fibonacci sequence, it is best to use iteration. If the input for a fibonacci sequence is large, there is a risk for a stack overflow when using recursio |
NewerOlder