Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View clc80's full-sized avatar

Claudia Maciel clc80

View GitHub Profile
@clc80
clc80 / App.js
Last active June 4, 2018 23:25
With new li to render
import React, { Component } from 'react';
import Form from './components/Form'
import './App.css';
class App extends Component {
constructor(props) {
super(props);
this.state = {
formItems: ['one', 'two', 'three']
@clc80
clc80 / App.js
Last active June 4, 2018 23:31
getting text from input field
import React, { Component } from 'react';
import Form from './components/Form'
import './App.css';
class App extends Component {
constructor(props) {
super(props);
this.state = {
formItems: [],
@clc80
clc80 / App.js
Created June 4, 2018 23:38
Changing the state with new value
import React, { Component } from 'react';
import Form from './components/Form'
import './App.css';
class App extends Component {
constructor(props) {
super(props);
this.state = {
formItems: ['one', 'two', 'three'],
@clc80
clc80 / App.js
Created June 4, 2018 23:55
Finished app
import React, { Component } from 'react';
import Form from './components/Form'
import './App.css';
class App extends Component {
constructor(props) {
super(props);
this.state = {
formItems: [],
1. Clean Code is code that is easy to read and understand. Code that someone else can come in and see what is happening as well as code that someone else can easily understand.
2. Similar to what was stated in the article where it says," ..provides a cautionary tale to all involved in safety-critical development...". There has been talk about automating airplanes to fly themselves and that is a scary thought, scarier than a self driving car. Yes there's alot of automation in flying an airplane but a crash in an airplane is fatal. There is so much at risk that one bug can be the end of many lives. Older airplanes with their pneumatic parts yes they fail but the pilot can usually detect the malfunction and compensate. Any code that will affect peoples lives should always exceed standards.
3. This is not clean code because it is not self documenting, the variables could be better names and it does not pass the squint test. Better code would look like this:
FUNCTION do(temperature, type)
I
Short Answer
1. Why do programmers use pseudocode?
Programmers use pseudocode because it's more like english than a coding language. Writing in Pseudocode helps put
the code together without having to worry about the correct syntax.
2. If you run pseudocode on your computer what would happen?
Pseudocode willl not run on a computer it will return errors.
1. A line of people at an amusement park ride.
The line is composed of members, represented as strings.
There is a front to the line, as well as a back.
When someone enters the line, place them at the end.
People may leave the line whenever they see fit, and those behind them take their place.
Given the above real-world information, use an array data structure to code the following solution.
a) Use an array input: ["Vivian", "Ava", "Josh", "Patrick", "Mike"]
b) Insert a new person, "Mary" at the end of the line. In other words, you should insert Mary after Mike.
1. What is the main difference between a stack and a queue?
The main differences between stack and queue are that stack uses LIFO (last in first out) method to access and add data elements whereas Queue uses FIFO (First in first out) method to access and add data elements
2. What are the similarities between stacks and queues?
One big similarity is that the user is not allowed to pick items from the middle of the queue or the stack. No indexes are available, as in arrays.
3. Imagine you are an engineer tasked with implementing the UNDO and REDO options in a word processor such as Microsoft Word. Which data structure would you use for each option and why?
In the case of an UNDO it would be a stack because we want to undo the last thing that we deleted.
In the Redo task would also be a stack. We usually want to redo the last command that we did so it's also a last in first out situation.
1. What is a hash table?
Just like it sounds like a hash table is a table. A hash table just like an object works with the idea of a key value pair.
The key should be a unique key from all the others in the table. A hash table is made up of two parts: an array (the actual table where the data to be searched is stored) and a mapping function.
2. What is hashing?
Hashing is the conversion from a string to a numerical index. In hash tables the key is usually a string. The process of hasing will create a numerical index value for that string.
It needs to be converted into a number since arrays can only be indexed by numbers.
3. How does a hash table store data?
With an array I can put something in the boxes, then get it back by telling the program go get what is in box 5. This is known as direct addressing, and in the case of arrays, it takes a single operation due to the way RAM works.
1. Using proper pseudo-code, describe the following primitive algorithms:
Making coffee;
Clean pot
Put water in the pot
Throw away old filter
Add new filter
Measure out coffee grounds
Place coffee grounds in filter
Add water in tank