Java: An Introduction to Problem Solving and Programming (8th Edition)
8th Edition
ISBN: 9780134462035
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 12, Problem 9PP
Program Plan Intro
Doubly linked list
Program Plan:
“DoublyLinkedList.java”:
- Define “DoublyLinkedList” class.
- Declare required variables.
- Default constructor for “DoublyLinkedList” class.
- Define the method “length”.
- Declare required variable.
- Check condition using “while” loop.
- Return the result of count value
- Define “addANodeToStart” method.
- Declare variable by using “ListNode” class.
- Assign value to head.
- If tail is null, then assign tail to head.
- If old head is not null, then set the values to link value at head and previous value at old head node.
- Define “getDataAtCurrent” method.
- If current is not null, then returns the data at current.
- Otherwise, display the given error message.
- Finally returns the null value.
- Define “resetIteration” method.
- This method is used to set current to head.
- Define “moreToIterate” method.
- This method is used to return the result of “current != null”.
- Define “goToNext” method.
- If current is not null, then set current value to link value at current.
- If head is not null, then display given message.
- Define “goToPrevious” method.
- If current is not null, then set current to previous value at current.
- If head is not null, then display given error statement.
- Define “insertNodeAfterCurrent” method.
- Declare required variables.
- If tail is equal to current, then set tail to new node.
- If current is not null, then set given values to given variables.
- If the link value at new node is not null, then set the value to new node.
- If the value of head is not null, then display given error message.
- If the link value at new node is not null, then set the value to new node.
- Define “deleteCurrentNode” method.
- Declare variable using “ListNode” class.
- If tail is equal to current and current is not null, then set tail to previous value at current node.
- If current and previous value at current node is not null, then set values for given variables.
- If current is not null and previous value at current node is null, then set values for head node.
- Otherwise, that is if current is equal to null, then display error message.
- Define “deleteHeadNode” method.
- If tail is equal to head, then set tail to null.
- If head is not null, then assign values for head.
- Otherwise, display error message.
- Define “findInList” method.
- Declare required variables.
- Check condition using “while” loop.
- Get the data position by calling the method “getData” and then store it to a variable “data_position”.
- If the position of data is equals to target node, then set “current” to “location” and then return true.
- Then get the location by calling the method “getLink”.
- Finally assign the “current” to “null” and return “false”.
- Define “onList” method.
- This method returns the result of “Find(target_node) != null”.
- Define “Find” method.
- Declare required variables.
- Check condition using “while” loop.
- Define “showList” method.
- Declare required variables.
- Display the data at each location using “while” loop.
- Define “displayListValues” method.
- This method is used to return the values in head, current, tail and number of items in list.
- Define node class “ListNode”.
- Declare required variables
- Define constructor for “ListNode” class.
- Define parameterized constructor for “ListNode” class.
- Define set and get method for data and link.
“DoublyLinkedListTest.java”:
- Define “DoublyLinkedListTest” class.
- Define main function.
- Assign result to “false”.
- Create an object for “DoublyLinkedList” class.
- Display the values in list by calling the method “displayListValues”.
- Add a name “John” to “nameList” by calling the method “addANodeToStart”.
- After adding, display the values in list by calling the method “displayListValues”.
- Reset the iteration for given list by calling the method “resetIteration”.
- Add a name “Merry” to “nameList” by calling the method “addANodeToStart”.
- After adding, display the values in list by calling the method “displayListValues”.
- Go to next node by calling the method “goToNext”.
- Add a name “Rose” to “nameList” by calling the method “addANodeToStart”.
- After adding, display the values in list by calling the method “displayListValues”.
- Display the list by calling “showList” method.
- Reset the iteration for given list by calling the method “resetIteration”.
- Go to next node by calling the method “goToNext”.
- After adding, display the values in list by calling the method “displayListValues”.
- Add a name “Jansi” to “nameList” by calling the method “addANodeToStart”.
- After adding, display the values in list by calling the method “displayListValues”.
- Display the list by calling “showList” method.
- Go to next node by calling the method “goToNext”.
- Delete first node by calling “deleteHeadNode” method.
- After deleting, display the list by calling “showList” method.
- Go to next node by calling the method “goToNext”.
- Add a name “Rosie” to “nameList” by calling the method “addANodeToStart”.
- Go to next node by calling the method “goToNext”.
- Add a name “Joshph” to “nameList” by calling the method “addANodeToStart”.
- After adding, display the values in list by calling the method “displayListValues”.
- Display the list by calling “showList” method.
- Go to previous node by calling the method “goToPrevious”.
- Display the values in list by calling the method “displayListValues”.
- Display the list by calling “showList” method.
- Go to previous node by calling the method “goToPrevious”.
- Get the current node by calling the method “getDataAtCurrent”.
- Delete node at current by calling the method “deleteCurrentNode”.
- After deleting, display the values in list by calling the method “displayListValues” and method “showList”.
- Add a name “Jack” to beginning of “nameList” by calling the method “addANodeToStart”.
- After deleting, display the values in list by calling the method “displayListValues” and method “showList”.
- Iterate to the end of list using “while” loop. After iterating, display the values in list by calling the method “displayListValues”.
- Iterate the list in reverse by calling “resetIterationReverse” method.
- After reverse iteration, display the values in list by calling the method “displayListValues”.
- Delete the current node by calling “deleteCurrentNode” method.
- After deleting current node, display the values in list by calling the method “displayListValues” and method “showList”.
- Check if “Rose” is found in list or not by calling “findInList” method. If the given name found, then display the message “Found”. Otherwise, display “Not found”.
- After performing check condition, display the values in list by calling the method “displayListValues” and method “showList”.
- Check if “Josph” is found in list or not by calling “findInList” method. If the given name found, then display the message “Found”. Otherwise, display “Not found”.
- After performing check condition, display the values in list by calling the method “displayListValues” and method “showList”.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
We want to get an idea of how many tickets we have and what our issues are. Print the ticket ID number, ticket description, ticket priority, ticket status, and, if the information is available, employee first name assigned to it for our records. Include all tickets regardless of whether they have been assigned to an employee or not. Sort it alphabetically by ticket status, and then numerically by ticket ID, with the lower ticket IDs on top.
Figure 1 shows an ASM chart representing the operation of a controller. Stateassignments for each state are indicated in square brackets for [Q1, Q0].Using the ASM design technique:(a) Produce a State Transition Table from the ASM Chart in Figure 1.(b) Extract minimised Boolean expressions from your state transition tablefor Q1, Q0, DISPATCH and REJECT. Show all your working.(c) Implement your design using AND/OR/NOT logic gates and risingedgetriggered D-type Flip Flops. Your answer should include a circuitschematic.
A controller is required for a home security alarm, providing the followingfunctionality. The alarm does nothing while it is disarmed (‘switched off’). It canbe armed (‘switched on’) by entering a PIN on the keypad. Whenever thealarm is armed, it can be disarmed by entering the PIN on the keypad.If motion is detected while the alarm is armed, the siren should sound AND asingle SMS message sent to the police to notify them. Further motion shouldnot result in more messages being sent. If the siren is sounding, it can only bedisarmed by entering the PIN on the keypad. Once the alarm is disarmed, asingle SMS should be sent to the police to notify them.Two (active-high) input signals are provided to the controller:MOTION: Asserted while motion is detected inside the home.PIN: Asserted for a single clock cycle whenever the PIN has beencorrectly entered on the keypad.The controller must provide two (active-high) outputs:SIREN: The siren sounds while this output is asserted.POLICE: One SMS…
Chapter 12 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Ch. 12.1 - Suppose aList is an object of the class...Ch. 12.1 - Prob. 2STQCh. 12.1 - Prob. 3STQCh. 12.1 - Prob. 4STQCh. 12.1 - Can you use the method add to insert an element at...Ch. 12.1 - Prob. 6STQCh. 12.1 - Prob. 7STQCh. 12.1 - If you create a list using the statement...Ch. 12.1 - Prob. 9STQCh. 12.1 - Prob. 11STQ
Ch. 12.1 - Prob. 12STQCh. 12.2 - Prob. 13STQCh. 12.2 - Prob. 14STQCh. 12.2 - Prob. 15STQCh. 12.2 - Prob. 16STQCh. 12.3 - Prob. 17STQCh. 12.3 - Prob. 18STQCh. 12.3 - Prob. 19STQCh. 12.3 - Write a definition of a method isEmpty for the...Ch. 12.3 - Prob. 21STQCh. 12.3 - Prob. 22STQCh. 12.3 - Prob. 23STQCh. 12.3 - Prob. 24STQCh. 12.3 - Redefine the method getDataAtCurrent in...Ch. 12.3 - Repeat Question 25 for the method...Ch. 12.3 - Repeat Question 25 for the method...Ch. 12.3 - Repeat Question 25 for the method...Ch. 12.4 - Revise the definition of the class ListNode in...Ch. 12.4 - Prob. 30STQCh. 12.5 - What is the purpose of the FXML file?Ch. 12.5 - Prob. 32STQCh. 12 - Repeat Exercise 2 in Chapter 7, but use an...Ch. 12 - Prob. 2ECh. 12 - Prob. 3ECh. 12 - Repeat Exercises 6 and 7 in Chapter 7, but use an...Ch. 12 - Write a static method removeDuplicates...Ch. 12 - Write a static method...Ch. 12 - Write a program that will read sentences from a...Ch. 12 - Repeat Exercise 12 in Chapter 7, but use an...Ch. 12 - Write a program that will read a text file that...Ch. 12 - Revise the class StringLinkedList in Listing 12.5...Ch. 12 - Prob. 12ECh. 12 - Write some code that will use an iterator to...Ch. 12 - Prob. 14ECh. 12 - Write some code that will use an iterator to...Ch. 12 - Prob. 17ECh. 12 - Revise the method selectionSort within the class...Ch. 12 - Repeat the previous practice program, but instead...Ch. 12 - Repeat Practice Program 1, but instead write a...Ch. 12 - Write a program that allows the user to enter an...Ch. 12 - Write a program that uses a HashMap to compute a...Ch. 12 - Write a program that creates Pet objects from data...Ch. 12 - Repeat the previous programming project, but sort...Ch. 12 - Repeat the previous programming project, but read...Ch. 12 - Prob. 9PPCh. 12 - Prob. 10PPCh. 12 - Prob. 11PPCh. 12 - Prob. 12PPCh. 12 - Prob. 13PPCh. 12 - Prob. 14PPCh. 12 - Prob. 15PP
Knowledge Booster
Similar questions
- 4G+ Vo) % 1.1. LTE1 : Q B NIS شوز طبي ۱:۱۷ کا A X حاز هذا على إعجاب Mohamed Bashar. MEDICAL SHOE شوز طبي ممول . اقوى عرض بالعراق بلاش سعر القطعة ١٥ الف سعر القطعتين ٢٥ الف سعر 3 قطع ٣٥ الف القياسات : 40-41-42-43-44- افحص وكدر ثم ادفع خدمة التوصيل 5 الف لكافة محافظات العراق ופרסם BNI SH ופרסם DON JU WORLD DON JU MORISO DON JU إرسال رسالة III Messenger التواصل مع شوز طبي تعليق باسم اواب حمیدarrow_forwardA manipulator is identified by the following table of parameters and variables:a. Obtain the transformation matrices between adjacent coordinate frames and calculate the global transformation matrix.arrow_forwardWhich tool takes the 2 provided input datasets and produces the following output dataset? Input 1: Record First Last Output: 1 Enzo Cordova Record 2 Maggie Freelund Input 2: Record Frist Last MI ? First 1 Enzo Last MI Cordova [Null] 2 Maggie Freelund [Null] 3 Jason Wayans T. 4 Ruby Landry [Null] 1 Jason Wayans T. 5 Devonn Unger [Null] 2 Ruby Landry [Null] 6 Bradley Freelund [Null] 3 Devonn Unger [Null] 4 Bradley Freelund [Null] OA. Append Fields O B. Union OC. Join OD. Find Replace Clear selectionarrow_forward
- What are the similarities and differences between massively parallel processing systems and grid computing. with referencesarrow_forwardModular Program Structure. Analysis of Structured Programming Examples. Ways to Reduce Coupling. Based on the given problem, create an algorithm and a block diagram, and write the program code: Function: y=xsinx Interval: [0,π] Requirements: Create a graph of the function. Show the coordinates (x and y). Choose your own scale and show it in the block diagram. Create a block diagram based on the algorithm. Write the program code in Python. Requirements: Each step in the block diagram must be clearly shown. The graph of the function must be drawn and saved (in PNG format). Write the code in a modular way (functions and the main part should be separate). Please explain and describe the results in detail.arrow_forwardBased on the given problem, create an algorithm and a block diagram, and write the program code: Function: y=xsinx Interval: [0,π] Requirements: Create a graph of the function. Show the coordinates (x and y). Choose your own scale and show it in the block diagram. Create a block diagram based on the algorithm. Write the program code in Python. Requirements: Each step in the block diagram must be clearly shown. The graph of the function must be drawn and saved (in PNG format). Write the code in a modular way (functions and the main part should be separate). Please explain and describe the results in detail.arrow_forward
- Based on the given problem, create an algorithm and a block diagram, and write the program code: Function: y=xsinx Interval: [0,π] Requirements: Create a graph of the function. Show the coordinates (x and y). Choose your own scale and show it in the block diagram. Create a block diagram based on the algorithm. Write the program code in Python. Requirements: Each step in the block diagram must be clearly shown. The graph of the function must be drawn and saved (in PNG format). Write the code in a modular way (functions and the main part should be separate). Please explain and describe the results in detail.arrow_forwardQuestion: Based on the given problem, create an algorithm and a block diagram, and write the program code: Function: y=xsinx Interval: [0,π] Requirements: Create a graph of the function. Show the coordinates (x and y). Choose your own scale and show it in the block diagram. Create a block diagram based on the algorithm. Write the program code in Python. Requirements: Each step in the block diagram must be clearly shown. The graph of the function must be drawn and saved (in PNG format). Write the code in a modular way (functions and the main part should be separate). Please explain and describe the results in detail.arrow_forward23:12 Chegg content://org.teleg + 5G 5G 80% New question A feed of 60 mol% methanol in water at 1 atm is to be separated by dislation into a liquid distilate containing 98 mol% methanol and a bottom containing 96 mol% water. Enthalpy and equilibrium data for the mixture at 1 atm are given in Table Q2 below. Ask an expert (a) Devise a procedure, using the enthalpy-concentration diagram, to determine the minimum number of equilibrium trays for the condition of total reflux and the required separation. Show individual equilibrium trays using the the lines. Comment on why the value is Independent of the food condition. Recent My stuff Mol% MeOH, Saturated vapour Table Q2 Methanol-water vapour liquid equilibrium and enthalpy data for 1 atm Enthalpy above C˚C Equilibrium dala Mol% MeOH in Saturated liquid TC kJ mol T. "Chk kot) Liquid T, "C 0.0 100.0 48.195 100.0 7.536 0.0 0.0 100.0 5.0 90.9 47,730 928 7,141 2.0 13.4 96.4 Perks 10.0 97.7 47,311 87.7 8,862 4.0 23.0 93.5 16.0 96.2 46,892 84.4…arrow_forward
- You are working with a database table that contains customer data. The table includes columns about customer location such as city, state, and country. You want to retrieve the first 3 letters of each country name. You decide to use the SUBSTR function to retrieve the first 3 letters of each country name, and use the AS command to store the result in a new column called new_country. You write the SQL query below. Add a statement to your SQL query that will retrieve the first 3 letters of each country name and store the result in a new column as new_country.arrow_forwardWe are considering the RSA encryption scheme. The involved numbers are small, so the communication is insecure. Alice's public key (n,public_key) is (247,7). A code breaker manages to factories 247 = 13 x 19 Determine Alice's secret key. To solve the problem, you need not use the extended Euclid algorithm, but you may assume that her private key is one of the following numbers 31,35,55,59,77,89.arrow_forwardConsider the following Turing Machine (TM). Does the TM halt if it begins on the empty tape? If it halts, after how many steps? Does the TM halt if it begins on a tape that contains a single letter A followed by blanks? Justify your answer.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
- New Perspectives on HTML5, CSS3, and JavaScriptComputer ScienceISBN:9781305503922Author:Patrick M. CareyPublisher:Cengage LearningNp Ms Office 365/Excel 2016 I NtermedComputer ScienceISBN:9781337508841Author:CareyPublisher:CengageProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Cengage Learning
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:9781337508841
Author:Carey
Publisher:Cengage
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage