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
Exercise, maxCylinderVolume F# system function such as min or methods in the list module such as List.map are not allowed Write a function maxCylinderVolume that takes a list of floating-point tuples that represent dimensions of a cylinder and returns the volume of the cylinder that has the largest volume. Each tuple has two floating point values that are both greater than zero. The first value is the radius r and the second value is the height h. The volume of the cylinder is computed using ??2h. The value π is represented in F# with System.Math.PI. If the list is empty, return 0.0. Examples: > maxCylinderVolume [(2.1, 3.4); (4.7, 2.8); (0.9, 6.1); (3.2, 5.4)];;val it : float = 194.3137888> maxCylinderVolume [(0.33, 0.66)];;val it : float = 0.2257988304
Question > Not complete Marked out of 1.50 Flag question Previous page Write a recursive function named get_palindromes (words) that takes a list of words as a parameter. The function should return a list of all the palindromes in the list. The function returns an empty list if there are no palindromes in the list or if the list is empty. For example, if the list is ["racecar", "hello", "noon", "goodbye"], the function should return ["racecar", "noon"]. A palindrome is a word that is spelled the same forwards and backwards. Note: The get_palindromes() function has to be recursive; you are not allowed to use loops to solve this problem. For example: Test words = ["racecar", "hello", "noon", "goodbye", "test", 'aibohphobia'] ['racecar', 'noon', 'aibohphobia'] print (get_palindromes (words)) print (get_palindromes ([])) print (get_palindromes (['this', 'is', 'test'])) Answer: (penalty regime: 0, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50 %) Result Precheck Check [] [] Next page
Fill in the blanks
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