If we have a Linked List L (20; 30; 40). Using the Linked List specifications from...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
If we have a Linked List L (20; 30; 40). Using the Linked List specifications from the slides, how can we insert 10 at the start of the list? L. findFirst (); Integer temp = L. retrieve (); O L.insert (new Integer (10)); L. update (temp); L.findFirst (); L.insert (new Integer (10)); L. findFirst (); L.insert (L.retrieve ()); L. update (new Integer (10)); L. findFirst (); Integer temp = L. retrieve (); O L. update (new Integer (10)); L.insert (temp); QUESTION 2 What is the output of the following code LinkedList<Integer> A = new LinkedList<Integer> (); A.insert (new Integer (100)); A.insert (new Integer (66)); A.insert (new Integer (13)); A.insert (new Integer (15)); A.findfirst(); 13, A.insert (new Integer (34)); A.insert (new Integer (56)); A. findnext(); A.insert (new Integer (24)); while (!A.last ()) { System.out.print (A.retrieve () + " A. findnext(); } 24, 13, 15, 100, 66, 13, 15, 34, 56, 24, O 24, 13, 100, 34, 56, 66, 24, 13, 15, QUESTION 3 As a User of the ADT List, the following method was written for the purpose of removing all the elements of a non-empty List. public static <T> void removeAll (List<T> 1) { 1.findfirst(); while (!l.last ()) 1.remove(); How good will it do? It will not delete the last element It will not work; the parameter should be List<Integer> instead of List<T> It will cause a runtime error It will not delete the first element O It will work properly and delete all elements QUESTION 4 What will this code do? A.findfirst (); while (! A.last()) { A. findnext(); A.insert (A.retrieve()) } It will duplicate 2nd 4th, 6th,...etc. elements findNext() will skip odd elements It will duplicate all the List elements It will duplicate all elements except for the last It will duplicate all elements except for the 1st and last The code will duplicate all elements except first one If we have a Linked List L (20; 30; 40). Using the Linked List specifications from the slides, how can we insert 10 at the start of the list? L. findFirst (); Integer temp = L. retrieve (); O L.insert (new Integer (10)); L. update (temp); L.findFirst (); L.insert (new Integer (10)); L. findFirst (); L.insert (L.retrieve ()); L. update (new Integer (10)); L. findFirst (); Integer temp = L. retrieve (); O L. update (new Integer (10)); L.insert (temp); QUESTION 2 What is the output of the following code LinkedList<Integer> A = new LinkedList<Integer> (); A.insert (new Integer (100)); A.insert (new Integer (66)); A.insert (new Integer (13)); A.insert (new Integer (15)); A.findfirst(); 13, A.insert (new Integer (34)); A.insert (new Integer (56)); A. findnext(); A.insert (new Integer (24)); while (!A.last ()) { System.out.print (A.retrieve () + " A. findnext(); } 24, 13, 15, 100, 66, 13, 15, 34, 56, 24, O 24, 13, 100, 34, 56, 66, 24, 13, 15, QUESTION 3 As a User of the ADT List, the following method was written for the purpose of removing all the elements of a non-empty List. public static <T> void removeAll (List<T> 1) { 1.findfirst(); while (!l.last ()) 1.remove(); How good will it do? It will not delete the last element It will not work; the parameter should be List<Integer> instead of List<T> It will cause a runtime error It will not delete the first element O It will work properly and delete all elements QUESTION 4 What will this code do? A.findfirst (); while (! A.last()) { A. findnext(); A.insert (A.retrieve()) } It will duplicate 2nd 4th, 6th,...etc. elements findNext() will skip odd elements It will duplicate all the List elements It will duplicate all elements except for the last It will duplicate all elements except for the 1st and last The code will duplicate all elements except first one
Expert Answer:
Answer rating: 100% (QA)
The detailed answer for the above question is provided below Question 1 Option 2 is used t... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Based on the example linked list code, extend that code to implement the following functions. You will have to update the linkedList.h file and the linkedList.c file. [2 marks each] int...
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-5. Ivan's grandfather died and left a portfolio of municipal bonds. In 2012, they pay Ivan...
-
A student adds NBS to a solution of 1-methylcyclohexene and irradiates the mixture with a sunlamp until all the NBS has reacted. After a careful distillation, the product mixture contains two major...
-
Identify three internal controls designed to safeguard payroll cash.
-
Which of the following is a charitable lead trust? a. The income of the trust fund goes to an individual until death, at which time the principal is conveyed to a charitable organization. b....
-
The Howell Corporation has the following account balances (in millions): Prepare an income statement and a supporting schedule of cost of goods manufactured for the year ended December 31, 2017. (For...
-
For 2012, Eurie Company reported its most significant decline in net income in year. At the end of the year, H. Finn, the president, is presented with the following condensed comparative income...
-
What sql commands are used in RDBMS? What are the 5 basic SQL queries?
-
A hollow circular post ABC (see figure) supports a load P1 = 1700 lb acting at the top. A second load P2 is uniformly distributed around the cap plate at B. The diameters and thicknesses of the upper...
-
The equations of a line are 5x 3 = 15y + 7 = 3 10z. Write the direction cosines of the line.
-
Discuss the use of different mediums in the gallery, such as paintings, sculptures, and mixed-media pieces. How did the choice of medium influence your interpretation of the artwork? Compare and...
-
How will knowledge about health care providers allow you to properly bill and code common gastrointestinal diseases? Provide details and support your responses with examples.
-
1. Discuss and describe the three-step portfolio management process with special emphasis on the investor's objectives and constraints. 2. Discuss how the concept of limits to arbitrage hinders...
-
how HIPAA might adversely influence project communication. How might your own communication bias influence project communication?
-
Prepare financial ratios in evaluating Islamic bank's performance by using Profitability Ratio only. Company No. 719057-X STATEMENTS OF FINANCIAL POSITION AS AT 31 DECEMBER 2019 ASSETS Group Bank...
-
Select a system (or major element) of your choice and complete a functional analysis covering the activities in the retirement phase of the life cycle.
-
Choose two matrices A and B with dimension 2 x 2. Calculate det A, det B, and det (AB). Repeat this process until you are able to discover how these three determinants are related. Summarize your...
-
John Williams (age 42) is a single taxpayer, and he lives at 1324 Forest Dr., Reno, NV 89501. His Social Security number is 555-94-9358. John's earnings and withholdings as the manager of a local...
-
Indicate, in each of the following situations, the number of exemptions the taxpayers are entitled to claim on their 2012 income tax returns. Number of Exemptions a. Donna, a 20-year-old single...
-
Karim Depak received a Form 1099-B showing the following stock transactions and basis during 2012: None of the stock is qualified small business stock. Calculate Karim's net capital gain or loss...
-
A dump truck, whose bed is made of steel, holds an old steel watering trough. The bed of the truck is slowly raised until the trough begins to slide. What is the acceleration of the trough as it...
-
A vendor at the local art fair ties her tent to the concrete-filled coffee can shown in Figure P5.34. A stiff breeze comes up and the string becomes taut. What is the maximum value that the string...
-
The acceleration of the spacecraft in which the Apollo astronauts took off from the moon was 3.4 m/s 2 . On the moon, g = 1.6 m/s 2 .What was the apparent weight of a 75 kg astronaut during takeoff?
Study smarter with the SolutionInn App