BuildDLL.java public class BuildDLL { DoubleLinkedNode front, rear; private static char[] letters =
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Exercise 1 - Creating a class with generics 1. Create a new class called ReversibleArray. 2. In the class header, add the code immediately to the right of the class name. 3. Give this class two private instance variables: T array and int count 4. Create a constructor which takes in one parameter of type T[] and assign that parameter's value into this. array. Set count as the length of the array. 5. Add a toString() method that outputs the array values in the format: elem0, elem1, elem2, etc. (hint: add the comma and space only if you are not on the final iteration of the loop). 6. Create the most important function in this class: public void reverse () { } a. This method must swap elements within the array, without making a new array or other collection. b. The swaps should be made symmetrically about the middle of the array. This means array[0] swaps with array[n-1], array[1] swaps with array[n-2], etc. c. Use a temp variable to help with these swaps. What variable type should this temp variable be? d. How many swaps must be made to correctly reverse the array? 7. Open TestReverse.java and read over the code in its main() function. Exercise 1 - Creating a class with generics 1. Create a new class called ReversibleArray. 2. In the class header, add the code immediately to the right of the class name. 3. Give this class two private instance variables: T array and int count 4. Create a constructor which takes in one parameter of type T[] and assign that parameter's value into this. array. Set count as the length of the array. 5. Add a toString() method that outputs the array values in the format: elem0, elem1, elem2, etc. (hint: add the comma and space only if you are not on the final iteration of the loop). 6. Create the most important function in this class: public void reverse () { } a. This method must swap elements within the array, without making a new array or other collection. b. The swaps should be made symmetrically about the middle of the array. This means array[0] swaps with array[n-1], array[1] swaps with array[n-2], etc. c. Use a temp variable to help with these swaps. What variable type should this temp variable be? d. How many swaps must be made to correctly reverse the array? 7. Open TestReverse.java and read over the code in its main() function.
Expert Answer:
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these programming questions
-
Briefly describe ASCII and Unicode and draw attention to any relationship between them. [3 marks] (b) Briefly explain what a Reader is in the context of reading characters from data. [3 marks] A...
-
(a) Use the following text to derive distributions for rat and chased. Use a five-word window, including open- and closed- class words, ignore case, punctuation and sentence boundaries and weight...
-
answer the question clearly You are building a flight-control system for which a convincing safety case must be made. Would you assign the tasks of safety requirements engineering, test case...
-
The following data pertain to the securities of Linford Company during 2012, the companys first year of operations: a. Purchased 400 shares of Persimmon Corporation stock at $40 per share plus a...
-
Decay of which nucleus will lead to the following products: (a) Bismuth-211 by beta decay (b) Chromium-50 by positron emission (c) Tantalum-179 by electron capture (d) Radium- 226 by alpha decay?
-
You are given the following information about Company ABC as at 31/12/2023 Premises Shs 25,000,000 Motor vehicles Shs 2,000,000 Electricity bills (Owings) shs500, 000 Creditors' Shs 4,500,000 Cash in...
-
What is the significance of a statechart diagram?
-
Suppose we put into a logical database a segment of the U.S. census data listing the age, city of residence, date of birth, and mother of every person, using social security numbers as identifying...
-
TranscribedText: Problem 2. [25pts] For each of the following vector fields F find the curl. 1. (5pts) F : R3 -> R3 such that F I2 = I3 2TIT213 V X F(x) = 2. (5pts) F : R3 -> R3 such that F I2 = T2 +...
-
1. Journalize the following transactions in the general journal On January 1, 2018, a payment in cash for $12,000 is made for prepaying rent for the entire year 2018. On January 4, 2018, accounting...
-
The UCC requires that an agreement modifying a contract be supported by new consideration to be binding. (True/False)
-
Intended beneficiaries have no legal rights under a contract. (True/False)
-
Stron Cellphones agrees to buy an unspecified quantity of microchips from SmartCorp. The quantity that a court would order Stron to buy under this contract is a. the amount that Stron would buy...
-
Lisa Goldstein reserved space for a wedding in a building owned by Orensanz Events, LLC, in New York City. The rental agreement provided that on cancellation of the event for any reason beyond...
-
No oral contract is enforceable under the UCC. (True/False)
-
Ennerdale Ltd has been asked to quote a price for a one a one-off contract. The company's management accountant has asked for your advice on the relevant costs for the contract. The following...
-
Why is homeostasis defined as the "relative constancy of the internal environments? Does negative feedback or positive feedback tend to promote homeostasis?
-
Holland at Home is considering introducing a variation of its current breakfast cereal, Zonnatura Regular Muesli Rich. The new cereal will be similar to the old with the exception that it will...
-
TSMC Corporation is considering selling one of its old wafer fabrication machines. The machine, purchased for \($3,000,000\) 5 years ago, had an expected life of 10 years and an expected salvage...
-
Assume that Fiskars Finland plans to invest in a new project that will annually generate revenues of \($2.3\) million. Cash expenses including both fixed and variable costs will be \($950,000,\) and...
Study smarter with the SolutionInn App