in c++ only. second part of the first question.
/*
* List.h file
*/
#include <iostream>
using namespace std;
struct NodeType
{
int data;
NodeType *next;
};
class List
{
private:
NodeType *front, *rear;
public:
List();
void getList();
void addNodeLast(int val);
NodeType* getFront()
{
return front;
}
NodeType* getRear()
{
return rear;
}
};
/* List.h file ends here */
/*
* List.cpp file
*/
#include "List.h"
List :: List()
{
front = NULL;
rear = NULL;
}
void List :: getList()
{
NodeType *ptr = new NodeType;
ptr = front;
while (ptr != NULL)
{
cout << ptr->data << " ";
ptr = ptr->next;
}
}
void List :: addNodeLast(int val)
{
NodeType *newNode = new NodeType;
newNode->data = val;
newNode->next = NULL;
if (front == NULL)
{
front = newNode;
rear = newNode;
newNode = NULL;
}
else
{
rear->next = newNode;
rear = newNode;
}
}
/* List.cpp file ends here */
/*
* Main.cpp file
*/
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
#include "List.h"
List getSubset(List M, int N)
{
List sub;
NodeType *ptr = new NodeType;
ptr = M.getFront();
while (N--)
{
sub.addNodeLast(ptr->data);
//cout << ptr->data << " ";
ptr = ptr->next;
}
return sub;
}
int main()
{
List M, N, subset;
srand(time(NULL));
for (int i = 0; i < 10; i++)
{
M.addNodeLast(rand()%25 + 18);
}
cout << "Linked List M: ";
M.getList();
cout << endl;
for (int i = 0; i < 6; i++)
{
N.addNodeLast(rand()%25 + 18);
}
cout << "Linked List N: ";
N.getList();
cout << endl;
// calling functions from question 2
int subLen = 4;
subset = getSubset(M, subLen);
cout << "Subset of M with subset length " << subLen << ": ";subset.getList();
// calling functions from question 3
return 0;
}
/* Main.cpp file ends here */

Note: This part is done, with all the necessary parts (1, 2, and 4). Please upload the 3rd question. I will do it for you.
in c++ only. second part of the first question. M is a linked list. this question as well as 3 and 4 are built off of question 1. 2. Write a function definition to create a new list. sub, that i...
write the function definition to create a linked list of 8 nodes that contain randomly generated characters between .с. 99) and· 119). The function should return t new linked list. (HINT: keep in mind the member function defined in question 2). 3.
Write a C function that iterates through a singly linked list and converts it to a doubly linked list. Your solution must NOT create a second list. You must come up with the appropriate parameters and return type. Note: the nodes in the singly linked list have a field for a previous pointer, but that field has not initially been set in any of the nodes. You must do this as part of your solution!
In C++ - Learn how to implement linked lists Part 1 Node and Linked List Class (50 pts): Create node with public properties: Block type block and block ptr next. Create a linked list class that uses the node you generated without an add or delete method with a head and optional tail and counter. Make a driver that generates a node to test your implementation. Part 2 Add Method (30 pts): Create an add method in your linked list...
a) 7% Define a function (the function definition only) named combine_lists that receives two lists of integers (the function has 2 parameters). You can assume that each list is the same length and each list is not empty. The function will create a new list which is composed of the addition of each element of the two lists. The function returns the new list. For example, if the function is sent this list: [2,4,6,8,10] and this list: [5,6,7,8,9] then the...
c++ only Program 2: Linked List Class For this problem, let us take the linked list we wrote in a functional manner in a previous assignment and convert it into a Linked List class. For extra practice with pointers we’ll expand its functionality and make it a doubly linked list with the ability to traverse in both directions. Since the list is doubly linked, each node will have the following structure: struct Node { int number; Node * nextNode;...
Write a C++ function to add a node to the beginning of a linked list. Your function takes two arguments - the head of the linked list and the value num to be added. Note that the list may be empty! Your function should modify the head of the linked list to point to the new node, and set the new node to point to the rest of the list (if not empty). Example: Initial Array: 4->2->3, key = 5...
Draw a sketch of a singly linked list containing the following int values: 3, 1, 4, 1, 5. The 3 should be at the front of the list. Remember to sketch the head pointer, each node, and each node's next pointer. 2. Write the code for the following new member function for our SinglyLinkedList class. You should write out the definition of the function, but do not need to write out all of the rest of the class. Your code...
Simple singly-linked list question: write an iterative function position(p, target) that returns position (1, 2, 3, or .......) of the target in the list to which p points. If target is not on the list the function returns -1. please write the function in C++ thanks
1. Create a node class and linked list class. 2. Add the following function from lecture to your linked list class addFirst(e) addLast (e) add(index, e) removeFirst removeLast remove(index) 3. Add the following methods to the linked list class. a. # Return the size of the list def getSize(self): b. # Clear the list */ def clear(self): c. # Return the element from this list at the specified index def get(self, index):
I need this in C++. This is all
one question
Program 2: Linked List Class For this problem, let us take the linked list we wrote in a functional manner in a previous assignment and convert it into a Linked List class. For extra practice with pointers we'll expand its functionality and make it a doubly linked list with the ability to traverse in both directions. Since the list is doubly linked, each node will have the following structure: struct...