Question: 1 . Prove that if f: X - > Y and g:Y - > Z are 1 - 1 functions then g f : X
Prove that if f: X Y and g:Y Z are functions then gf : X Z is also
Give an example of a function that is:
a not onto include domain and codomain
b and onto include domain and codomain
c Neither nor onto include domain and codomain
d Has asymptotic complexity more that n but less than n
A population has exponential growth; t years from now its population will be y et
a When will the population reach show work
b How long does it take the population to double show work
Write pseudocode for a program that will take an unordered list of distinct integers A
An and output a new list BBn such that;
B is the largest number in list A B is the smallest number in A
B is the second largest number in A B is the second smallest number in A
B is the third largest, etc.
The following gives pseudocode for a binary search We have a list of n integers AAn
in order starting with the lowest. We are given a value x to search for in the list. If x is in
the list, we Return its position. If x is not in the list, Return You may assume n is even,
and start by giving out Bubblesort code from class to order the numbers first, if you wish.
a Trace the program using n A value and xvalue Give me the
values of low, hi and mid each time the mid value is calculated by mid:lowhi
and give the final output Returned.
b Same as a but now use xvalue
Program Binary Search
Input: positive integer n list of n integers A An number x
Output: location of x if it is in the list, otherwise
hi: n
low :
while hi low do
mid:lowhi
if Amid x Return mid
else if Amid x low: mid
else hi: mid
endif
endwhile
Return
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
