CSI 202 - Fall 2015 - Review #1 Review CSI 201: C++ base types, string for, while, if functions/methods, main static arrays v. dynamic arrays classes numeric manipulation Linux commands: ssh, scp, passwd, make ls, cat, script cp, mv, rm cd, mkdir g++, make Other: makefiles meaning of . and .. Memory and Memory Diagrams - Stack V. Heap - Static allocation vs. Dynamic allocation - Compile time vs run-time - Function Stack Classes: - programmer-defined type - public vs private - dot (.) operator - w/ pointers and using the arrow (->) operators - the big 4 - constructor, destructor, copy assignment, copy constructor Pointers: - declaration, meaning of star (*) in various places - Dynamic arrays - reference, dereference - new and delete - NULL - pointer / dynamic memory issues: - garbage - stale pointers - pointers to stack addresses - segmentation fault - deep copy vs shallow copy Linked Lists: - node structure and code - pointers, use of NULL - end of list - head v tail - add to front, output, delete, print, operations on every element STL: (not included in the practical of exam #1) vector - as dynamic arrays with reserve list - double linked list set - tree (described in the future) -------------- Sample quick answer questions: What do the following mean in linux? What linux command does the following operation? What compiler do we use? Show a sample compilation of the file hw1.cpp into the hw1 executable. Does the following code leave garbage? How much? Does the following code leave a stale pointer? Which variables are stale? What is the output of the following code? When does a segmentation fault occur? What is the danger of a stale pointer? When might the result of a pointer operation be undefined? Using STL, would you use a list or a vector in "xyz" situation? Sample practical/questions: * refers to difficulty. more stars is more difficult. Assume LLNode in questions referring to linked lists. You may not assume the LinkedList class or its implemented functions unless otherwise mentioned. Also, LL refers to a linked list. * - Given the head of a LL, show how to print every element of the LL. * - Given the head of a LL, demonstrate how to change every element by increasing its value by 1. * - Given the head of a LL, show how to find the tail of the LL. * - Given the head of a LL, add a new element to the LL. ** - Given an array with 10 elements, make a new array with 11 elements that has the same first 10 elements. ** - Given an array, make a new array in the reverse order. ** - Given an array, reverse the order of the elements without making a new array. ** - Given the head of a LL, make a copy of the LL. (two identical LL at the end) ** - Given the head of a LL, delete every node in the list and change the head to point to an empty list. *** - Given the head of a LL, show how to create a new LL in the reverse order. (two LL at the end) **** - Given the head of a LL, show how to modify the LL to reverse the order. (one LL at the end)