160 likes | 178 Views
This review covers writing programs, tracing code, linked lists, pointers, structures, stacks, Linux basics, command line arguments, algorithm analysis, and study tips. Practice your skills to ace the exam!
E N D
Exam Format • 105 Total Points • 55 Points Writing Programs • 20 Points Short Answer • 30 Points of Tracing Code • Similar to programming assignments • All point values are approximations
Example Programming Problems • Given a 2D array of characters, write a short piece of code that will count the number of cells that are directly above the letter ‘Q’ and have the value ‘Y’. • Given a file of strings, write a program that will read each line into a linked list node such that the lines are in the correct order (insert at the end) and each insert is a O(1) operation. Then traverse the linked list and print out the lines to the screen.
Example Short Answer • Explain why traversing a linked list of nodes is an O(n) operation.
What will the EXACT output of the following program be? intfoo = 9; int *ptr = &foo; float foo2 = 5.7; *ptr = 2; foo2 = foo - foo2; if (foo > foo2) printf("Hello!\n“); else if (foo < foo2) printf(“%f\n”, foo2); else printf(“%d\n”, foo); printf(“\n”); printf (“foo2 is %f\n”, foo2);
Fundamentals of C • ?? Points • Declaration of variables and functions • Looping and conditional statements • While, for, if • One and two dimensional arrays • Simple I/O • Printf, scanf, fscanf, fgets
Pointers • 20 Points • A pointer is a variable that holds the address of a memory location • Declaration • int *ptr; • Assignment • ptr = &foo; //& is the address function • Dereferencing • *ptr = 54; //same as foo=54; • You can point to any kind of data type • Relationship between arrays and pointers • Understand the “malloc” and “free” commands
Structures • 10 Points • Declaration • Assignment • Use of the “.” operator • Pointers to structures • (*ptr).field • ptr->field • Structures used in Linked Lists
Linked Lists • 30 Points • Declaring a linked list • Adding a node to a linked list • Removing a node from a linked list • Traversing a linked list • What is the order of magnitude of each of the above operations? • Understand the Stack312_ll code and the linked list code from class.
Stacks • 20 Points • Operations • makeStack • Push • Pop • isEmpty • isFull • Know how to use in a problem and implement • Understand the Stack Fun! assignment
Linux • 6 Points • Know the basic commands you needed to complete a program in Linux • Know how to edit a file in Linux • Know how to compile and run a C program in Linux • Know how to create directories and move around the Linux file system
Command Line arguments • 12 Points • Make sure you understand how to use argc and argv • Understand the use of atoi(char *)
Algorithm Analysis • 15 Points • Understand what Big O notation is • Be able to look at an algorithm or piece of code and determine how much work it has to do (and then the Big(O) analysis of the code) • Understand the relative speed of the Big O orders. • Which is faster? O(1) or O(n)
How to Study • Rewrite all the programs. • Don’t memorize C! Code syntax will be on the exam. • Learn by doing and recognizing patterns. • Don’t stay up late!! Get some sleep and eat a good breakfast.
What to bring • Pencils and erasers • We will provide scratch paper • No calculators