a) Let us consider the functions f(x)=x, for all x∈R, and
g(x)={x,x+1,x∈Qx∈R∖Q.
The function g is discontinuous at any real point. Let a<b<c be three arbitrary real numbers. For any sequence (xn)n≥1 of rational numbers converging to b, we have limn→∞g(xn)=limn→∞xn=b∈(a,c)=(f(a),f(c)).
b) Consider b∈R a continuity point of g. We will prove g(b)=f(b) by contradiction. If g(b)<f(b) then, based on the continuity of f at the point b, there is a<b such that f(a)>g(b). Then, for any sequence (xn)n≥1 converging to b, we have limn→∞g(xn)=g(b)<f(a), contrary to the hypothesis. If g(b)>f(b) then, by using again the continuity of f at b, we can find c>b such that f(c)<g(b). For any sequence (xn)n≥1 converging to b, we have limn→∞g(xn)=g(b)>f(c), contrary to the hypothesis. So g(b)=f(b). We conclude that g(x)=f(x) at any continuity point x of g.
Let x be an arbitrary real number. The monotone function g has lateral limits at x. The set of discontinuity points of g is at most countable. So, for any n∈N∗, there are two continuity points of g: un∈(x−1/n,x) and vn∈(x,x+1/n). Then limt↘xg(t)=limn→∞g(un)=limn→∞f(un)=f(x) and limt↗xg(t)=limn→∞g(vn)=limn→∞f(vn)=f(x). Thus, limt↘xg(t)=limt↗xg(t)=f(x). From the monotony of g, we get g(x)=f(x).