Q:

Union of two countable set is also countable

This question is asked many time when I search it. But i didn't find what am I really looking for.
My approach: 
Let $A_1,A_2$ be two countable sets. If they have some common elements then redefine it by $B_2=A_1\setminus A_2=\{x\in A_2:x\notin A_1 \}$. The point of this is that the union $A_1 \cup A_2=A_1 \cup B_2$ and the sets $A_1,B_2$ are disjoint. I guess three case be happen for $B_2:$

If $B_2=\emptyset$, then $A_1\cup A_2=A_1 \cup B_2=A_1$ which we already know to be countable.
If $B_2=\{b_1,b_2,\cdots,b_m \}$ has $m$ elements, then how can I define and make sure $h:A_1 \cup B_2\to \mathbb{N}?$ In order to satisfy the statement $A$ is countable iff there is a bijective $(1-1$ and onto$)$ mapping $f: A \to \mathbb{N}$, where $\mathbb{N}$ is the set of all natural numbers.
If $B_2$ is inﬁnite again the same problem faced.

I have no idea how to approach and fix all these things. Besides, I wanted to know Is this approach is enough to proof the statement or not? Any hint or solution will be appreciated.
Thanks in advance.

A:

I would proceed like this:

We know that there is a bijection between $A_1$ and $\Bbb{N}$ and $A_2$ and $\Bbb{N}$. Let's call them $f_1: A_1 \longrightarrow \Bbb{N}$ and $f_2: A_2 \longrightarrow \Bbb{N}$.
We need to prove that there is $g: B \longrightarrow \Bbb{N}$ bijective ($B = A_1 \cup A_2$), or equivalently, a $g': \Bbb{N} \longrightarrow B$.

So define $g'$ as follows: $$g'(n) = \begin{cases} f_1^{-1}(n), & \text{if n is even} \\ f_2^{-1}(n), & \text{if n is odd} \end{cases}$$
Note that $f_1$ and $f_2$ are invertible because they are bijective. Now take $g = g'^{-1}$ and you have what you were looking for.
Note: a way to visualize it is to consider the following two sets: $A = \{(+, n) : n \in \Bbb{N}\}, B = \{(-, n) : n \in \Bbb{N}\}$ which union gives $\Bbb{Z} \setminus {0}$ and notice that $h$ defined as $$h(n) = \begin{cases} (+, n/2), & \text{if n is even} \\ (-, (n+1)/2), & \text{if n is odd} \end {cases}$$ is a bijection between $A \cup B$ and $\Bbb{Z} \setminus {0}$.  And you know that $\Bbb{Z} \setminus {0}$ is countable.

