Answers to Practice Questions and Notes for the Lecture Slides: Ace The Exam! IEEE UNSW Student Branch / The Learning Centre UNSW [http://www.cse.unsw.edu.au/~ieee] Clarence Dang 2007-06-12 Disclaimer: This whole document is based on my experience studying at CSE. It might not work for you. Like many things in life, there are no magic tricks to learning and exam performance (that I know of). It comes down to: 1. Using a study technique so that your study time is well spent. The aim is to intuitively understand a concept by practising it, rather than rote memorisation. 2. Putting a _lot_ of time into studying. Some students spend close to 100% of each week studying or doing assignments. CSE courses are very practical. In my opinion, practising programming is very important, followed by doing the tutorial questions. 3. Using exam techniques to maximise marks. Slide 16: Studying - "Passing Arrays to Functions" - A slide is a chunk of text that does not help in learning esp. if you have hundreds of such slides - Underlining - Underlining the whole slide adds no value - Underline what you don't know - Differs from person to person - This is why not going to the lecture and getting your friends to take notes does not work - Do it during to lecture to reduce study time - Write down extra things the lecturer says - After all, this is the point of going to a lecture - Star things you don't understand so you can go back to them later - The idea is that you can revise much faster by only reading the underlined important information, compared to reading the whole slide - Underlining also reinforces the idea in your head - Draw arrows on the slide to make statements clearer - Cross out useless bits like "strange formatting to fit on page" (and correct the formatting) - Cross out useless slides like "the assignment is due next week" as this is worthless at exam study time - Textbooks may or may not help - Some textbooks require too much effort to read - cost is more than benefit - Add little value since virtually all examined content is covered in lectures, assignments and tutorials - Final exams are very similar to tutorial questions - Textbooks are generally not written with particular uni courses in mind - Do not memorise the textbook - this is not the HSC - And the lecturer might never have even read the textbook - Many CSE students go through an entire degree without using a textbook - Internet contains plenty of computing information - In the worst case, you can just go to the 2hr loan section of the library and read/photocopy information needed (you can do this for more than 2hrs by not explicitly loaning the book) Slide 22: Short Answer Questions - "Answering All Aspects" - Appropriate answer length depends on marks - 1 piece of information per mark (2 in same questions) - "Backup" pieces to show depth of knowledge and in case other bits don't get marks - Clearly laid out for marker - Grammatically loose so that it can be written faster Slide 23: Short Answer Questions - "Irrelevant Essay Waffle" - BAD, BAD, BAD - Repeats the question, adding no value - Uses full prose, which takes too much time and space - Quotes like Arts essays - Not answering the question - Memorising the textbook - Lecturer is not interested in you memorising useless information - There is no value in knowing what is on "page 78" Slide 24: Diagram Questions - Messy solution with lots of crossing out gets little or no marks - Lecturers have to mark all hundred exam papers in a few days - Don't have time or energy to decipher mess - You _will_ lose marks! - HB pencil doesn't rub out easily - Use 2B - Pencils are obsolete anyway - use pacers - Pencils require time-consuming sharpening and may break straight after sharpening, requiring sharpening again - Think about how you will lay out the solution before drawing it - Write "PTO" (Please Turn Over) and draw on a fresh page as you'll need the space - the answer booklets are nowhere near as tall as A4 Slide 26: Multiple Choice Questions - "The 'Best' Answer" - Standard multiple choice requires that you select the _best_ answer - In this example: - All are true statements - But you must still only choose one - So choose the best - a) is not a useful point of view - b) it doesn't justify writing new programs in C - c) C is correct - d) since you can't reuse code, this is not a good reason Slide 27: Multiple Choice Questions - Guessing - Eliminate silly possibilities - c) and d) - When you're stuck, consider guessing - Calculate the expected mark from guessing e.g. if: i) A correct answer gets 1 mark ii) An incorrect answer gets -1/2 mark iii) There are 3 possibilities left Expected Mark = (1/3 * 1) + (2/3 * -1/2) = 0 There is no harm in guessing. In our example, there are 2 possibilities left: Expected Mark = (1/2 * 1) + (1/2 * -1/2) = 1/4 You should definitely guess as in the long run, you'll be ahead - Star question to come back to it if unsure - Do this in the question booklet - Or to the left of the question number on the answer sheet - It's much quicker to see which questions need to be revisited but is risky if your star is picked up as an answer by the computer - Other questions may hint at the answer Slide 29: Code Writing Questions - Think how to do it algorithmically before writing any code - Use curly-brace-on-same-line coding style to save space - Key to success is practice writing many, many, many small programs - Do this in a study group - Examples: - Print contents of linked list - Reverse a singly-linked list - Print all fibonacci numbers less than n - Calculate the nth triangle number - Create phone book mapping name to number (use struct's) - If you're stuck, write some roughly correct code and move on to another question Slide 31: Finding Bugs Questions The "Assume 'string' is never longer than 20 characters" ensures that the "string [i] = 'A' + i" line produces capital letters (there are only 26 letters in English). 1. Discriminator (tests for HD students): - char *string = "Hello world"; + char string [] = "Hello world"; Pointers used nearly, but not exactly, identically to arrays. The first is a pointer to an array of characters. This array of characters is stored in the _read-only_ string table. You cannot write to it (e.g. "string [i] = 'A' + i;") without corrupting memory or crashing the program. The second is an array of characters, which can be written to. 2. - i = strlen (string); + i = strlen (string) - 1; "strlen" gives the number of characters up to, but excluding, the first '\0' NUL character. The last non-NUL character is at index "strlen - 1". 3. - while (i > 0) { + while (i >= 0) { The first index of any array is 0. 4. - i++; + i--; Classic error when converting a loop that goes forwards to backwards. If uncorrected, the loop will execute 2 billion times before 'i' goes negative through integer overflow. 5. - printf ("The contents of the string is: %d\n", string); + printf ("The contents of the string is: %s\n", string); Slide 32: Tracing Questions Always show working as you get most of the marks from the working. Flow-on errors result in very minimal mark loss. Simply writing the answer without working can result in 0 if the answer is wrong. Working is good. i j i*j a 0 0 -1 2 1 2 2 0 -1 4 3 12 14 2 8 22 1 4 26 0 -1 Answer: 26