COMPOUND LITERALS BAD - do not do this unless there you have articulated the reason why you must new_top -> ch = ch; new_top -> next = NULL; GOOD - bug-resistant *new_top = (Node) { .ch = ch, .next = NULL }; // Compound literal sizeof(…) BAD Node* new_top = malloc(sizeof(Node)); GOOD Node* new_top = malloc(sizeof(*new_top)); └───┬──┘ ↑ Node // Don't forget the asterisk! ↑ D.R.Y. - Don't Repeat Yourself assert(…) - Lets you write code that tests itself while it is running. - assert(«CONDITION») will cause your program to crash if the condition is false. - Use a condition that *must* be true if *your* code is correct (not buggy). - Useful for post-conditions (things that must be true after operation) and preconditions (things that must be true before the operation). - Do not use assert(…) to check if someone else called your code correct. - Do not use assert(…) to check environmental conditions such as if file exists, server is running, keyboard is connected, etc. Use for loop to iterate through linked list BAD Node* curr = head; while(curr != NULL) { // BODY curr = curr -> next; } GOOD for(Node* curr = head; curr != NULL; curr = curr -> next) { // BODY } Binary Search - Searching for any element in an array using binary search takes O(log n) running time. - It will not take N time steps (compares) except for very small n (1 or 0). RECURSION VS ITERATION