Suppose your program contains type definitions and pointer variable declarations as in Self-Test Exercise 7. Suppose further that p2 points to a node of type Node that is on a linked list and is not the last node on the list. Write code that will delete the node after the node pointed to by P2. After this code is executed, the linked list should be the same, except that there will be one less node on the linked list. (Hint: You might want to declare another pointer variable to use.)
Want to see the full answer?
Check out a sample textbook solutionChapter 13 Solutions
Problem Solving with C++ (9th Edition)
Additional Engineering Textbook Solutions
Starting Out with C++ from Control Structures to Objects (8th Edition)
Starting Out with C++ from Control Structures to Objects (9th Edition)
Starting Out with C++: Early Objects (9th Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Starting Out With Visual Basic (8th Edition)
- in C++ Write a method ‘void addBack(double x)’ that adds value x to the back of a linked list. Assume you have access to a ‘head’ pointer pointing to the first node in the list. Please note that you do NOT have a tail pointer. Be sure to check for any special cases.arrow_forwardin C++ kth ElementExtend the class linkedListType by adding the following operations:a. Write a function that returns the info of the kth element of the linked list. If no such element exists, terminate the program.b. Write a function that deletes the kth element of the linked list. If no such element exists, terminate the program. Provide the definitions of these functions in the class linkedListType. please, do not copy from any other sources, give me a fresh new code. Thank youarrow_forwardYou may do this assignment using either Java or C++. Do *not use the JDK LinkedList class or any linked list library! A linked list consists of zero or more nodes, which each contain one item of data and a link (Java reference, C++ pointer or reference) to the next node, if there is one. Linked List code is usually generic, so that you can use it to create a list of Strings, Students, Doubles, etc. For this assignment, you will write a simplified version of linked list that only can be used to create and use a list of ints and that has only a few of the functions typical of linked lists. The data element can be just an int, and the data type of the link to the next node can be just Node. You will need a reference (Java) or either a reference or a pointer (C++) to the first node, as well as one to the last node. Write a method/function that takes an in, creates a node with that int as its data value, and adds the node to the end of the list. This function will need to update the…arrow_forward
- in c++ : The function insert of the class orderedLinkedList does not check if the item to be inserted is already in the list; that is, it does not check for duplicates. Rewrite the definition of the function insert so that before inserting the item it checks whether the item to be inserted is already in the list. If the item to be inserted is already in the list, the function outputs an appropriate error message. Also write a program to test your function (in the driver file).arrow_forwardUse C++arrow_forwardComputer Science In c++ (There should be three different files, "main.cpp", "sourcefile.cpp" and "header.cpp" your solution must have those three different files): Write a function that checks if the nodes in a linked list is sorted in ascending order. The function should return true if the values are sorted, otherwise false. Take user input. Call the funciton in the main function to show it is working.arrow_forward
- A dummy-headed circular singly-linked list has been created and holds a list of integer temperatures. (Remember, the first node is the dummy node and holds no payload.) Write a C++ function, "NothingOdd(list)", that accepts a single argument that is a pointer to the dummy node of the linked list and removes and deallocates all nodes in the list with odd (i.e., not even) temperature values. The relevant type struct xNode { int xNode* next; }; // Temperature (in Celsius) // Pointer to successor node temp; declarations are:arrow_forwardplease use python languagearrow_forwardAll the problems are to be coded in Python/Java. You must explicitly solve each problem below using your own logic. For example, Do not use existing library functions, such as sum( ), which computes the sum of a list. Instead, you must use for/while loop to sum up the items in a list. a. Write code for a CharList class which converts a string to a linked list of characters in the string. * b. Add a class member function which outputs if the linked list in Problem a. is a palindrome. What is the Big-O upper bound? c. What change could be made to the class definition in Problem a. to make your solution in Problem b. more efficient? Explain. What is the Big-O upper bound? Hint: Think of how the palindrome determination problem is solved for a regular string. d. Add a method to the classic List class we discussed in class that reverses the list. That is, if the original list is A -> B ->C, all of the list's links should change so that C-> B-> A. Make your solution as efficient as possible.…arrow_forward
- QUESTION: NOTE: This assignment is needed to be done in OOP(c++/java), the assignment is a part of course named data structures and algorithm. A singly linked circular list is a linked list where the last node in the list points to the first node in the list. A circular list does not contain NULL pointers. A good example of an application where circular linked list should be used is a items in the shopping cart In online shopping cart, the system must maintain a list of items and must calculate total bill by adding amount of all the items in the cart, Implement the above scenario using Circular Link List. Do Following: First create a class Item having id, name, price and quantity provide appropriate methods and then Create Cart/List class which holds an items object to represent total items in cart and next pointer Implement the method to add items in the array, remove an item and display all items. Now in the main do the following Insert Items in list Display all items. Traverse…arrow_forwardDo the whole code in C++ and please share the whole program.arrow_forwardPlease use C++, send screenshot of code running. Because this is the 2nd time I upload this photo, last answer I got, the code wasn’t compiled and run.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education