Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

12. (10%) Fill in the five blanks (A, B, ..., E) in the following C++ function, Reverse(), which reverses a singly linked list (or called

image text in transcribed

12. (10%) Fill in the five blanks (A, B, ..., E) in the following C++ function, Reverse(), which reverses a singly linked list (or called a Chain in the program code). For example, after running X.Reverse() where X=(x1, X2, Xn) is a chain, X will become (Xn, Xn-1, ..., x1). // Declaration of a node (in a chain). template class ChainNode { friend class Chain ; private: T data; ChainNode* link; // "link" points to the next node in the chain. // "link" of the last node is set to be NULL. }; Il Declaration of a chain. template class Chain { private: ChainNode *first; // 'first points to the 1st node in the chain. public: Chain(void) {first = last = NULL;}; // constructor void Chain::Reverse(void); // The function. }; // This is the function used for reversing the chain. // In other words, it turns a chain (X1, X2, ..., xn) into (Xn, Xn-, ..., x). template void Chain::Reverse(void) { ChainNode *next = first, *current = NULL; while (next) { ChainNode *previous = ; current = _B__; next = current->link D } first = E }

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

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 19 21 2012 Proceedings Part 3 Lnai 7198

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284922, 978-3642284922

Students also viewed these Databases questions

Question

What are the stages of project management? Write it in items.

Answered: 1 week ago

Question

why do consumers often fail to seek out higher yields on deposits ?

Answered: 1 week ago