subject

HW3 Implement MyArrayList and MyLinkedList using MyList interface and MyAbstractList as defined in Java Collection Framework. (10 points)

* For the following problem use your own created MyArrayList or MyLinkedList if needed. (10 points)

Given an array of words and a width maxWidth, format the text such that each line has exactly maxWidth characters and is fully (left and right) justified.

You should pack your words in a greedy approach; that is, pack as many words as you can in each line. Pad extra spaces ' ' when necessary so that each line has exactly maxWidth characters.

Extra spaces between words should be distributed as evenly as possible. If the number of spaces on a line do not divide evenly between words, the empty slots on the left will be assigned more spaces than the slots on the right.

For the last line of text, it should be left justified and no extra space is inserted between words.

Note:

* A word is defined as a character sequence consisting of non-space characters only.

* Each word's length is guaranteed to be greater than 0 and not exceed maxWidth.

* The input array words contains at least one word.

Example 1:

Input:

words = ["This", "is", "an", "example", "of", "text", "justification."]

maxWidth = 16

Output:

[

"This is an",

"example of text",

"justification. "

]

Example 2:

Input:

words = ["What","must","be","acknowledgment ","shall","be"]

maxWidth = 16

Output:

[

"What must be",

"acknowledgment ",

"shall be "

]

Explanation: Note that the last line is "shall be " instead of "shall be",

because the last line must be left-justified instead of fully-justified.

Note that the second line is also left-justified because it contains only one word.

Example 3:

Input:

words = ["Science","is","what","we","unders tand","well","enough","to","explain ",

"to","a","computer.","Art","is","ev erything","else","we","do"]

maxWidth = 20

Output:

[

"Science is what we",

"understand well",

"enough to explain to",

"a computer. Art is",

"everything else we",

"do "

]

HW 3 bonus: implement A circular, doubly linked list with threads.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 11:30
To hide gridline when you display or print a worksheet
Answers: 1
question
Computers and Technology, 23.06.2019 06:30
To become an audio technician, the most successful tactics might include the following. (select all that apply). learning how to persuade other people gaining different types of experience in audio technology learning as much as possible about art history establishing a reputation as a reliable professional
Answers: 1
question
Computers and Technology, 24.06.2019 03:00
What is one potential problem associated with an organization purchasing new technology early in its lifecycle
Answers: 1
question
Computers and Technology, 24.06.2019 06:00
Hey i really need some solving this problem: 1. encrypt this binary string into cipher text: 110000. include in your answer the formula the decoder would use to decrypt your cipher text in the format (coded answer) x n mod (m) = y & 2. decrypt this cipher text into a binary string: 106 you.
Answers: 2
You know the right answer?
HW3 Implement MyArrayList and MyLinkedList using MyList interface and MyAbstractList as defined in J...
Questions
Questions on the website: 13722360