QuestionQuestion

Transcribed TextTranscribed Text

Q1 Order the following functions by asymptotic growth rate. Anlogn + 2n 210 2logn 3n + 100logn 4n 27 n2+10n n° nlogn Q2. Consider the following code fragment, taken from some package : public class Maryland extends State { Mayland() { /* null constructor */ } public void printMe0) ( System.out.println("Read. } public static void main(String[] largs) { Region mid = new State(); State md = new Maryland(); Object obj = new Place(); Place usa = new Region(); md.printMc(); mid.printMc(); ((Place) obj).printMe(); obj=md; ((Maryland) obj).printMe();obj = usa; ((Place) obj).printMe(); usa=md; ((Place) usa).printMe(); 11 class State extends Region { State() { /* null constructor */ ) public void printMe() ( System.out.println("Ship it.");) ) class Region extends Place { Region() { /* null constructor */} public void printMe0) ( System.out.println("Box it."); ) } class Place extends Object { Place() { null constructor */ } public void printMc() { System.out.println("Buy it.");} } What is the output from calling the main() method of the Maryland class?

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

The order of growth for each function is given by the dominant term (the term of the highest degree). In order to be easier for ordering the functions by their asymptotic growth rate it is necessary to process some of them.
2^log⁡n = n =O(n) (according the basic properties of Math operations).
2^10=1,024 therefore O(1) (since it is a contant)
4nlog⁡n +2n is O(nlog⁡n)
3n+100log⁡n is O(n)...
$15.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Data Structures and Algorithms Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats