Question: Introduction Add function definition for insertAtPosition ( int value, int position ) , insertAtEnd ( int value ) , insertAtBeginning ( int value ) that
Introduction
Add function definition for insertAtPositionint value, int position insertAtEndint value insertAtBeginningint value that insert the node base on the function name.
Example
head refers to the first node in the list
data
position
Insert a node at position with The new list is
Function Description
Complete the function insertAtPositio in the editor below. It must return a reference to the head node of your finished list.
insertAtPositio has the following parameters:
value: an integer value to insert as data in your new node
position: an integer position to insert the new node, zero based indexing
Input Format
The first line contains an integer the number of elements in the linked list.
Each of the next n lines contains an integer SinglyLinkedListNodeidata.
The next line contains an integer data, the data of the node that is to be inserted.
The last line contains an integer position.
Constraints
n
SinglyLinkedListNodeidata where SinglyLinkedListNodei is the ith element of the linked list.
position n
Note:
My set up: Apple M with visual studio code, NO PLUGIN
I ran into this issues
Node.cpp::: error: use of undeclared identifier 'nullptr'
Nodeint value : datavalue nextnullptr
Run this
gstdc Node.cpp LinkedList.cpp driver.cpp o driver
Output
Output
Original List:
List after insertion:
Explanation
The initial linked list is Insert at the position which currently has in it The updated linked list is
Requirements:
Your program must be split into files:
The driver program
The class interface add if needed
The class header file class definition add if needed
The class implementation file.
The driver program for each programming project should begin with "header comments" containing:
Your name
Programming assignment number
A short description of the program
Course
The date
For example:
Programmer: TRUC HUYNH
Project number:
Project Desc: Quadratic Expression class
Course: COSC PF III Data Structures
Date:
note:
Use a standard indentation convention in your code see examples in textbook
Use meaningful variable names.
Do not use global variables.
Your class methods should not contain any input or output operations. All input and output should be done in your driver.
Submission:
Project will automatically clone to your github account. Please clone to your work space and work on it Make sure you push regularly to create good habit. Your code will automatically submit to my board when you push. I will grade by due date.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
