Algorithm	Complexity	
Analyzing
By	Haluan	Mohammad	Irsad
Algorithm	Complexity
• Commonly	expressed	in	Big	O	Notation
“is	a	mathematical	notation	that	describes	the limiting	behavior of	
a function when	the	argument	tends	towards	a	particular	value	or	infinity.”
“Representing	the	growth	rate	of	an	algorithm	based	on	time and	space”
Measurement
• Time	complexity:	how	long	does	the	algorithm	run?
• Space	complexity:	the	number	of	memory	cells	which	an	algorithm	
needs
Exclude
• Platform	(	machine/hardware	&	OS)
• Programming	Language
• Compiler	Quality
• Programming	Paradigm
Code	Example
Constant	Algorithm	O(1)
Linear	Algorithm	O(n)
Algorithm	O(logn)
Quadratic	Algorithm	O(n2)
Cubic	Algorithm	O(n3)
Benchmark	by	Data	Structure
Benchmark	by	Sorting	Operation
DataTest
Problem
Count	1	and	0	in	a	line.		If	in	the	line	have	1	digit	in	even	then	print	1,	
else	 print	0.
Example	Result
Input Output
Data	Test
Size	of	data
1
9
Results
Graphic	Linear	Algorithm	O(n)
Graphic		Algorithm	O(nlogn)
Graphic	Quadratic	Algorithm	O(n2)
Graphic	Cubic	Algorithm	O(n3)
Graphic	Resume
Resume
• Linear	algorithm	is	stable	for	any	size	of	data
• Simplify	your	complexity	if	you	found	Quadratic	and	Cubic	algorithm	
in	your	code.	Avoid	nested	looping.
• Choose	the	right	data	structure	for	the	right	operation.