Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a c++ function that takes a linked list of ints as a parameter and returns the weight of the list where the weight is

Write a c++ function that takes a linked list of ints as a parameter and returns the weight of the list where the weight is equal to the sum of the depth*data for each node in the list. The linked list class has functions .getSize() which returns the number of nodes(ints) in the list, .getFront() which returns the front integer, and .deleteFront() which deletes the front node and makes the next node the front.

*NOTE: not using a built in class, linked list class built in header file

Example list

Depth Data
1 2
2 4
3 3
4 1

Weight = (1*2) + (2*4) + (3*3) + (4*1) = 23

int calculateWeight(list d) {

return weight;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MySQL/PHP Database Applications

Authors: Brad Bulger, Jay Greenspan, David Wall

2nd Edition

0764549634, 9780764549632

Students also viewed these Databases questions