{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# tuesday - ECE 190 Exam 3 Tuesday April 12th 2011 Problem...

This preview shows pages 1–4. Sign up to view the full content.

ECE 190 Exam 3 Tuesday, April 12th, 2011 Problem 1 (5 points): Warmup Problem 2 (20 points): Problem Solving Problem 3 (15 points): File I/O Problem 4 (10 points): Debugging Problem 5 (15 points): Function Activation Records Be sure your exam booklet has 11 pages. This is a closed book exam. You are allowed three handwritten 8.5 x 11” sheets of notes. Absolutely no interaction between students is allowed. Be sure to clearly indicate any assumptions that you make. Don’t panic, and good luck! 1

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

View Full Document
Warmup (5 points) In this assignment, you are asked to implement a function to normalize an n-dimensional vector. The function accepts one input vector, vector , one output vector, result , and the number of dimensions, n : void normalize ( f l o a t vector [ ] , f l o a t r e s u l t [ ] , int n ) ; Recall from MP4 that a normalized vector has a length of one. Thus, to normalize a vector, one must divide each component of the vector by the length of the original vector. To determine the length of the vector you may use the following formula: length = p vector [0] 2 + vector [1] 2 + ... + vector [ n - 1] 2 Getting Started Invoke the ’ece190’ script Execute ’cd mp’ Execute ’ls’ to verify that mp.c and Makefile are present To compile the code, simply type ’make’. To run the code, simply type ’make test’ and input the necessary information. Specifics To receive any credit for this problem, the code must compile. sqrt() is the only function from math library that you are allowed to use. 2
Problem Solving (20 points) In this assignment, you will implement a function for counting the number of intersections between one-dimensional line segments. Algorithm Two line segments, A[ s a , e a ] and B[ s b , e b ] , given by their start coordinates, s a and s b , and end coordinates, e a and e b , such that s a <s b , are intersecting if s b <e a (line segment B starts before line segment A ends). Thus, to find if a given pair of line segments intersects, all you have to do is to see if one segment starts before the other segment ends. Implementation requirements You are required to implement the following function that implements the above algorithm: int intersect segments ( int num, f l o a t s t a r t [ ] , f l o a t end [ ] ) ; The function should accept 3 arguments: number of line segments, num , array containing start coordinates of the line segments, start , and array containing end coordinates of the line segments, end . In this representation, line segment i starts at start [ i ] and ends at end

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern