Question

Please use java language to answer these qustions, and then test the code if it need...

Please use java language to answer these qustions, and then test the code if it need code (like qustion 2) to make suer the code work fine and type the answer please

1- Order the following functions by asymptotic growth rate. Explain your answer.

4n log n 210          2log n      

3n + 100 log n 4n 2n

n2 + 10n n3   n log n

2-Implement a method with signature transfer (S, T) that transfers all elements?

Please use java language to answer these qustions, and then test the code if it need code (like qustion 2) to make suer the code work fine and type the answer please

0 0
Add a comment Improve this question Transcribed image text
Answer #1

PART 1:

The functions are arranged in increasing order by using the value of n in the functions. In general I will provide you a list that would help you for future arranging of the asymptotic functions.

0(1) < O(log n) < O(n) < O(nlog n) < O(n2) < O(n2logn) < O(n3) < O(2n)

The value of ‘log n’ is less ‘n’ and any number of addition in the value by ‘n’ will increase the value.

Following are the increasing order of the asymptotic growth rate:

1.   4nlog n, 210, 2log n

210 < 2log n < 4nlog n

2.   3n + 100log n, 4n, 2n

2n< 4n< 3n+100log n

3.   n2 + 10n, n3, nlog n

nlog n < n2 + 10n < n3

PART 2:

public static void signatureTransfer(Stack stack1, Stack stack2)
{
Object topOfStack = stack1.topOfStackEl();
//save the topOfStack
  
topOfStack = stack1.pop();
stack2.push(stack1.pop());
stack2.push(stack1.pop());
  
//push it back on to the stack
stack1.push(topOfStack);
stack1.push(stack2.pop());
stack1.push(stack2.pop());
  
//save the topOfStack
topOfStack = stack1.pop();
  
   // The bottom is left in Stack1
   stack2.push(stack1.pop());
stack2.push(topOfStack);
stack1.push(stack2.pop());
stack1.push(stack2.pop());
while(!stack1.isEmpty()){
stack2.push(stack1.pop());
}
System.out.println(stack1.toString());
System.out.println(stack2.toString());
}

Add a comment
Know the answer?
Add Answer to:
Please use java language to answer these qustions, and then test the code if it need...
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
  • need help with a few excercises on general concepts using JAVA language. Try it: what is...

    need help with a few excercises on general concepts using JAVA language. Try it: what is the value of x after each operation? int x = 9; int y = 5; x = x/y; x += 6; x++; x--;I x %= 5; Try it: • What do these evaluate to? int x = 4; int y = ++X – 3 * 2; int z = x++ - 3 * 2; int w = x + 6/2; int t = x+...

  • C Language! Please, comment what each line of code does in the code below and answer...

    C Language! Please, comment what each line of code does in the code below and answer this question: (sentence is fine) 1. Aside from pressing ctrl-(d/z) at the beginning of a line causing the getnchar() function to return NULL, is there any way to enter less than 9 characters? Code: void exer1(void) {    char input[LEN];    char *check; getchar(); // Clearing character buffer. printf("Please enter 9 characters: "); // Prompting the user to enter // a specific input.   ...

  • Need Help Please Using Java Language Create a Code Write a class (and a client class...

    Need Help Please Using Java Language Create a Code Write a class (and a client class to test it) that encapsulates the evolution of the passwords of three students over four months. Your only instance variable should be a two-dimensional array of values representing the passwords. Dimension 1 represents the student and dimension 2 represents the month. (Since we are concerned about security, we are assuming that people change their password once a month; we only care about the value...

  • Please, i need Unique answer, Use your own words (don't copy and paste). *Please, don't use...

    Please, i need Unique answer, Use your own words (don't copy and paste). *Please, don't use handwriting. Describe when and why you should use PHP (as a server-side programming language). Why a client-side programming language (like JavaScript), not enough? Also, is it generally safe to keep credentials like the Database passwords in PHP source code? Why? Compare that to doing the same thing in JavaScript.

  • please write code in java language and do not add any break, continue or goto statements...

    please write code in java language and do not add any break, continue or goto statements Write a program with a graphical interface that allows the user to convert an amount of money between U.S. dollars (USD), euros (EUR), and British pounds (GBP). The user interface should have the following elements: a text box to enter the amount to be converted, two combo boxes to allow the user to select the currencies, a button to make the conversion, and a...

  • Hello, I need the correct answer for this please , a quick sort program -java code-...

    Hello, I need the correct answer for this please , a quick sort program -java code- that have 2 arrays first one will have different values , the second one the values will be from smallest to largest number then the program have a quick sort to do it for both of them and will count the time - how long the quick sort is take for each one - which array is faster. Thank you ❤️

  • answer this question please, use java language Exercise 5: StyleOption program a) Modify the "StyleOption" program,...

    answer this question please, use java language Exercise 5: StyleOption program a) Modify the "StyleOption" program, in your lecture slides, to allow the user to specify the font name and size. Use combo boxes to obtain the font name and size (at least add four font name and 10 sizes) Style Options Say it with style! ]Bold Italic Make A Selection.... 26 b) Modify your solution in part 'a' such that it uses a slider to obtain the font size....

  • JAVA! Algorithm using Java Collections Framework. Please only answer if you can help... Basically we need...

    JAVA! Algorithm using Java Collections Framework. Please only answer if you can help... Basically we need to find an algorithm using an EFFICIENT JCF in order to get to the solution... for this problem, I need to go through a text file and output only the last 8888 lines in order that they appear...if there are fewer lines, then print all of those... But my code is too slow because I store the all lines (s.add(lines)) i think...and I can't...

  • I need help with this problem please, This code needs to be in Ruby, Java, or...

    I need help with this problem please, This code needs to be in Ruby, Java, or Python. See problem below. -5 - Functional Programming (due Mon] Assignment Content Your software company was invited to provide a proposal for a company in Australia. You currently have the cost in US dollars and need to convert the prices to the Australian dollar. Write a 2-part program using Ruby, Java, or Python. Part 1: Write a function to gather the following costs from...

  • Please use java code. Implement a test class named BatArray1Test that tests all the functionality of...

    Please use java code. Implement a test class named BatArray1Test that tests all the functionality of the following given 3 methods, including the invalid arguments: 1) commonEnd Given two arrays of ints, a and b, return true if they have the same first element or they have the same last element. This method should return false if either array is empty or null. 2) midThree Given an array of integers, return a new array of length 3 containing the elements...

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