ALGORITHM An Algorithm is a finite set of instruction that perform a particular task. An Algorithm should satisfy following criteria. Input: Zero or more quantities are supplied externally. Output: At least one quantity is produced. Definiteness: Each instruction is clear and unambiguous. Finiteness: Algorithm must terminate after few steps. Effectiveness: Every instruction must be very basic. ANALYSIS: It means determining amount of resources (such as time and space) needed to execute it. TIME COMPLEXITY: Time complexity of an algorithm is basically the execution time of a program. Time complexity of an algorithm depends on the number of machine instruction. SPACE…