Asymptotic Analysis – Practical Examples  
					•
					A program has two pieces of code A and B, executed one after the other,  
					2
					with A running in O(n log n) and B in O(n ). What is the complexity of the  
					program?  
					2
					O(n ) because n2 > n log n  
					–
					•
					•
					•
					A program calls an O(log n) function n times, and then calls another O(log  
					n) function again n times. What is the complexity of the program?  
					–
					O(n log n)  
					A program has 5 loops, called sequentially, each with complexity O(n).  
					What is the complexity of the program?  
					–
					O(n)  
					A program P has a running time proportional to 100 × n log n. Another  
					1
					2
					program P is 2 × n . What is the most efficient program?  
					1
					2
					2
					–
					–
					P is more efficient because n > n log n.  
					However, for a small n, P is faster and it might make sense to have a program  
					2
					that calls P or P according to the value of n.  
					1
					2