Question

You will need those four files: d_node.h, d_nodel.h, d_random.h, and prg9_1.cpp Program Definition 1. Create program...

You will need those four files: d_node.hPreview the documentView in a new window, d_nodel.hPreview the documentView in a new window, d_random.hPreview the documentView in a new window, and prg9_1.cppPreview the documentView in a new window

Program Definition

1. Create program definition with the following templates and methods:

// returns the sum of all elements in a single linked list
template <typename T>
int sum(node<T> *front);

// outputs the nodes of a single linked list in reverse order.
template <typename T>
void outputReverse(node<T> *front);

Main Method: add before the "cout << "\nOutput in Descending Order: ";" line

call sum() to print sum of all elements in the linked list.

call outputReverse() to display the elements in reverse order.

Include: system("PAUSE"); after the last output in main to pause the screen if needed.

int sum(node<T> *front)

return the sum of all elements in a single linked list

0 should be returned if front is NULL

void outputReverse(node<T> *front)

create a new linked list with its elements in reverse order as the original list pointed by front. For example, if the original list is 4 15 8 2, this new linked list should be 2 8 15 4.

call method writeLinkedList to display this new linked list with separator "<-". writeLinkedList is defined in the given header file d_nodel.h

delete this new linked list and its nodes. Be sure to delete each node properly and that there is no memory leak.

You should not modify the original list pointed by front.

You're not allowed to use any STL classes or other libraries (i.e. no additional #include).

Up to 60% credit may be deducted if you violate item 4 and 5 listed above.

See example below.

Ensure you include ALL files required to make your program compile and run. I would like to see your .cpp file and the .exe file that is inside your debug directory.

Submit your page.

NOTE: Complete your activity and submit it by clicking on the Submit Assignment link at the top right of this screen.

Total Possible Points

Example output of your program (yellow highlights are from the functions we add into the given program)

Enter the size of the list: 9
Original List of Values: 60 93 35 68 75 45 65 83 53
Sum of all elements are: 577
The list reversed is: 53<-83<-65<-45<-75<-68<-35<-93<-60<-
Output in Descending Order: 93 83 75 68 65 60 53 45 35

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
You will need those four files: d_node.h, d_nodel.h, d_random.h, and prg9_1.cpp Program Definition 1. Create program...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • In C++ please! Please include .cpp and .hpp files! Thank you! Recursive Functions Goals Create and...

    In C++ please! Please include .cpp and .hpp files! Thank you! Recursive Functions Goals Create and use recursive functions In this lab, we will write a program that uses three recursive functions. Requirements: Important: You must use the array for this lab, no vectors allowed. First Recursive Function Write a function that recursively prints a string in reverse. The function has ONLY one parameter of type string. It prints the reversed character to the screen followed by a newline character....

  • JAVA Program: reverse a linked list and find the middle node in the linked list. inFile...

    JAVA Program: reverse a linked list and find the middle node in the linked list. inFile (use argv[1]): A text file contains a list of English words (strings), giving below outFile1 (use argv[2])a text file includes       i) The completed sorted linked list, in ascending order. //With caption indicating you are printing the original sorted list       ii) The reversed linked list. //With caption indicating you are printing the reversed sorted list       outFile2( use argv[3]): All debugging outputs.                        ...

  • What is the specific answer for 1. and 2. Thanks! Add a new method, find, to...

    What is the specific answer for 1. and 2. Thanks! Add a new method, find, to class SinglyLinkedList (defined here) that takes as input a “data” value and returns a pointer to a node. If the input data is present in the linked list, the returned pointer should point to that node; if not, the returned pointer is nullptr. Write the (single line) method declaration/specification. Write the method definition/implementation. Test by running the main() function below and capture the console...

  • #C++, Programming: Program Design Including Data Structures, 7th Edition, it is too long so i can't...

    #C++, Programming: Program Design Including Data Structures, 7th Edition, it is too long so i can't add the these two file.(unorderedlinked.h and linkedlist.h) as well as the output Please use the file names listed below since your file will have the following components: Ch16_Ex5_MainProgram.cpp - given file //22 34 56 4 19 2 89 90 0 14 32 88 125 56 11 43 55 -999 #include #include "unorderedLinkedList.h" using namespace std; int main() { unorderedLinkedList list, subList; int num;                                                                                                                                   ...

  • Pull out question 8 on Exercises. See also: Program 4.16 invert (), Program 4.4 printList () Configuring -main () 1. Create a linked list 2. Function call of 8 (a) and (b) 3. Check the accuracy of th...

    Pull out question 8 on Exercises. See also: Program 4.16 invert (), Program 4.4 printList () Configuring -main () 1. Create a linked list 2. Function call of 8 (a) and (b) 3. Check the accuracy of the output of r list and l list 4. Repeat steps 1-3 above Please use c language void printlist(listPointer first) printf ("The list contains: ) for (; first; first = first→link) printf ("%4d", first-"data); printf("In") Program 4.4: Printing a list the nodes are...

  • NEED C++ HELP. PLEASE FOLLOW DIRECTIONS CAREFULLY: Use a 1 dimensional array object to create a...

    NEED C++ HELP. PLEASE FOLLOW DIRECTIONS CAREFULLY: Use a 1 dimensional array object to create a 2 dimensional table object. Then modify to create a triangular table. Example: Objective -> create an array of dynamic objects of RowAray inside Table. See below for RowAray.h, Table.h, Then create a triangular table like the example above. Fill each cell with random 2 digit integers. The Example Table above has 8 columns of RowAray objects each filled with 6 rows of random 2...

  • Here is the IntegerLinkedList_incomplete class: public class IntegerLinkedList { static class Node { /** The element...

    Here is the IntegerLinkedList_incomplete class: public class IntegerLinkedList { static class Node { /** The element stored at this node */ private int element; // reference to the element stored at this node /** A reference to the subsequent node in the list */ private Node next; // reference to the subsequent node in the list /** * Creates a node with the given element and next node. * * @param e the element to be stored * @param n...

  • I need to complete the C++ program for hotel reservation. In the main cpp you have...

    I need to complete the C++ program for hotel reservation. In the main cpp you have to display the hotel information from the hotel.txt based on customer preferences(which can be taken from the User.txt) For example, if the customer's budget is 200$, then only the hotels with prices below that amount should be displayed. Then the user has an option to choose which one to reserve for the particular time(which also can be found in the user.txt) The last two...

  • starter code To write a program using the starter code which is TestLinkedList to see if...

    starter code To write a program using the starter code which is TestLinkedList to see if the LinkedList program has bugs. It will produce ether a pass or fail.More information is in the first two pictures. LinkedList.java /** * @author someone * * Implements a double-linked list with four errors */ public class LinkedList<E> { // The first and last nodes in the list private Node<E> head, tail; // Number of items stored in the list private int size; //...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT