Hand-in @ lecture #10

Published

21 April 2026

2.3.18a

For \(f(x) = -3x + 4\) to be a bijection, it needs to be both one-to-one and onto.

Since \(f(x)\) is a linear function with a negative gradient covering \(\mathbb{R}\) for both domain and codomain, it is strictly decreasing. This means that it is indeed both one-to-one and onto, thus \(f(x) = -3x + 4\) is a bijection from \(\mathbb{R}\) to \(\mathbb{R}\).

2.3.18b

For \(f(x) = -3x^{2} + 7\) to be a bijection, it needs to be both one-to-one and onto.

Since \(f(x)\) is a second order polynomial with a negative second order coefficient, it is strictly increasing until a vertex and then strictly decreasing onwards. This means that it is not one-to-one since the codomain is folded at the vertex meaning that except at the vertex it is two-to-one, nor is it onto since the domain is \(\mathbb{R}\) but the codomain is a true subset of \(\mathbb{R}\)), thus \(f(x) = -3x^{2} + 7\) is not a bijection from \(\mathbb{R}\) to \(\mathbb{R}\).

A-3.2

The following procedure uses assignment statements to interchange the values of the variables x and y:

\begin{algorithm} \caption{SwapVars} \begin{algorithmic} \Procedure{SwapVars}{$x, y$} \State $z \gets y$ \State $y \gets x$ \State $x \gets z$ \EndProcedure \end{algorithmic} \end{algorithm}

A minimum of 3 assignment statements are needed to do this, 2 for target assignments and 1 intermediate assignment to hold a value initially held by a variable which would otherwise be overwritten.

3.1.6

The following pseudocode describes an algorithm that takes as input a list of integers and finds the number of negative integers in the list:

\begin{algorithm} \caption{NegativeIntegers} \begin{algorithmic} \Procedure{NegativeIntegers}{$integers$} \State $negatives \gets 0$ \For{ $i$ in $integers$ } \If{ $i < 0$ } \State $negatives \gets negatives + 1$ \EndIf \EndFor \Print $negatives$ \EndProcedure \end{algorithmic} \end{algorithm}

3.1.24

The following pseudocode describes an algorithm that determines whether a function from a finite set to another finite set is one-to-one:

\begin{algorithm} \caption{IsOneToOne} \begin{algorithmic} \Procedure{IsOneToOne}{$function, domain$} \State $results \gets []$ \For{ $i$ in $domain$ } \State $res \gets function(i)$ \For{ item $j$ in results} \If{ $res = j$ } \Print "function is not one-to-one" \Break \State results \gets $[results, res]$ \EndIf \EndFor \EndFor \Print "function is one-to-one" \EndProcedure \end{algorithmic} \end{algorithm}