Anda di halaman 1dari 3

Quiz 1 cheat sheet

Modified from Alex Chang 10


Valgrind used for detecting memory leaks from forgetting to fclose() and free()
- syntax: valgrind v --leakcheck=full <executable file>
Hashtable - has 2 main parts: (1) a hash function, and (2) an array the hash function maps to. Often times, each index of the array will be a linked
list to store the values that are hashed to a specific index. Struct of a hashtable node is below at left:
node* hashtable[HASHTABLE_SIZE];
typedef struct node {
char word[50]; // 50-char word
struct node *next;
} node;

typedef struct tree {


bool valid; // exists or not
struct tree *child1; // could be left side
struct tree *child2; // could be right side
} tree;

Tree - a data structure made up of nodes that have the following 2 rules: (1) A tree node can point at its children or at
NULL, and (2) A tree node may not point at any other node other than those listed in (1), including itself. Struct of a 3child tree is above right. In the diagram, black (top) is the root node and grey (point to NULL) are leave nodes. A binary
tree is a special kind of tree that has 2 children left and right.
Trie Just like tree but can have arbitrary number of children. Below are examples of binary trie and 6-child trie.
typedef struct trie {
typedef struct btrie {
bool valid;
bool valid;
struct trie*children[26];
struct btrie *children[2];
} trie;
} btrie
LANGUAGE
TYPE
VARIABLE
EXECUTION
SOURCE CODE
C
Compiled
Strictly typed
N/A
N/A
language
HTML
Markup
N/A
N/A
Available
Language,
connectionless
protocol
PHP
Interpreted
Loosely typed
Server side
Not available
language
JAVASCRIPT
Interpreted
Loosely typed
Client side
Available
language

ERROR
Wont compile
Ignores error

Error message
Fail gracefully

IP address unique to every computer to identify it on the internet. It sends data in the form of IP packets. in the form #.#.#.#, where each # is a
number within 0-255 for a total of ~4 billion IP addresses.
TCP keeps track of the data between points A and B and tell computer to resend data if packets get lost or corrupted.
Table:
Form:
<table>
<tr> <td>(0,0)</td> <td>(0,1)</td> </tr>
<tr> <td>(1,0)</td> <td>(1,1)</td> </tr>
</table>

<form action="login2.php" method="post">


Username: <input type="text" name="u-name" /><br/>
PW: <input type="password" name="p-word" /><br/>
<input type="submit" value="Log me in!/>
</form>

Port Number: HTTP = 80. SSH = 22.


form action = page youre directing to. input type password: show *s on screen. input type text: show text. input type submit = click button.
action GET = passing variables in URL (ex. Search, etc.). On next page, use $_GET[<name>] to get the value.
action POST = passing hidden variables (ex. Password). On next page, use $_POST[<name>] to get the value.
$_SESSION[name] is used to store global variables.
chmod: giving permission to read/write/execute files and directories. rwxrwxrwx, in the order of user/group/world.
600 for php, 711/755 for directories, 644 for all others.

SQL:

SELECT
INSERT
UPDATE
DELETE

Class FROM StudentTable WHERE Class=Freshman;


INTO StudentTable(Class, Class_size) VALUES('Super Senior', 202);
Students SET Class_size='1600' WHERE Class='Freshman';
FROM Students WHERE Class='Senior';

Javascript:
- Variables declared by: var one_to_four_array = [ 1, 2, three, 4.00 ]; // diff. type is

allowed
- Concatenating variables with +: var phrase = into one; var sentence = 3 + words joined together +
phrase;
- In JavaScript, "1" == 1 evaluates to be true (loosely typed). To compare the value AND the type, "1" === 1 evaluates to false.
- typeof: document.write(typeof dogName); will write string to the page. None existing type will print undefined.
- Embedding javaScript in body:
<form action=onclick=lookup()>

</form>
- Linking External JavaScript in head:
<head>
<script src = file.js></script>
</head>
- Some examples of event handlers in JavaScript: onClick, onLoad,
onFocus, onMouseOver, onMouseOut.
- To include JavaScript in the body, you need the following tag:
<script type="text/javascript">
</script>
- for-in syntax in JavaScript:
String weekdays = {Sunday, ...,Saturday};
for(int i = 0; i < 7; i++)
{
printf(today is %s, weekdays[i]);
}

Document Object Model (DOM) - storing contents of a webpage as


a structure called DOM and then access individual elements by
their ID to get their contents (see right).

Anda mungkin juga menyukai