Interval scheduling - does this IF statement check for overlapping?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • javaMed
    New Member
    • Mar 2010
    • 6

    Interval scheduling - does this IF statement check for overlapping?

    Hello,

    The following if statement is supposed to check to see if the given values overlap (in any way):

    Code:
    if( ((st1 < st2)&&(st2 < fin1)) ||  ((st1 < fin2)&&(fin2 < fin1)) )
    st1, st2 --> starting time
    fin1, fin2 --> finishing time

    I was supposed to go off of the following given by my teacher:
    "things overlap if (starti < startj < finishi) or (starti < finishj < finishi)"

    Could anyone please help me figure out why it always returns false??


    Thanks in advance!
Working...