167k views
2 votes
Merge sort has a o(n log2(n)) complexity. if a computer can sort 1,024 elements in an amount of time x, approximately how long will it take the computer to sort 1,024 times that many, or 1,048,576 elements?

User Brgn
by
7.2k points

1 Answer

7 votes
1,048,576 is 1,024 times 1,024, 1,024 * 1,024 or 1,024 squared or 1,024^2. If a computer takes x amount of time to sort 1,024 elements then the relationship is a 1 to 1. Therefore the computer will take x times x or x^2 (x squared) amount of time to sort 1,048,576.
User RDU
by
7.2k points