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.20E
Program Plan Intro
1. Create a function printListBackward such that when head is not null it calls the printListBackward recursively to print in reverse order
2. Create additemfunction to push a node to linked list. Note that this function
changes the head.
3. Create linked list using additemfunction 64->49->36->25
4. Call printListBackwardon the linked list
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Topic: Singly Linked ListImplement the following functions in C++ program. Read the question carefully. (See attached photo for reference)
void isEmpty()
This method will return true if the linked list is empty, otherwise return false.
void clear()
This method will empty your linked list. Effectively, this should and already has been called in your destructor (i.e., the ~LinkedList() method) so that it will deallocate the nodes created first before deallocating the linked list itself.
Topic: Singly Linked ListImplement the following functions in C++ program. Read the question carefully. (See attached photo for reference)
int count(int num)
This will return the count of the instances of the element num in the list. In the linked list in removeAll method, having the method count(10) will return 3 as there are three 10's in the linked list.
Additionally, you are to implement these methods:
bool move(int pos1, int pos2)
This method will move the element at position pos1 to the position specified as pos2 and will return true if the move is successful. This will return false if either the specified positions is invalid. In the example stated, operating the method move(1, 3) will move the 1st element and shall now become the 3rd element. The linked list shall now look like: 30 -> 40 -> 10 -> 50
int removeTail()
This method will remove the last element in your linked list and return the said element. If the list is empty, return 0. You can use the…
(Please Help. My professor did not teach us any of this and will not answer my emails)
Design a class named Queue for storing integers. Like a stack, a queue holds elements. In a stack, the elements are retreived in a last-in-first-out fashion. In a queue, the elements are retrieved in a first-in-first-out fashion. The class contains:
An int[] data field named elements that stores the int values in the queue
A data field named size that stores the number of elements in the queue
A constructor that creates a Queue object with defult capacity 8
The method enqueue(int v) that adds v into the queue
The method empty () that returns true if the queue is empty
The method getSize() that returns the size of the queue
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
- (Generic binary search) Implement the following method using binary search. public static <E extends Comparable<E>> int binarySearch(E[] list, E key) Note:- Please type this java code fully running and also need an output for this given code.arrow_forward(Circular linked lists) This chapter defined and identified various operations on a circular linked list.a. Write the definitions of the class circularLinkedList and its member functions. (You may assume that the elements of the circular linked list are in ascending order.)b. Write a program to test various operations of the class defined in (a).arrow_forward) Implement shell sort for a given sequence of increments. Display the outputlist at the end of each pass.arrow_forward
- Topic: Singly Linked ListImplement the following functions in C++ program. Read the question carefully. (See attached photo for reference) int removeAt(int pos) Removes the number in the posth position of the list and returns the element removed. Performing removeAt(3) in the example list will remove the 3rd element of the linked list and the updated list will be: 10 -> 30 -> 50 When the value of pos is greater than the size or less than one, return -1. int removeAll(int num) Removes all instances of num in the linked list and returns the number of instances removed. In this list 10 -> 10 -> 20 -> 30 -> 10, performing removeAll(10) will remove all three 10's and the list will look like this: 20 -> 30. Then, it will return the number of instances removed, in this case, 3. int contains(int num) This will return the position of the first instance of the element num in the list. If num is not found, return 0. In the example, having the method contains(30) will…arrow_forwardComplete using Standard C programming. Implement a singly linked list that performs the following: Displays the maximum value in the linked list using recursion. Displays the linked list in reverse order using recursion. Merge two single linked lists and display.arrow_forwardComplete question bcoding:-.arrow_forward
- (Implement a doubly linked list) The MyLinkedList class used in Listing 24.6 is a one-way directional linked list that enables one-way traversal of the list. Modify the Node class to add the new data field name previous to refer to the previous node in the list, as follows:public class Node<E> { E element; Node<E> next; Node<E> previous;public Node(E e) { element = e; } }Implement a new class named TwoWayLinkedList that uses a doubly linked list to store elements. The MyLinkedList class in the text extends MyAbstractList. Define TwoWayLinkedList to extend the java.util.AbstractSequentialList class. You need to implement all the methods defined in MyLinkedList as well as the methods listIterator() and listIterator(int index). Both return an instance of java.util. ListIterator<E>. The former sets the cursor to the head of the list and the latter to the element at the specified index.arrow_forward(Sort ArrayList) Write the following method that sorts an ArrayList: public static <E extends Comparable<E>> void sort(ArrayList<E> list) Write a test program that prompts the user to enter 10 integers, invokes this method to sort the numbers, and displays the numbers in increasing order. Sample Run Enter 10 integers: 3 4 12 7 3 4 5 6 4 7 The sorted numbers are 3 3 4 4 4 5 6 7 7 12 Class Name: Exercise19_09arrow_forward#python codecoud you provide comments and little explanation it would really help me to understandthankyouarrow_forward
- C++arrow_forwarda) Can you develop Java code.Create a recursive function to print all permutations of a string. For example, the permutation of the string "abc" is [abc, acb, bac, bca, cab, cba]. b) Revise the genericStack class to use an array instead of an ArrayList. Before adding a new element, make sure the array size is correct. If the current array is full, construct a new array twice the size, copy the elements, and add the new array. dont use aiarrow_forwardData structure and algorithms. DYNAMIC DATA STRUCTURE LINKED LIST. PURPOSE OF WORK : Consolidation of knowledge on the theoretical foundations of presentation of data in the form of links, classification of lists, learning to solve problems using the LIST standard template library in C++. Task : Write a program to process a linked list from the standard template library. Perform an individual task as a separate function. Implementation of automatic filling and display functions with random data in the program. The task is : The list is given. Create a function to calculate the arithmetic mean value of the elements of the list equal to the Fibonacci number.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 Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning