Subject Computer Science C-Family Programming

Question

1. Write a function that steps through a linked list of nodes with integer values, changing every other item to zero.
The function’s parameter should be a pointer to a node, and it should have a local variable that is a node iterator.

2. Write a function that steps through a linked list of nodes with integer values, counting the number of occurrences of zero.
The function’s parameter should be a pointer to a const node, and it should have a local variable that is a const_node_iterator.
Test both the functions in main()
You can use node2.h and node2.template file

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

int main(int argc, char** argv) {
    node<int> * n = NULL;
   
    for (int i = 0; i < 5; i++) {
       n = new node<int>(i, n);
    }
   
    cout << "Current list: ";
    Print(n);   
    cout << "\nNumber of occurrences of zero: " << ZeroCounting(n) << "\n";
    cout << "\n";
   
    cout << "Changing every other item to zero\n";
    ZeroOut(n);   
    cout << "Current list: ";
    Print(n);   
    cout << "\nNumber of occurrences of zero: " << ZeroCounting(n) << "\n";
   
    return 0;
}...

This is only a preview of the solution. Please use the purchase button to see the entire solution

Assisting Tutor

Related Homework Solutions

The Simplistic Primary Predictor in C++
Homework Solution
$20.00
Computer Science
Programming
C++
Primary Predictor
Election Results
Factors
Candidates
States
Information
Commercials
Campaign
Calculations
Statements
Variables
Input
Output
C++ Questions
Homework Solution
$15.00
Computer Science
Programming
Prime Numbers
Mathematics
Input
Output
Loops
Statements
Structures
Algorithms
Calendar
Leap Years
Reverse Digits
Functions
Programming Questions
Homework Solution
$40.00
Programming
C++
Computer Science
Strings
Codes
Characters
Pointers
Buffer
Human-Readable Information
CMYK Colors
Encoding
Issues
Compiler Errors
Assembly Language
Intel Machine
Lines
Symbols
Repetition Structures
Homework Solution
$30.00
Computer
Science
C
Programming
Repetition
Structures
Table
Creator
Pseudocode
Get help from a qualified tutor
Live Chats