Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Submit either of the documentation sets from the work on page 36 below 1.6 Invok

ID: 3813625 • Letter: S

Question

Submit either of the documentation sets from the work on page 36 below   

1.6 Invoke the change Color method, and write the color into the parameter field without the quotes. What happens? Pitfall A common error for beginners is to forget the double quotes when typing in a data value of type String. lfyou type green instead of "green", you will get an error message saying something like "Error: cannot find symbol variable green Java supports several other data types, including decimal numbers and characters. We shall not discuss all of them right now, but rather come back to this issue later. If you want to find out about them now, look at Appendix B 1.6 Multiple instances Exercise 1.7 Create several circle objects on the object bench. You can do so by select ing new Circle() from the pop-up menu of the Circle class. Make them visible, then move them around on the screen using the "move" methods. Make one big and yellow; make another one small and green. Try the other shapes too: create a few triangles, squares, and persons. Change their positions, sizes, and colors Once you have a class, you can create as many objects (or instances) of that class as you Concept like. From the class Circle, you can create many circles. From Square, you can create Multiple many squares. nstances. Many similar objects can Every one of those objects has its own position, color, and size. You change an attribute of an be created from a object (such as its size) by calling a method on that object. This will affect this particular object, single class. but not others You may also notice an additional detail about parameters. Have a look at the changeSize method of the triangle. Its signature is void change Size (int newHeight int newWidth) Here is an example of a method with more than one parameter. This method has two, and a comma separates them in the signature. Methods can, in fact, have any number of parameters. 1.7 State The set of values of all attributes defining an object (such as x-position, y-position, color, Concept diameter, and visibility status for a circle) is also referred to as the object's state. This is another example of common terminology that we shall use from now on Objects have state. The state is repre In BlueJ, the state of an object can be inspected by selecting the Inspect function from the ob- sented by storin ng ject's pop-up menu. When an object is inspected, an object inspector is displayed. The object values in fields inspector is an enlarged view of the object that shows the attributes stored inside it (Figure 1.60

Explanation / Answer

Divide the set into 2 equal sized components by the road l, and recursively figure the token distance in every half.
Let d be the token of the 2 token distances.
Eliminate points that lie farther than d excluding l
Sort the remaining points in step with their y-coordinates
Scan the remaining purposes within the y order and figure the distances of every point to its 5 neighbors.
If any of those distances is a smaller amount than d then update d.
Steps 2-6 outline the merging method that should be perennial logn times as a result of this can be a divide and conquer algortithm:
Step a pair of takes O(1) time
Step three takes O(n) time
Step four could be a kind that takes O(nlogn) time
Step five takes O(n) time (as we have a tendency to saw within the previous section)
Step half-dozen takes O(1) time
Hence the merging of the sub-solutions is dominated by the sorting at step four, and therefore takes O(nlogn) time.
This should be perennial once for every level of rule within the divide-and-conquer formula,

hence the complete of formula ClosestPair takes O(logn*nlogn) = O(nlog2n) time.