recursive one takes considerable amount of time as its exponential.