
#include <iostream>
#include "stack.h"
#include "queue.h"

bool 
isPalindrom (char w[]) {
  Queue Q; Stack S;

  // Enter the string in both a Queue and a Stack
  for (int i = 0; w[i] != 0; i++) {
      Q.Enqueue (w[i]);
      S.Push (w[i]);
    }
  // Compare elements while both of them are not empty
  while (!S.isEmpty ()) {
      char sp, qp;
      S.Pop (sp); 
      Q.Dequeue (qp);
      if (sp != qp)
        return false;
    }
  // Because both have the same number of elements no other 
  // tests are needed
  return true;
}

int
main (int argn, char *argv[])
{
  cout << (isPalindrom ("abacc") ? "true" : "false") << endl;
  return 0;
}


