0

I have a text on Algorithms which has these 2 lines in it -

random double value in [a,b)

random int value in [0..N)

What do the notations [ and ) mean?

What's the difference between the 2 lines?

  • 1
  • $[a,b]$ includes both ends in the interval, $(a,b)$ includes neither, $[a,b)$ includes $a$ but not $b$, while $(a,b]$ includes $b$ but not $a$. Some people instead write $[a,b]$ and $]a,b[$ and $[a,b[$ and $]a,b]$ respectively – Henry Jan 24 '19 at 10:28
  • The key difference between your two lines are the words double (double-precision floating-point type, so not necessarily an integer) and int (integer type). – Henry Jan 24 '19 at 10:30
  • I meant, is there any significance of the '..' between the ends of the intervals? (in the 2nd line) – Karthik Bhat Jan 24 '19 at 10:44
  • As you might guess, [0..N) probably means the same as ${0,1,\dots,N-1}$. – Somos Jan 24 '19 at 11:16
  • So, both the lines actually mean the same? They just tell us the numbers between the endpoints of the interval? ( With the end a/0 inclusive?) – Karthik Bhat Jan 24 '19 at 11:42

1 Answers1

2

$(a, b)$ means all $x$ such that $a<x<b$.

$(a,b]$ means all $x$ such that $a<x\le b$.

$[a, b)$ ... such that $a\le x <b$.

$[a, b]$ ... $a\le x \le b$