Question: Part 3 : Printing a Path Part 3 . 1 : Node findPredPath ( int i ) Node findPredPath ( int i ) should find

Part 3: Printing a Path
Part 3.1: Node findPredPath(int i)
Node findPredPath(int i) should find the path to the predecessor of index i(exactly the same as
Node findPred(int i)) and return the predecessor Node. However, in this version you should store the path
somehow. You may look at ods. SkiplistSSet. java for inspiration - it uses an array of Nodes called stack to save
part of the path on a call to add (T x). This may not be sufficient for your needs, but it is a good starting place.
Part 3.2: String toStringWithPath()
This method is currently exactly the same as String toStringWithNodes(). You are to modify it so that its out-
put highlights the path found on the previous call to Node findPredPath(int i). To highlight a path replace all
instances of,>>>>, or >>>>>>>>along the path. You do NOT have to indicate downward steps. This method need work ONCE per call to
findPredPath(). If you call toStringWithPath() twice in a row without a second call to findPredPath(), it
does not need to highlight the path on the second call (although it can if you like). That means that you can destroy
the path that was stored as you highlight it if you wish.
IMPORTANT: Do not change how anything else is printed. The tests will check if the returned String is an
exact match to the correct version. If it is not exact, you get 0 marks. For example, if you accidentally add a space
somewhere, you will get 0.
An example of the expected output is provided below. It also highlight another function, toStringWithLength,
that provides the length of each next pointer (which you may use for debugging).
Note that findPredPath(4) finds a path to the predecessor of Node 4, which is Node 3(containing ' c ').
 Part 3: Printing a Path Part 3.1: Node findPredPath(int i) Node

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!