Roger Federer was impressed by Alexander Zverev's cool-headed approach as the German claimed a dramatic Shanghai Masters quarter-final win.

While the usually serene Federer lost his temper and suffered a point deduction in the deciding set after hitting a ball into the crowd in frustration, Zverev proved far more focused.

That served him well when, having squandered five match points in the second set, Zverev dusted himself down to win the third and seal a 6-3 6-7 (7-9) 6-3 victory.

Despite his own evident dissatisfaction, Federer had some kind words for his opponent after a fiery contest.

"I told him at the net that he showed great character, that he was strong," said the 20-time grand slam champion.

"I thought he didn't show any frustrations or too much negativity. I didn't see him very often being extremely frustrated except the one time when he hit three let cords in a row, the last game I think it was.

"That was impressive, because he has tendencies to get a bit down on himself, especially this season he hasn't been playing maybe so well, so that impressed me the most. 

"If I can get one per cent of that, I'm happy, too."

Matteo Berrettini is up next for Zverev, who reflected on a remarkable end to the second set, when he was on the brink of a far more straightforward success.

"Obviously I had three [match points] on my serve and two more in the tie-break," he said. "I played great tennis and didn't do unforced errors or anything like that.

"I knew if I keep playing the way I was playing in the first two sets I was going to have a chance in the third as well.

"I don't think Roger Federer's game suits anybody to be honest. He is the greatest player of all time. He will always find a way and make it tricky for you like he did with me.

"You have always got to play your best tennis to have a chance."