Answer
(a)$$f(x)=\begin{cases} 4x+1, & x \ge 0 \\ 2x+1, & x<0 \end{cases}$$
(b)$$g(x)=\begin{cases}2x-1, & x \ge 1 \\1, & 0 \le x <1 \\ -2x+1, & x<0 \end{cases}$$
Work Step by Step
(a) By definition of absolute value function we have$$|x|= \begin{cases} x, & x \ge 0 \\ -x, & x<0 \end{cases}$$ $$\Rightarrow \quad f(x)=|x|+3x+1= \begin{cases} 4x+1, & x \ge 0 \\ 2x+1, & x<0 \end{cases}.$$
(b) By definition of absolute value function we have$$|x|= \begin{cases} x, & x \ge 0 \\ -x, & x<0 \end{cases}, \quad |x-1|= \begin{cases}x-1, & x-1 \ge 0 \\ -(x-1), & x-1<0 \end{cases}= \begin{cases} x-1, & x \ge 1 \\ -x+1, & x<1 \end{cases}$$ $$\Rightarrow \quad g(x)=|x|+|x-1|= \begin{cases}x+(x-1), & x \ge 1 \\ x+(-x+1), & 0 \le x <1 \\ -x+(-x+1), & x<0 \end{cases}=\begin{cases}2x-1, & x \ge 1 \\1, & 0 \le x <1 \\ -2x+1, & x<0 \end{cases}.$$