Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

// Exercise 1: Manipulating linked lists in C++ #include // Link is a data type for a linked list of integers class Link { public:

// Exercise 1: Manipulating linked lists in C++

#include

// Link is a data type for a linked list of integers

class Link

{

public:

int value;

Link* tail;

Link(int v, Link* t) : value(v), tail(t) {}

~Link()

{

if (tail) delete tail;

}

void print_list()

{

std::cout << value;

if (tail)

{

std::cout << ", ";

tail->print_list();

}

else

std::cout << std::endl;

}

};

// Return the reverse of the input list, as a new list.

// Do not modify the input list, but build a fresh list for its reverse.

Link* reverse_list(Link* lst)

{

// TODO

return 0;

}

// Return the index of an element in the provided list, or -1 if it does not exist.

int find_in_list(Link* lst, int element)

{

// TODO

return 0;

}

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_2

Step: 3

blur-text-image_3

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

Modern Database Management

Authors: Donald A. Carpenter Fred R. McFadden

1st Edition

8178088045, 978-8178088044

More Books

Students also viewed these Databases questions

Question

Question Can employees make contributions to a profit sharing plan?

Answered: 1 week ago