how come the 3rd for loop complexity is O(nlogn) ??

# How come the 3rd for loop complexity is O(nlogn)?

Firstly its O(logn) and not O(nlogn) assuming loop body is O(1). Now coming to how it is O(logn). You can think of it as a loop starting from 2^0 to 2^j such that 2^j>=n and value of j is being incremented by 1. Now loop will terminate when j>=log(n)[Base 2], hence it is O(logn).