Midterm-w10 - EECS 280: Midterm Winter 2010 This is a...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
EECS 280 Winter 2010 1 EECS 280: Midterm Winter 2010 This is a closed-book exam. There are 5 problems on 13 pages. Read the entire exam through before you begin working. Work on those problems you find easiest first. Read each question carefully, and note all that is required of you. Keep your an- swers clear and concise, and state all of your assumptions carefully. Each question has a box for your answer; put your answers in the boxes provided. Write your uniqname on the line provided at the top of each page. You are to abide by the University of Michigan/Engineering honor code. Please sign below to signify that you have kept the honor code pledge. Honor code pledge : I have neither given nor received aid on this exam, nor have I concealed any violations of the Honor Code. Signature: _________________________________________ Name: _________________________________________ Uniqname: _________________________________________
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Uniqname:________________________________________________________________________________ EECS 280 Winter 2010 2
Background image of page 2
Uniqname:________________________________________________________________________________ EECS 280 Winter 2010 3 Problem 1 _________ out of 20 Problem 2 _________ out of 20 Problem 3 _________ out of 20 Problem 4 _________ out of 20 Problem 5 _________ out of 20 Total: ________ out of 100
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Uniqname:________________________________________________________________________________ EECS 280 Winter 2010 4 1. Correctness In the following problems, you are given: An English description of a function A (potentially erroneous) implementation of that function For each implementation, state whether or not it is correct. If it is not correct, list the specific bugs. You do not need to correct the bugs; only identify them! 1.a locate Returns true if the string s2 appears anywhere inside of the string s1, returns false otherwise. For example, "lo" appears in "hello" whereas "la" does not. bool locate(const char * s1, const char * s2) { // REQ: s1 and s2 are non-empty, NULL-terminated strings // EFF: returns true if s2 is contained anywhere inside of s1, // false otherwise. while (*s1) { if (*s1 == *s2) { while (*s1 && *s2 && (*s1 == *s2)) { s1++; s2++; } if (!*s2) return true; } else s1++; } return false; }
Background image of page 4
Uniqname:________________________________________________________________________________ EECS 280 Winter 2010 5 1.b strnrev Reverses the first n characters of the string str and returns the result to the user. char* strnrev(char* str, int n) {
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 13

Midterm-w10 - EECS 280: Midterm Winter 2010 This is a...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online