For the medium to hard ones you just have to break it down line by line. What helps me the most is desk checking it or implementing it into Visual Basic (or whatever language your using) and seeing what happens.
Specifically for sorting algorithms, I found that it was easier to understand once...