Question: (a) Write an algorithm (use pseudo-code) to determine whether a function f: Z100 Z100 is surjective. That is, supply a Method to go with

(a) Write an algorithm (use pseudo-code) to determine whether a function f:

(a) Write an algorithm (use pseudo-code) to determine whether a function f: Z100 Z100 is surjective. That is, supply a "Method" to go with Input: A function (array) f with f(i) Z100 for i = 0, 1,...,99. Output: Boolean B. B='true' if f is surjective, 'false' otherwise. Try to make your algorithm as efficient as possible. Do NOT include an implementation of your algorithm in a programming language. (b) How many comparisons does your algorithm perform for a worst case when f is surjective? Count all tests for =, +, < and >. Include all comparisons used, not just comparisons of function values. For example, remember that each pass of a loop will require at least one comparison to test whether the exit condition(s) has/have been met.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!