Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 1 [30 Marks Given a C++ program file, Test2_Q1.cpp, which creates a linked list with the initial state as shown in Figure 1. The

image text in transcribed

Question 1 [30 Marks Given a C++ program file, Test2_Q1.cpp, which creates a linked list with the initial state as shown in Figure 1. The variables head and tail are pointers that pointing to the first and last node of the list, respectively. 45 50 55 760 765 70 75 80 head Figure 1: The initial state of the list tail Append the appropriate lines of code at the space provided in Test2_Q1.cpp to accomplish each of the following tasks. Note that, each task is continous from one to the next. The state of the list after the execution of each task is given in each question below. You must not change any line of code regarding the class definition and the given lines of code in the main function. Task 1: Insert a new node (with the item = 111) at the end of the list. The result is given in Figure 2. (3 marks) 45 45/750 17 55176017667701-75/70/ head Figure 2 tail Task 2: Insert a new node (with the item = 222) between node 65 and node 70. The result is given in Figure 3. Note: In this task, you should use loop. (7 marks) 457 5017557607 65 222|7701775 80 +111 head Figure 3 tail Task 3: Delete the first node from the list. Figure 4 shows the result of this task. (3 marks) 50 55 55 [076010765117-2221770077516730107 m/ head Figure 4 tail

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

Building Database Driven Catalogs

Authors: Sherif Danish

1st Edition

0070153078, 978-0070153073

More Books

Students also viewed these Databases questions