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++ (10th 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)
- Please write a full C++ code 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 Also please allow the code to be copied. Don't just provide a screenshotarrow_forwardin 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_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
- Can you help with with the following questions, regarding population genetics and the Wright Fisher model in python? 1. Go through the given WFtrajectory function and give a short explanation of what each line of code does. Pay attention to the variables in the function and explain what they contain. 2. Make a new version of the WFtrajectory function which does exactly the same thing except that instead of appending to a list it initialises a numpy vector with zeroes and fills the vector with a for loop instead of a while loop. Make a plot of the output from a few example trajectories.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_forwardA 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_forward
- please use python languagearrow_forwardAdd the following functions and write a program to test these functions in the class linkedListType: a. Write the definition of a function that returns the data of the kth element of the linked list. If such element is not exist in the list, exit the program. b. Write the definition of a function that deletes the kth element of the linked list. If such element is not exist in the list, exit the program and display message as output. (Subject:Data stracture and algorithm )arrow_forwardin c++, use parallel arrays , and srand(time(NULL)) to randomize the two cards dealt at the start Create a Blackjack (21) game. Your version of the game will imagine only a SINGLE suit of cards, so 13 unique cards, {2,3,4,5,6,7,8,9,10,J,Q,K,A}. Upon starting, you will be given two cards from the set, non-repeating. Your program MUST then tell you the odds of receiving a beneficial card (that would put your value at 21 or less), and the odds of receiving a detrimental card (that would put your value over 21). Recall that the J, Q, and K cards are worth ‘10’ points, the A card can be worth either ‘1’ or ‘11’ points, and the other cards are worth their numerical values.arrow_forward
- 3. Write a class for the city database using unordered lists. Each database record contains the name of the city (a string of arbitrary length) and the coordinates of the city expressed as integer x and y coordinates. Your database should allow records to be inserted, deleted by name, and searched by name or coordinate. Implement the database using an array-based list. Develop a simple test (as the main function) Run your program and present the results of the test.arrow_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_forwardQUESTION: 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_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