Java: An Introduction to Problem Solving and Programming (7th Edition)
7th Edition
ISBN: 9780133766264
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
What is Windows Server and what is the Differences between Windows Server 2019 and the Windows Operating System that people have installed on their personal computer.
solve and show the tree on paper
I need help to resolve the following activity
Chapter 12 Solutions
Java: An Introduction to Problem Solving and Programming (7th 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 - 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
- Modern life has been impacted immensely by computers. Computers have penetrated every aspect of oursociety, either for better or for worse. From supermarket scanners calculating our shopping transactionswhile keeping store inventory; robots that handle highly specialized tasks or even simple human tasks,computers do much more than just computing. But where did all this technology come from and whereis it heading? Does the future look promising or should we worry about computers taking over theworld? Or are they just a necessary evil? Provide three references with your answer.arrow_forwardWhat are the steps you will follow in order to check the database and fix any problems with it? Have in mind that you SHOULD normalize it as well. Describe in full, consider the following:• Taking the database offline is not allowed since people are connected to it.• Personal data might be bridged and not secured. Provide three refernces with you answerarrow_forwardYou are called by your supervisor to go and check a potential data bridge problem. What are the stepsyou will follow in order to check the database and fix any problems with it? Have in mind that youSHOULD normalize it as well. Describe in full, consider the following:• Taking the database offline is not allowed since people are connected to it.• Personal data might be bridged and not secured. Provide three refernces with you answerarrow_forward
- (A) A cellular system has 12 microcells with 10 channels per cell. The microcells are split into 3 microcells, and each microcell is further split into 4 picocells. Determine the number of channels available in system after splitting into picocelles.arrow_forwardQuestion 8 (10 points) Produce a relational schema diagram that corresponds to the following ER diagram for a Vacation Property Rentals database. Your relational schema diagram should include primary & foreign keys. Upload your relational schema diagram as a PDF document. Don't forget that the relation schemas for "Beach Property" and "Mountain Property" should each have primary keys. FYI: "d" in this notation denotes a subclass. Figure 2: ER Diagram for Question 8 id first RENTER name middle last address phone email 1 signs N id begin date RENTAL AGREEMENT end date amount N street address books city id 1 state address num. rooms PROPERTY zip code base rate type propertyType blocks to beach activity "B" "M" BEACH PROPERTY MOUNTAIN PROPERTYarrow_forwardNotes: 1) Answer All Question, 2) 25 points for each question QI Figurel shows the creation of the Frequency Reuse Pattern Using the Cluster Size K: (A) illustrates how i and j can be used to locate a co-channel cell. huster 3 Cluster Cluster 2 X=7(i=2,j1)arrow_forward
- You are called by your supervisor to go and check a potential data bridge problem. What are the stepsyou will follow in order to check the database and fix any problems with it? Have in mind that youSHOULD normalize it as well. Describe in full, consider the following taking the database offline is not allowed since people are connected to it and how personal data might be bridged and not secured.Provide three references with you answer.arrow_forwardYou are called by your supervisor to go and check a potential data bridge problem. What are the stepsyou will follow in order to check the database and fix any problems with it? Have in mind that youSHOULD normalize it as well. Describe in full, consider the following:• Taking the database offline is not allowed since people are connected to it.• Personal data might be bridged and not secured. Provide three refernces with you answerarrow_forwardYou are called by your supervisor to go and check a potential data bridge problem. What are the stepsyou will follow in order to check the database and fix any problems with it? Have in mind that youSHOULD normalize it as well. Describe in full, consider the following:• Taking the database offline is not allowed since people are connected to it.• Personal data might be bridged and not secured. Provide three refernces with you answer from websitesarrow_forward
- Modern life has been impacted immensely by computers. Computers have penetrated every aspect of oursociety, either for better or for worse. From supermarket scanners calculating our shopping transactionswhile keeping store inventory; robots that handle highly specialized tasks or even simple human tasks,computers do much more than just computing. But where did all this technology come from and whereis it heading? Does the future look promising or should we worry about computers taking over theworld? Or are they just a necessary evil? Provide three references with your answer.arrow_forwardObjective: 1. Implement a custom Vector class in C++ that manages dynamic memory efficiently. 2. Demonstrate an understanding of the Big Five by managing deep copies, move semantics, and resource cleanup. 3. Explore the performance trade-offs between heap and stack allocation. Task Description: Part 1: Custom Vector Implementation 1. Create a Vector class that manages a dynamically allocated array. 。 Member Variables: ° T✶ data; // Dynamically allocated array for storage. std::size_t size; // Number of elements currently in the vector. std::size_t capacity; // Maximum number of elements before reallocation is required. 2. Implement the following core member functions: Default Constructor: Initialize an empty vector with no allocated storage. 。 Destructor: Free any dynamically allocated memory. 。 Copy Constructor: Perform a deep copy of the data array. 。 Copy Assignment Operator: Free existing resources and perform a deep copy. Move Constructor: Transfer ownership of the data array…arrow_forward2.68♦♦ Write code for a function with the following prototype: * Mask with least signficant n bits set to 1 * Examples: n = 6 -> 0x3F, n = 17-> 0x1FFFF * Assume 1 <= n <= w int lower_one_mask (int n); Your function should follow the bit-level integer coding rules Be careful of the case n = W.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