1: public void displayArray(int first, int last) 2: { 3: boolean done = false; 4: StackInterface<Record> programStack = new LinkedStack<>(); 5: programStack.push(new Record(first, last)); 6: while (!done && !programStack.isEmpty()) 7: { 8: Record topRecord = programStack.pop(); 9: first = topRecord.first; 10: last = topRecord.last; 11: 12: if (first == last) 13: System.out.println(array[first] + " "); 14: else 15: { 16: int mid = first + (last - first) / 2; 17: // Note the order of the records pushed onto the stack 18: programStack.push(new Record(mid + 1, last)); 19: programStack.push(new Record(first, mid)); 20: } // end if 21: } // end while 22: } // end displayArray 23: // Version 4.0