Question

An array of 100 elements is to be sorted using the bubble sort in the modules (the one that tests the return value of floatLaAssume you are working inside the method definition of some instance method of lass B you are writing the statements that defWhich diagram best describes the idea of different derived classes inheriting from the same base class in Java? BaSC DerivediMatch each data structure with its best description. Data is a LIFO: There is only one data item that is naturally fetched (rConsider the following statement: FileInputStream galSource- new FileInputStream(GalaxyData.txt Check the true statements (t

An array of 100 elements is to be sorted using the bubble sort in the modules (the one that tests the return value of floatLargestToTop0 to see if it can return "early".) Check all the true statements about the sort algorithm, i.e., the sort method and its support methods. (Check all that apply.) It will sometimes return (completely sorted) after only 99 data comparisons. It will always require at least one swap. It will always require at least 99 comparisons It will always return (completely sorted) after 99 data comparisons
Assume you are working inside the method definition of some instance method of lass B you are writing the statements that define this method. In order to call an instance method of a class A from inside this instance method of a class B (where B and A are unrelated by inheritance to one-another), you: O must use an object of a third class, a base class of both class A and class B, for dereferencing. O can call the method without any object used for dereferencing. . must use an object of class A for dereferencing the method cal. must use an object of class B for dereferencing the method call
Which diagram best describes the idea of different derived classes inheriting from the same base class in Java? BaSC Derivedi Derived2 Basel Base2 Derived
Match each data structure with its best description. Data is a LIFO: There is only one data item that is naturally fetched (returned) to the client at any given moment, and it is the item most recently stored Queue Data is both LIFO and FIFO: The are potentially two data items that could be naturally fetched (returned) to the client at any given moment, either the the item Stack Data is neither LIFO nor FIFO: Client can naturally fetch (return) any of the many data items stored. Array Data is a FIFO: There is only one data item that is naturally fetched (returned) to the client at any given moment, and it is the oldest (earliest) item stored Deque
Consider the following statement: FileInputStream galSource- new FileInputStream("GalaxyData.txt Check the true statements (there may be more than one) If the file GalaxyData.txt could not be opened for some reason, a FileNotFoundException would be thrown which our client could try and catch. It attempts to open a file named 'GalaxyData.txt for writing/output It attempts to open a file named "galSource" for reading/input О lt attempts to open a file named "GalaxyData.txt' for reading/input. If GalaxyData.txt is successfully opened, then we could use the statement val- myFilein.read) to read a byte from it. O If the file is successfully opened and we read to the very end, the next time we try to read, using val-myFiiein.readO read0 would throw an exception.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

1) Bubble sort has to compare all the elements once to check if they are sorted.

So the answer is it will sometimes return completely sorted array in 99 comparisons. It will always require atleast 99 comparisons.

Bubble sort will keep comparing adjacent elements in the n iterations, n here is 100. Assuming array is already sorted, minimum number of comparisons required is 99 in the first iteration. If no swap occurs we know array is already sorted so it requires atleast 99 comparisons. If the array is already sorted, it will in such cases return completely sorted array in first iteration itself.

It always requires 1 swap is false, if array is sorted no swaps occur

2) The two classes are unrelated by inheritance, unless the method you want to call is static, object is needed to deference the method.

You must use an object of class A for dereferencing the method call.

3) Base class is one and derived classes are many as per the question. So the correct answer is first figure

base class

/ \

derived 1 derived2

4) LIFO - Last in first out

FIFO - first in first out

LIFO structure is stack where push and pop occur from same side

LIFO and FIFO is deque. Double sided queue where push pop occurs from both sides of data structure

Neither LIFO or FIFO is array, you could access any element of array anytime.

FIFO is queue where insert occurs at one end and removal at other end

5) FileInputStream class is used to read a file so the operation is taking input from file. File name is passed to the constructor. If the file doesn't exist it will throw file not found exception.

If "GalaxyData.txt" is opened successfully you could use read method to read a byte but it should be called from the object of FileInputStream which is galSource.read() in this case.

Same is the case with last option, If called from the file object galSource it would give exception at the end as there is no more data to be read.

So the correct answers is option a) throws an exception that can be put in try catch block,

d) it attempts to open a file named "GalaxyData.txt" for reading/input

Add a comment
Know the answer?
Add Answer to:
An array of 100 elements is to be sorted using the bubble sort in the modules (the one that tests...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT