finished question4.4;Here I used java LinkedList class and Queue interface in order to simplify the coding processing