Implement the method push_back(), which is just a variant of method
Ask Expert

Be Prepared For The Toughest Questions

Practice Problems

Implement the method push_back(), which is just a variant of method

Problem 2 

Implement the method push_back(), which is just a variant of method push_front(). Do not reinvent the wheel. The method push_back() does not require a search. Remember  that fRoot is 12 o’ clock if the doubly-linked list nodes are viewed as a clock. 

You can use #define P2 in Main.cpp to enable the corresponding test driver. 

void testP2() 

 using StringList = List<string>;   

 string s1( "AAAA" ); 

 string s2( "BBBB" ); 

 string s3( "CCCC" ); 

 string s4( "DDDD" ); 

 string s5( "EEEE" ); 

 string s6( "FFFF" ); 

 cout << "Test of problem 2:" << endl; 

 StringList lList;   

 lList.push_front( s4 ); 

 lList.push_front( s3 ); 

 lList.push_front( s2 ); 

 lList.push_front( s1 ); 

 lList.push_back( s5 ); 

 lList.push_back( s6 ); 

 // iterate from the top 

 cout << "Bottom to top " << lList.size() << " elements:" << endl; 

 for ( StringList::Iterator iter = lList.rbegin(); iter != iter.rend(); iter-- )  { 

 cout << *iter << endl; 

 } 

 cout << "Completed" << endl; 

The result should look like this. No errors should occur: 

Test of problem 2: 

Bottom to top 6 elements: 

FFFF 

EEEE 

DDDD 

CCCC 

BBBB 

AAAA 

Completed

problemset-3

Hint
Computer push_back() method is one technique in C++ that is part of the standard library associate vector whose main duty is to insert any new section at the end of the vector being well-defined or declared. Introducing a new element at the end of the vector using the push_back function increase the size of the whole vector by one....

Know the process

Students succeed in their courses by connecting and communicating with
an expert until they receive help on their questions

1
img

Submit Question

Post project within your desired price and deadline.

2
img

Tutor Is Assigned

A quality expert with the ability to solve your project will be assigned.

3
img

Receive Help

Check order history for updates. An email as a notification will be sent.

img
Unable to find what you’re looking for?

Consult our trusted tutors.

Developed by Versioning Solutions.