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

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

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

Unformatted text preview: 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. Dont panic, and good luck! 1 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 result [ ] , 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 start [ ] , 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....
View Full Document

This note was uploaded on 03/08/2012 for the course ECE 190 taught by Professor Hutchinson during the Spring '08 term at University of Illinois, Urbana Champaign.

Page1 / 10

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

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

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