Starting Out with C++ from Control Structures to Objects (9th Edition)
Starting Out with C++ from Control Structures to Objects (9th Edition)
9th Edition
ISBN: 9780134498379
Author: Tony Gaddis
Publisher: PEARSON
bartleby

Concept explainers

Question
Book Icon
Chapter 20, Problem 10PC
Program Plan Intro

MaxNode function

Program Plan:

“Main.cpp”:

  • Include the required header files.
  • Declare the necessary function prototype and constants.
  • Define the main () function.
    • Declare the necessary variables.
    • Insert the values into the list.
    • Displays to user that the values are inserted.
    • Call the method “maximumnode()” to find the largest element of the list.
    • The largest valued node gets displayed.

“NumberList.h”:

  • Define the template function necessary.
  • Define the class “NumberList”.
  • Declare the necessary structure variables.
  • Define the constructor and destructor.
  • Declare the necessary function prototype.

“NumberList.cpp”:

  • Include the required header files.
  • Declare the necessary function prototype and constants.
  • Define the method named “nodeappend()”,
    • Declare the necessary variables
    • Validate the list using if statement to find the status of the list.
    • Use loop to iterate for the contents present in the list and add node to the last of the list.
  • Define the method named “viewlist()”,
    • Declare the necessary variables.
    • Use loop that iterates to display the elements present in the list.
  • Define the method named “insertval()”,
    • Declare the necessary variables.
    • Validate the content of the list using if statement.
    • After evaluation of the list the contents the values are inserted at the desired location.
    • Loop is used to iterate for the values that are present, to validate whether the particular element is greater or lesser than the elements present in the list.
    • After evaluation the value is inserted at the desired location.
  • Define the method named “removenode()”,
    • Declare the necessary variables.
    • Validate the list using if statement in order to position the list based on the elements that is deleted from the list.
  • Define the method named “~NumberList()”,
    • Declare the necessary variables.
    • Loop that iterates to delete the memory allocates.
  • Define the method named “sortlist()”,
    • Declare the necessary variables.
    • Use loop to iterate for the value of the list.
    •  A condition statement to compare the elements of the list and return the sorted list.
  • Define the method named “mergeval()”,
    • Loop that is used to iterate to merge the values of the list based on the list values.
    • Call the function “sortlist()” to sort the value after being merged.
  • Define the method named “maximumnode()”,
    • Return the head node to be the maximum node.
  • Defined the method named “maxNode()”,
    • Use a condition statement to validate the elements of the list to identify the maximum value that is present in the list.

Blurred answer
Students have asked these similar questions
I need help in server client project. It is around 1200 lines of code in both . I want to meet with the expert online because it is complicated. I want the server send a menu to the client and the client enters his choice and keep on this until the client chooses to exit . the problem is not in the connection itself as far as I know.I tried while loops but did not work. please help its emergent
I need help in my server client in C language
Exercise docID document text docID document text 1 hot chocolate cocoa beans 7 sweet sugar 2345 9 cocoa ghana africa 8 sugar cane brazil beans harvest ghana 9 sweet sugar beet cocoa butter butter truffles sweet chocolate 10 sweet cake icing 11 cake black forest Clustering by k-means, with preprocessing tokenization, term weighting TFIDF. Manhattan Distance. Number of cluster is 2. Centroid docID 2 and docID 9.
Knowledge Booster
Background pattern image
Computer Science
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
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr