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

  Create a student object based on the information given

You will then attempt to open the file, create a Student object based on the information given in the file and read the student's essay from the file.

  Advantages of the java object class structure

Discussion Question: What are the advantages of the Java object class structure with its instance fields and methods

  Java application that calculates weekly pay for an employee

I have attach the pseudocode for it. I have also attach the program that I wrote for it and it will not compile need help on it. Now does the progrma follow suit with the pseudocode or not? In not then how do I go about on doing it?

  An int representing the value stored inside the node

In Java, code a doubly linked, sorted list (in ascending order). Each item of the list will just store an int. You need to code three classes: Nade, SortedList, and GroupProject. The Node class has three instance variables, all private: an int..

  Technical community blog

Write a blog article for a coding and technical community blog.

  Variable of type string that has been assigned

Assume that word is a variable of type string that has been assigned a value. Write an expression whose value is a string consisting of the last three characters of the value word. So if if the value if word were "biggest" the expression's value w..

  Prepare an app that calculates the product of a series

Prepare an app that calculates the product of a series of integers that are passed to method   product using a variable-length argument list.

  Trying to write it java first and then pseudo code

A popular diversion in the United States, "word find" (or "word search") puzzles ask the player to find each of a given set of words in a square table filled with single letters. Trying to write it java first and then pseudo code

  Elements in a two-dimensional array

Write a value-returning method that returns the number of columns with n elements in a two-dimensional array of chars, where n is a parameter of the method. Include code to test your method.

  Build the gui layout of the gamecreate a class called

build the gui layout of the gamecreate a class called pipegameapp.java which will be the main game user interface. the

  In a method named setfavoritesports declare

In a method named setFavoriteSports declare the sports array and populate it.  This method will return the sports array to the calling statement.  The 9 in the prompt below will print 1 for the first sport, then 2 for the 2nd one and so forth.  Use t..

  Which correctly creates an array of five empty strings

Which correctly creates an array of five empty Strings? Which of the following statements is preferred to create a string "Welcome to Java"?

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