Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

1. What makes a program easy to modify?

2. Describe the order of magnitude of the following code section using Big(O) notation.

j = 1;

While (j < N)

{

  j = j * 2);

}

3. What are the benefits we accrue by using a Java interface construct to formally specify the logical level of ADTs?

4. Suppose we have a linked list of Strings, as defined in the textbook, named presidents. Suppose it contains three nodes, with the first node holding "Adams", the second node "Washington", and the third node "Kennedy". What would be output by the following code:

LLStringNode temp = presidents;

while (temp != null)

{

   temp = temp.getLink();

}

System.out.println(temp.getInfo());

5. Suppose a collection object is defined to hold elements of class Object, and you use it to store String objects. Describe what you must do when you retrieve an object from the collection and intend to use it as a String.

6. Show what is written by the following segment of code, given that item1, item2, and item3 are int variables, and stack is an object that fits our abstract description of a stack. Assume that you can store and retrieve variables of type int on stack.

item1 = 1;

item2 = 0;

item3 = 4;

stack.push(item2);

stack.push(item1);

stack.push(item1 + item3);

item2 = stack.top();

stack.push (item3*item3);

stack.push(item2);

stack.push(3);

item1 = stack.top();

stack.pop();

System.out.println(item1 + " " + item2 + " " + item3);

while (!stack.isEmpty())

{

  item1 = stack.top();

  stack.pop();

  System.out.println(item1);

}

7. Explain the relationship between dynamic storage allocation and recursion.

8. Analyze the factorial method and answer the following questions:

int factorial (int n)

{

  if (n > 0)

    return (n * factorial (n - 1));

  else

    if (n == 0)

      return 1;

}

a. What is the base case?

b. What is the general case?

c. What are the constraints on the argument values?

d. What does the method do?

9. What are the three interfaces we defined related to our Queue ADT?

10. Describe in general terms the approach we use to implement an unbounded queue based on an array.

11. What does it mean for a class's equals and compareTo methods to be "consistent"?

12. Questions a-e below refer to the following figure:

a. What are the ancestors of node J?

b. What are the descendants of node T?

c. What are the descendants of node B?

d. What is the order in which the nodes are visited by a preorder traversal?

e. What is the order in which the nodes are visited by a postorder traversal?

13.  If a heap is used to implement a priority queue, what is the Big O efficiency of the enqueue operation, assuming the size of the priority queue is N?

14.  What would be the order of the following list after two iterations of the "inner" part of the Insertion Sort algorithm?

13         4          16         19         2          15         12         3          23         20

15. Suppose we are using Merge Sort to sort the following list of numbers. What would be the order of the list immediately before the execution of the merge method in the original (non-recursive) call to mergesort?

13         4          16         19         2          15         12         3          23         20

16. Programming Sorting Algorithms: For this section, use the Sorts.java test harness (provided by instructor).

a. Describe an approach to modifying the Sorts.java program so that after calling a sorting method the program prints out the number of swaps needed by the sorting method.

b. Implement your approach.

c. Test your new program by running the selectionSort method. Your program should report 49 swaps.

d. Now, modify your program to also output the number of comparisons (compares) needed. You must include one or more statements to increment your counter within the sorting methods themselves. For each of the listed methods, make and test the changes needed, and list both the number of swaps and the number of compares needed by the Sorts program to sort an array of 50 random integers.

selectionSort     swaps:____       compares:____

bubbleSort        swaps:____       compares:____

shortBubble      swaps:____       compares:____

insertionSort     swaps:____       compares:____

Java, Programming

  • Category:- Java
  • Reference No.:- M91249137
  • Price:- $90

Guranteed 48 Hours Delivery, In Price:- $90

Have any Question?


Related Questions in Java

Assessment socket programmingtaskwrite a java gui program

Assessment: Socket Programming Task Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If yo ...

Retail price calculatorwrite a java program that asks the

Retail Price Calculator Write a JAVA program that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: (If an item's wholesale cost is 5. ...

Applied software engineering assignment 1 -learning

Applied Software Engineering Assignment 1 - Learning outcomes - 1. Understand the notion of software engineering and why it is important. 2. Analyse the risk factors associated with phases of the software development lif ...

Assessment database and multithread programmingtasktask 1

Assessment: Database and Multithread Programming Task Task 1: Grade Processing University grading system maintains a database called "GradeProcessing" that contains number of tables to store, retrieve and manipulate stud ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Can someone please help me with the following java

can someone please help me with the following java question The input is an N by N matrix of nonnegative integers. Each individual row is a decreasing sequence from left to right. Each individual column is a decreasing s ...

Project requirementsfor the problem described in the next

Project requirements For the problem described in the next section, you must do the following: 1. include your student ID at the end of all filenames for all java code files. Three classes have been identified in section ...

In relation to javaa what is constructor the purpose of

(In relation to Java) A. What is constructor? the purpose of default constructor? B. How do you get a copy of the object but not the reference of the object? C. What are static variables and instance variables? D. Compar ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Assessment instructionsin this assessment you will design

Assessment Instructions In this assessment, you will design and code a simple Java application that defines a class, instantiate the class into a number of objects, and prints out the attributes of these objects in a spe ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As