Implements Assignment 4 Part 3-1

encode