
/* Implements the Stack data structure
   using a String array. */

public class Stack {

  protected int size;
  private int capacity;
  private String[] stackArray;

  public Stack(int capacity) {
    this.capacity = capacity;
    this.stackArray = new String[capacity];
  }

  /* Push the new item to the top of the stack. */
  protected void push(String item) {
    if (this.size < this.capacity) {
      this.stackArray[size] = item;
      this.size++;
    }
    return;
  }

  /* Pop the item off the top of the stack and return it. */
  protected String pop() {
    if (this.size > 0) {
      String poppedItem = this.stackArray[size - 1];
      this.stackArray[size - 1] = null;
      this.size--;
      return poppedItem;
    }
    return null;
  }

  /* Determine if the stack is empty. */
  protected boolean isEmpty() {
    return this.size == 0;
  }

  /* Determine if the stack still has space for more elements. */
  protected boolean hasSpace() {
    return this.size < this.capacity;
  }

  /* Show the elements in the stack */
  protected void displayStack() {
    for (String item : this.stackArray) {
      if (item != null) {
      System.out.println(item);
      }
    }
  }

}

@@ -319,24 +319,54 @@
 e stack. */%0A
+  /* Time Complexity: O(1) */%0A
   protected 
@@ -386,24 +386,24 @@
 ing item) %7B%0A
-
     if (this
@@ -562,24 +562,54 @@
 turn it. */%0A
+  /* Time Complexity: O(1) */%0A
   protected 
@@ -850,24 +850,54 @@
 s empty. */%0A
+  /* Time Complexity: O(1) */%0A
   protected 
@@ -1010,24 +1010,54 @@
 lements. */%0A
+  /* Time Complexity: O(1) */%0A
   protected 
@@ -1116,24 +1116,24 @@
 acity;%0A  %7D%0A%0A
-
   /* Show th
@@ -1155,24 +1155,89 @@
 he stack */%0A
+  /* Time Complexity: O(n), n is the # of items in the stack. */%0A
   protected 

Add time complexity comments for Stack methods.