COP2500 Assignment 10

Deliverables: To complete this assignment you must --
1.) Complete the JavaScript coding for a queue and a stack. Use this page as a stating point.

Introduction: The main goal of this assignment is to familiarize yourself with the details of stacks and queues.
You will code the Push(), Pop(), and Peek() functions for the stack
and the Enqueue() and Dequeue() functions for the queue.
The document lab10form.html contains the forms and global variables you will need to do this. It also contains shell functions for you to fill in. Use the algorithms below to complete the functions. Show your results to your lab instructor prior to the end of lab.

Queue Functions:
Enqueue()Dequeue()
Input document.queue.entry.value
(user entry from form text box)
None required.
Other VarsQueue myqueue;
Integer back;
Integer front;
Queue myqueue;
Integer back;
Integer front;
Init. None - all global variables. None - all global variables.
Computationback++;
myqueue[back] = document.queue.entry.value;
IF (back < front) THEN
alert user that queue is empty.
ELSE
alert returned value of myqueue[front];
front++;
ENDIF
OutputNone (done through alerts). None (done through alerts).

 

Stack Functions:

Push()Pop()Peek()
Input document.stack.entry.value
(User entry from stack text box.)
None required.None required.
Other Vars Stack mystack;
Integer top;
Stack mystack;
Integer top;
Stack mystack;
Integer top;
Init. None - all global variables. None - all global variables. None - all global variables.
Computation top++;
mystack[top] = document.stack.entry.value;
IF (top < 0) THEN
alert user stack is empty.
ELSE
alert value of mystack[top]; top--; ENDIF
IF (top < 0) THEN
alert user stack is empty.
ELSE
alert value of mystack[top]; ENDIF
OutputNone (done through alerts). None (done through alerts). None (done through alerts).