Write pseudocode for an algorithm that checks a string to see if it
contains correctly matched pairs of brackets and parentheses. Test your
algorithm on the following inputs: "[()]"
, "[]()"
, "[(])"
, "(("
, "))"
.
ALGORITHM: CheckMatches
INPUT: I - A string containing only the characters '[', ']', '(' and ')'.
OUTPUT: True if the string contains only correctly matched brackets
and parentheses, False otherwise.
Implement the Queue ADT using only stacks to store information. Analyze the running time of each operation.
// Declare instance variables...
StackQueue() {
}
void enqueue(E item) {
}
E dequeue() {
}
Implement the Stack ADT using only queues to store information. Analyze the running time of each operation.
// Declare instance variables...
QueueStack() {
}
void push(E item) {
}
E pop() {
}
Implement the following subset of the List ADT using only Stacks to store information. Analyze the running time of each operation.
// Declare instance variables...
StackList() {
}
void insert(E item) {
}
E remove() {
}
void moveToPos(int pos) {
}