Put ex 5.7 algorithm into generic function
reuse 5.7 algorithm with different type of vector