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 10:20
Print "usernum1 is negative." if usernum1 is less than 0. end with newline. convert usernum2 to 0 if usernum2 is greater than 10. otherwise, print "usernum2 is less than or equal to 10.". end with newline
Answers: 3
question
Computers and Technology, 22.06.2019 19:30
Singing in the rain: this first part of the film shows the early history of motion picture. how accurate do you think the portrayal of the early motion picture industry is? why? is historical accuracy important in films and theater productions? explain.
Answers: 1
question
Computers and Technology, 24.06.2019 02:50
Be sure to answer all parts. synthesize the following compound from benzene. a. b. c. d. e. f. reaction [1] conditions: a b c d e f reaction [1] product: draw structure reaction [2] conditions: a b c d e f reaction [2] product: draw structure reaction [3] conditions: a b c d e f reaction [3] product:
Answers: 3
question
Computers and Technology, 25.06.2019 02:00
Feedback is one of the basic elements games have in common true false
Answers: 2
You know the right answer?
HW3 Implement MyArrayList and MyLinkedList using MyList interface and MyAbstractList as defined in J...
Questions
question
English, 14.11.2020 04:20
question
Mathematics, 14.11.2020 04:20
question
Spanish, 14.11.2020 04:20
Questions on the website: 13722359