7] Write an algorithm to find uniqueness of elements in an array and give the mathematical analysis of this non-recursive algorithm with all steps.
Analysis of Non-recursive Algorithms:
General Plan for Analyzing the Time Efficiency of Non-recursive Algorithms
- Decide on a parameter (or parameters) indicating an input’s size.
- Identify the algorithm’s basic operation. (As a rule, it is located in innermost loop.)
- Check whether the number of times the basic operation is executed depends only on the size of an input. If it also depends on some additional property, the worst-case,average-case, and, if necessary, best-case efficiencies have to be investigated separately.
- Set up a sum expressing the number of times the algorithm’s basic operation is executed.
- Using standard formulas and rules of sum manipulation, either find a closed form formula for the count or, at the very least, establish its order of growth.
Uniqueness of elements in an array :