Computers and Technology

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.

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 24.06.2019 18:30, shemiahking5432
Jacking is a crime that takes place when a hacker misdirects url to a different site. the link itself looks safe, but the user is directed to an unsafe page
Answers: 1
image
Computers and Technology, 24.06.2019 22:00, apexdude2020
Need getting google account back, big issue
Answers: 2
image
Computers and Technology, 25.06.2019 08:00, yungkxng57
Is a major factor in the widespread use of global information systems
Answers: 1
image
Computers and Technology, 25.06.2019 08:00, jzjajsbdb8035
Beginning in the 1940s, first-generation computers used circuitsvacuum tube technologylaser technologytransistors
Answers: 2
Do you know the correct answer?
HW3 Implement MyArrayList and MyLinkedList using MyList interface and MyAbstractList as defined in J...

Questions in other subjects:

Konu
Biology, 29.11.2019 08:31
Konu
Mathematics, 29.11.2019 09:31