Data Str & Algorithm HW Solutions 28

Data Str & Algorithm HW Solutions 28 - return true;...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
28 Chap. 4 Lists, Stacks, and Queues listArray = new Elem[size]; isEmpty = true; } ˜AQueue() { delete [] listArray; } // Destructor void clear() { front = rear; isEmpty = true; } (((rear+1) % size) == front)) return false; rear = (rear+1) % size; // Circular increment listArray[rear] = it; isEmpty = false; return true; } if (isEmpty == true) return false; // Empty it = listArray[front]; front = (front+1) % size; // Circular increment if (((rear+1) % size) == front) isEmpty == true;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: return true; } bool frontValue(Elem& it) const { if (isEmpty == true) return false; // Empty it = listArray[front]; return true; } virtual int length() const { if (isEmpty == true) return 0; return ((rear+size) - front + 1) % size; } }; 4.14 bool palin() { Stack<char> S; Queue<char> Q; while ((c = getc()) != ENDOFSTRING) { S.push(c); Q.enqueue(c); } while (!S.isEmpty()) { if (S.top() != Q.front()) return FALSE; char dum = S.pop(); dum = Q.dequeue(); } return TRUE;...
View Full Document

Ask a homework question - tutors are online