CSCI455 – CS 455 Lab 10: Linear Containers (Solution)

$ 29.99
Category:

Description

Goals and Background
In this lab you’ll get some practice working with some Java linear contaner classes (besides ArrayList). The first problem uses the LinkedList class, in particular, using an iterator on a LinkedList. The other problems use the Stack class.
Reading and Reference Material
Horstmann, Sect. 15.2, Using Linked Lists
Horstmann, Sect. 15.5.1 and 15.6 on Java Stacks
Horstmann, Section 15.6.1 Balancing parentheses example
Exercise 1 (1 checkoff point)
list hasOnePeak(list)
2 4 7 false
2 7 4 true
7 4 2 false
2 4 false
2 false
2 4 7 9 3 2 true
2 4 7 9 7 3 7 1 false
7 5 4 false
2 4 2 3 false
5 4 3 false
Exercise 2 (1 checkoff point)
Exercise 3 (1 checkoff point)
[1, 2, 3, 2, 4, 5] <– top
the expected output is
[1, 3, 5] <– top
Exercise 4 (1 checkoff point)
<p> some text <ul> <li> some more <a> wow!
</a> </li> </ul> <a> </a> </p> some more text
The inner tags must be closed before the outer ones. For simplicity, assume the tags are separated by whitespace, as is any other text in the file. You must use a stack to help you match tags.
To make this problem easier, we wrote some helper methods for you: isOpening, isClosing, and getTagName.
Before you start your implementation, do Part 1 to make sure you understand the problem, and expected results.
Part 1: add expected results. The test program Html.java contains several test cases for matchingTags, but right now the expected results provided are all false, whether the string does or does not contains matching tags. Look at the helper method testOneString to see what it does with its parameters. Run the starter version of this code.
Change the starter version so all the calls to testOneString have the correct expected results: i.e., based on whether the string provided has matching tags or not you’ll put in a true or a false. (Some of the tests will still fail, of course, because matchingTags is a stub method.)
Part2: implement method. Implement matchingTags as described above. When you have a correct implementation (run on correct expected results) none of the test cases should print FAILED.
Checkoff for DEN students
Make sure you put your name and NetID in the source code files and README.
When you click the Submit button, it will be looking for and compiling (for source code) the files
README, PeakTester.java, removeTests.out, RemoveEvens.java and Html.java.

Reviews

There are no reviews yet.

Be the first to review “CSCI455 – CS 455 Lab 10: Linear Containers (Solution)”

Your email address will not be published. Required fields are marked *