edited by
689 views
0 votes
0 votes

Consider the line $y=\frac{n}{m}x$, where $n$ and $m$ are positive integers.

  1. If mq - np < 0, then is the point (p,q) above the line, below the line, or on the line?
  2. Complete the following function, that returns true if the line segment with endpoints (p,q) and (r,s) intersects the line $y=\frac{n}{m}x$, by writing the line number and the content of each box in your answer book.
  1: function clash (m, n, p, q, r, s: integer): Boolean;
  2: begin
  3: clash = false;
  4: if(m*q - n*p)⊏⊐ 0 then clash:= true;
  5: if(m*s - n*r)⊏⊐ 0 then clash:= true;
  6: if(m*q - n*p)⊏⊐ 0 and (m*s - n*r)⊏⊐ 0 then clash:= true;
  7: if(m*q - n*p)⊏⊐ 0 and (m*s - n*r)⊏⊐ 0 then clash:= true;
  8: end;
edited by

Please log in or register to answer this question.

Related questions

33 votes
33 votes
8 answers
2
Kathleen asked Sep 14, 2014
10,862 views
Consider the following nested representation of binary trees: $(X \ Y \ Z)$ indicates $Y$ and $Z$ are the left and right subtrees, respectively, of node $X$. Note that $Y...