Review the given code fragment from arraybag class

Assignment Help JAVA Programming
Reference no: EM131179407

Q1. Review the given code fragment from ArrayBag class below and answer the following:

a. Explain each line in your own words:

b. Write the header (signature) of the method that contains this code.

checkInitialization();

int index = getIndexof(anEntry);

T result = removeEntry(index);

return anEntry.equals(result);

Q2. For the LinkedBag class write the code for the method: "boolean add(T obj)".

Q3. Simplify the following running time functions as O "Big-O":

a. T(n) = log2(n8)+n2 +1024n

b. T(n) = n√n + 2048/n4 + n!

c. T(n) =  n/256 + 64√n + 128n

Q4. Write the output of the following code:

String s = "CSIS210";

Stack stk = new Stack();

for(char c : s.toCharArray()){

stk.push(c);

}

for(int i=0; i<4; ++i) stk.peek();

for(int i=0; i<3; ++i) System.out.print(stk.pop());

for(int i=0; i<4; ++i) System.out.print(stk.pop());

Q5. Find and fix all errors in the following code.

public void pop(T obi) {

checkInitialization();

if (!isEmpty(Stack)) {

throw new EmptyStackException();

} else {

T top = stack[0];

Stack[topIndex] = 0;

++topIndex;

return top[0];

}

}

Reference no: EM131179407

Questions Cloud

What is the expected capital gains yield on the stock : Company ABC last dividend was $2.50. The current price of the stock is $50 and the firm is expected to grow 5% per year. What is the expected capital gains yield on the stock? (round to 2 decimals as a %)
An entrepreneur seeking best site for his or her business : What is the special appeal of an enterprise zone to an entrepreneur seeking the best site for his or her business?
Why the loads on the slab-on-ground in concrete tilt-up : Explain why the loads on the slab-on-ground in concrete tilt-up wall building are generally higher during the construction of the building than after the building is complete.
Develop financial section of your nab companys business plan : Develop the following financial sections of your NAB company's Business Plan. Note: Attach the MS Word document to the discussion thread.
Review the given code fragment from arraybag class : Review the given code fragment from ArrayBag class below and answer the following: Explain each line in your own words: Write the header (signature) of the method that contains this code
Which resource factors might be most vital : Which resource factors might be most vital to a new manufactunng venture that produces residential home furniture? Why?
Payment stream assuming your required rate : Suppose you wish to receive payments of $1371.2 in one year's time, $685.6 in two years' time, and $6856 in three years' time. What is the cost today of the payment stream assuming your required rate of return is 4.50% p.a.?
Determine how economics of greece spain and portugal have : Determine how the economics of Greece, Italy, Spain and Portugal have contributed to a global economic crisis. and how the global impact of such economies can be mitigated in the future. Provide specific examples to support your response.
Is hometown of business owner likely to be a good location : Is the hometown of the business owner likely to be a good location?- Is it logical for an owner to allow personal preferences to influence a decision about business location?

Reviews

Write a Review

JAVA Programming Questions & Answers

  A method with the signature public static void

A method with the signature public static void printDetails(City[] cities) that will iterate through the cities and printthe details of the city using the displayDetails(...) method.

  What are some of the differences in the sql

What are some of the differences in the SQL supported by RDBMS vendors?

  Write a method that prompts the user for a word and prints

Write a method that prompts the user for a word and prints out its equivalent in Pig Latin. To translate a word to Pig Latin, take the initial letter, move it to the end of the word and add 'ay'. The new suffix (first letter with ay) should be pri..

  Button to increase or decrease the number of the balls

Simulates a bouncing ball. Extend to allow mulitple balls. You can use the +I or -I button to increase or decrease the number of the balls and use teh Suspend and Resume buttoms to freeze the balls or resume bouncing. For each ball, assign a random c..

  Calculate and return the sum of the geometric series

calculate and return the sum of the geometric series

  Java application prompt user to put in integer from keyboard

Write a java application that performs the following task: prompt user to put in an integer from the keyboard, search for the user input from the array created in step 1.

  Implement/update specific methods for the dfs of a graph

implement/update specific methods for the DFS of a graph; for at least 2 graphs (1 being the provided one), show the DFS order of vertices in the graph, and for each node,

  Produce a fully functional gui program

Produce a fully functional GUI program in accordance with the specifications mentioned below. The program will be used to determine and display the final mark of students

  Create the program which converts fahrenheit to celsius

Create the following program which converts Fahrenheit to Celsius. Read integer Fahrenheit temperatures from the user.

  User enters a list of car parts

So if the user enters a list of car parts, the programm holds this list. Afterward, when the user types in the name of the part the programm outputs that name from the list.

  Objective to learn the use of comments and basic math

objective to learn the use of comments and basic math operators.create a new folder called assign21 under

  Write a java program that accepts a positive long integer

Write a Java program that accepts a positive long integer between 2 to 15, and then using the number, calculate its factorial (n!). Using do-while statement, make sure it only accepts a valid number (between 2 and 15) - if an invalid number is ent..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd