Homework: Stack and Sequence Flip


  1. Implement the Stack family instance method flip declared as follows (this is a Stack<T>):

        /**
         * Reverses ("flips") {@code this}.
         * 
         * @updates this
         * @ensures this = rev(#this)
         */
        public void flip();
    

  2. Implement the Sequence family instance method flip declared as follows (this is a Sequence<T>):

        /**
         * Reverses ("flips") {@code this}.
         * 
         * @updates this
         * @ensures this = rev(#this)
         */
        public void flip();
    

  3. Provide a second, different implementation of the instance method flip for Sequence<T>. If your first implementation is iterative (i.e., uses a loop), your second one should be recursive and vice versa.