Question: Representations and Abstractions CircArrayPipe Specifically, assume that an initial array contains all null values, and assume that removing an element from the pipe does *not*
Representations and Abstractions
CircArrayPipe
Specifically, assume that an initial array contains all null values, and assume that removing an element from the pipe does *not* remove the element from the internal array.
1. Complete a CircArrayPipe representation for the Pipe abstraction = [A, B, C]:4 in which first < last and first 0.
| contents = [ ... ] first = ... last = ... length = ... capacity = ... |
2. Complete a CircArrayPipe representation for the Pipe abstraction = [P, Q, R]:4 in which first > last and none of the array elements are null values.
| contents = [ ... ] first = ... last = ... length = ... capacity = ... |
3. Write the Pipe abstraction corresponding to the CircArrayPipe representation: contents = [A, B, C, D, E] and first =3 and length = 4.
| pipe = ... |
4. Give both the representation and abstraction for the CircArrayPipe built using the following code sequence. Assume that an initial array contains all null values and assume that removing an element from the pipe does *not* remove the element from the array. Pipe
| contents = first = ... length = ... capacity = ... |
| pipe = ... |
5. Assume an implementation of circular array pipe with fields first and last, but not length. Complete the implementation for the length method below using only first, last, capacity, and math operations (including %)? Do not use an if statement and do not use another ternary operator. The implementation should have a single line.
| public int length() { return (isEmpty()) ? 0 : ... } |
LinkedPipe
Figure 1 (before)
Figure 2 (after)
6. The diagram in Figure 1 shows a doubly linked list along with a temp node holding element W. Dashed arrows are previous links, and solid arrows are next links. Arrows with a circle at the end point to null. We want to end up with a list like the one in Figure 2. What are thethree steps to achieve that? Choose from one of the following statements for each step. [var1] and [var2] are temp, first, or last; [previous|next] means previous or next.
Relocate [temp|first|last] to [temp|first|last]'s node
Redirect [temp|first|last]'s [previous|next] link to [temp|first|last]'s node
Make [temp|first|last] follow its [previous|next] link
| step 1: ... step 2: ... step 3: ... |
7. What is a one-line command (in Java code) for "Makefirst follow itsprevious link"?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
