ICS 46 Data Structures - Homework 4
ICS 46 Data Structures - Homework 4
Homework 4: Implementing
Stacks and Queues using both
Array and LinkedList
Overview and Objectives
Implementation of Classes and Files
1 Class Holder Hierarchy
2 Function balancing parentheses
Empirical Testing of Data Structures
Sample spreadsheet for your data - make a copy
How to Test
How to Submit
https://docs.google.com/document/u/1/d/e/2PACX-1vQg7QSymE8L…QQtCKa80Mq5xKvmE9gqToh3T_rrsnS4dU5q5wmZR/pub?embedded=true Page 1 of 5
2025/2/4, 21:46
Holder
Stack Queue
The implementations of array and linked list are similar to what you
have done in earlier homework assignments. ArrayStack and
LinkedStack are especially straightforward— implemented
similarly to UnorderedList using Array and LinkedList.
● is_balanced(“({(())})((([({})])))(((((<>
([{()}])(<>))))))()”)
returns true because all are correctly matched and balanced
● is_balanced(“({(<>)})((([({})])))(((((()
([{()}])(())))))”)
returns false because it is missing a closing paren
● is_balanced(“({(<>)})((([({})])))((((([]
([{<>}])(()))))))()])”)
returns false because it has too many closing square brackets
https://docs.google.com/document/u/1/d/e/2PACX-1vQg7QSymE8L…QQtCKa80Mq5xKvmE9gqToh3T_rrsnS4dU5q5wmZR/pub?embedded=true Page 3 of 5
2025/2/4, 21:46
How to Test
In the file student_gtests.cpp, write good GTests for Stack and
Queue. Apply them to all four concrete class implementations.
Set NWORDS to a smaller number, like 450 for initial testing. Be sure
to print out your data structures to be sure items being removed
are coming out in the correct order. Once your program seems to
be working correctly, run it on the full-size word files. Try it on
words.txt which is sorted, making it easier to see if words are
coming out in the correct order.
How to Submit
In GradeScope for Homework 4, upload from GitHub the files
detailed above:
● .Analysis_46HW4
● Timer.h
● holder.h
● holder.cpp
https://docs.google.com/document/u/1/d/e/2PACX-1vQg7QSymE8L…QQtCKa80Mq5xKvmE9gqToh3T_rrsnS4dU5q5wmZR/pub?embedded=true Page 4 of 5
2025/2/4, 21:46
● main.cpp
● student_gtests.cpp
● is_balanced.h
● is_balanced.cpp
● is_balanced_main.cpp
● words.txt
https://docs.google.com/document/u/1/d/e/2PACX-1vQg7QSymE8L…QQtCKa80Mq5xKvmE9gqToh3T_rrsnS4dU5q5wmZR/pub?embedded=true Page 5 of 5