You don't really need to integrate to get this. y= 2(1- x) is a straight line from (0, 2) to (k, 2(1- k)).
If k= 1, the area under it is the area of the triangle with height 2 and base 1 and so area (1/2)(2)(1= 1. That is what we need to have in order to have a valid probability distribution.
As a check, if k< 1, the area under the line is the area of the trapezoid with bases 2 and 2(1- k) and height k. It's area is k(2+ 2(1- k))/2= k(4- 2k)/2= k(2- k) and we want that equal to 1. k(2- k)= 2k- k^2= 1 is the same as k^2- 2k+ 1= (k- 1)^2= 0. As before, it reduces to k= 1, the triangle case.
(You say "I sketched the graph and got a line from (0,2) to (1,0)". Well, you couldn't know it would be a line from (0, 2) to (1, 0) until after you knew that k= 1.)
Now the median is where the area both left and right is equal to 1/2. If we take that to be at "x", then we have a triangle on the right with base 1- x and height 2(1- x) which has area (1/2)(1-x)(2(1-x))= (1- x)^2 and we want that equal to 1/2: (1- x)^2= 2. Solve that for x.
If you really want to integrate, you are integrating
\int_0^x 2(1- t)dt= 2 \int_0^x 1- t dt= 2\left(x- (1/2)x^2)= 1/2[/itex]] which gives the same result.<br />
<br />
You can simplify that integral by letting u= 1- t so that du= -dt, when t= 0, u= 1 and when t= x, u= 1- x. Now the integral is 2\int_0^{1- x}u^2du= 1/2[/=itex], giving, again, the same result.