{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

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

View Full Document Right Arrow Icon
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
Image of page 1

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

View Full Document Right Arrow Icon
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
Image of page 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
Image of page 3

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

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern