C++ How to Program (10th Edition)
10th Edition
ISBN: 9780134448237
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 19, Problem 19.26E
Program Plan Intro
Program Plan:
This Program defines following structure to represent a List Node in Linked List
structlist_node {
int data;
structlist_node *next;
}node;
We have defined functions to add element at beginning and last of the list.
And to remove element from beginning and last.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
@6
The Reference-based Linked Lists: Select all of the following statements that are true.
options:
As a singly linked list's node references both its predecessor and its successor, it is easily possible to traverse such a list in both directions.
According to the terminology introduced in class, the head reference variable in a singly linked list object references the list's first node.
According to the terminology introduced in class, in a doubly linked list, each node references both the head and tail node.
In a double-ended singly linked list, the tail reference variable provides access to the entire list.
In a circular linked list, the last node references the first node.
C++
Consider the following function as a property of a LinkedBag that contains a Doubly Linked List.
Assume a Node has pointers prev and next, which can be read and changed with the standard get and set methods.
Assume that the doubly linked list is:
1 <--> 2 <--> 3 <--> 4 <--> 5 <-->6
If you are uncertain what the above diagram depicts, it is a doubly linked list such that:
The head of this doubly linked list is the node that contains the value 1.
The tail of this doubly linked list is the node that contains the value 6.
The 3rd node in this list contains the value 3.
The contents of this list are the values 1 through 6 in sequential order.
The following questions are regarding the linked list after after the test_function is run.
A. The head of the list after the test_function is run contains the value: B. The tail of the list after the test_function is run contains the value:
C. The 3rd node in the list after the test_function is run…
C++
Create a generic function add_bookends(ls, e) that adds a copy of element e to the front and back of list ls.
Chapter 19 Solutions
C++ How to Program (10th Edition)
Ch. 19 - Prob. 19.6ECh. 19 - Prob. 19.7ECh. 19 - Prob. 19.8ECh. 19 - Prob. 19.9ECh. 19 - Prob. 19.10ECh. 19 - Prob. 19.11ECh. 19 - (Infix-to-Post fix conversion) Stacks are used by...Ch. 19 - Prob. 19.13ECh. 19 - Prob. 19.14ECh. 19 - Prob. 19.15E
Ch. 19 - Prob. 19.16ECh. 19 - Prob. 19.17ECh. 19 - (Duplicate Elimination) In this chapter, we saw...Ch. 19 - Prob. 19.19ECh. 19 - Prob. 19.20ECh. 19 - Prob. 19.21ECh. 19 - Prob. 19.22ECh. 19 - Prob. 19.23ECh. 19 - Prob. 19.24ECh. 19 - Prob. 19.25ECh. 19 - Prob. 19.26ECh. 19 - Prob. 19.27ECh. 19 - Prob. 19.28E
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- SOB 22 – (Block 2)Write up what the properties of sets, lists, vectors and strings are and whether they are mutable or immutable. Then consider the class of problems that they are best for and use some code to illustrate your points. E.g., if you have a function that solves a problem using lists, then you can say why you can/can’t use vectors for it or sets etc.arrow_forwardFill in the blanks in the function below. listsum() takes a list of integers and the list’s length. listsum() gets the sum by adding the sum of the halves. Each half is recursively divided into two until it reaches the base case (a list containing a single element or an empty list). Trace and illustrate what happens.arrow_forwardCount word dominators def count_word_dominators(words): If you already solved the earlier count_dominators problem, you might notice that even though the problem was originally stated for lists of integers, the logic of domination did not depend on this fact in any way. As long as the individual elements can be compared with each other for order, the Pythonic spirit of duck typing allows the very same count_dominators function to handle a list of strings just as smoothly as it would handle a list of integers! For example, the function call count_dominators(['dog','emu','cat','bee']) would return 3, since 'emu', 'cat'and 'bee' dominate all words coming after them in the list when using the lexicographic order comparison. If your count_dominators function does not already pass this hurdle, try to rewrite it to contain no baked-in assumptions about elements being specifically integers. However, things become more interesting if we define domination between words of equal length with a…arrow_forward
- Using the following instruction below, write a header class for orderedLinkedList with a function of search,insert, insertFirst, insertLast and deleteNode. Use the library to write a c++ program to show an operation on an ordered linked list. - include the orderedLinkedList.h library in the codes - Create main function and include your information details - initialize a list1 and list2 as orderedLinkedList type - Declare a variable num as integer data type - Print out an instruction for user to input a numbers ending with -1 - Get a numbers from user input - Use a while loop to insert the numbers into list1 ending with -1 - Assign the list2 to list1 - Print out the current elements in List 1 and 2 - Get user input for the number to be deleted - Delete the number requested by user in list2 - Print out the elements in the list1 and list2 after delete operationarrow_forwardin c++ also please write comment to each line of the code explaining the code Suppose we have class named NumberList that holds a linked list of double values. In this section you will modify the class by adding recursive member functions. The functions will use recursion to traverse the linked list and perform the following operations: Count the number of nodes in the list. To count the number of nodes in the list by recursion, we introduce two new member functions: numNodes and countNodes. countNodes is a private member function that uses recursion, and numNodes is the public interface that calls it. Display the value of the list nodes in reverse order. To display the nodes in the list in reverse order, we introduce two new member functions: displayBackwards and showReverse. showReverse is a private member function that uses recursion, and displayBackwards is the public interface that calls it.arrow_forwardWhat is the difference between a singly-linked list and a doubly-linked list? In what situation would you use a singly-linked list over a doubly-linked list? In what situation would you use a doubly-linked list over a singly-linked list?arrow_forward
- Define the function (doubleBubbleLst lst). This function should resolve to a list of sublists, where each sublist holds a single element from lst and all sublists from lst are also bubbled, so that every list and sublist has no atoms. This is the deep recursion version of bubbleLst. For example: (doubleBubbleLst '(1 2 (3 4)) ) resolves to '((1) (2) (( (3) (4) ))).arrow_forwardUsing the following instruction below, write a header class for unorderedLinkedList with a function of search, insertFirst, insertLast and deleteNode. Use the library to write a program to show an operation on an unordered linked list. write in C++ program. - Include the unorderedLinkedList.h library in the codes - Initialize a list1 and list2 as unorderedLinkedList type - Declare a variable num as integer data type - Print out an instruction for user to input a numbers ending with -99 - Get a numbers from user input - Use a while loop to insert the numbers into list1 ending with -99 - Print out the current elements in List 1 - Assign list 2 to list 1 - Print out the elements in list 2 - Print the length of list 2 - Get user input for the number to be deleted - Delete the number requested by user in list2 - Print out the elements in the list after delete operation - Print the length of list 2 - Declare the intIt variable to be linked list iterator - Print out the elements in List 1…arrow_forwardTitle: Using Comparable in Singly Linked List I'm writing a singly linked list that can insert, remove, search, and count. When I try to implement generic so that the list can accept different types, the instruction requires the use of Comparable. How is Comparable used in this case (since I'm not sorting anything), and what exactly am I comparing? Do I need to "implements Comparable" or "extends Comparable"?arrow_forward
- write a c++ code that will do the adding a node to a doubly-linked list in the three cases (insert a node at the beginning-middle-end). A separate function is required for each case.arrow_forwardCan you please help me with these three questions? 1) A designator used to give a non-member function in C++ access to the private data members of a class, even though the function is not technically part of the class, is called ______ 2) The stack operation that is required when using an array implementation, but is not required when using a linked list implementation, is ___ . isFull() push() pop() peek() 3) A mechanism in C++ that interrupts program execution when errors occur and signals the rest of the program that something unexpected has happened is a(n) ___ . exception logic error catch phrase interceptionarrow_forwardin C++ Suppose we have class named NumberList that holds a linked list of double values. In this section you will modify the class by adding recursive member functions. The functions will use recursion to traverse the linked list and perform the following operations:• Count the number of nodes in the list.To count the number of nodes in the list by recursion, we introduce two new member functions: numNodes and countNodes. countNodes is a private member function that uses recursion, and numNodes is the public interface that calls it.• Display the value of the list nodes in reverse order.To display the nodes in the list in reverse order, we introduce two new member functions: displayBackwards and showReverse. showReverse is a private member function that uses recursion, and displayBackwards is the public interface that calls it.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- 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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education