need c++ format
need SkipListNode.h & .cpp and main.cpp
**********************************************************

![1.3.1 Displaying the Skip List Node From a purely object-oriented standpoint, the only piece of human-readable information in a skip list node is the data stored there; the next pointers are essentially random numbers which most likely change from execution to execution of the program. From a program development point of view, however, it will be helpful to be able to visually confirm the next pointer contents. To do so, the write method for one node shall parenthetically display the values (and only the values) of successor nodes in addition to its own value. // write nodes key value for // each next pointer if // nexts[i] leads to a node // write (nodes key value) else // write Add the interface and implementation of write to the project and overload the << operator so that it invokes method write. Test it with the following program segment in function main SkipListNode n1 (103, 3); SkipListNode n2 (201, 1); cout << w/o setNext: << n1 << endl << n1.setNext (0, &n2); cout << setNext: << n1 << endl << << n2 << endl; << n2 << endl; The results should appear as follows w/o setNext: 201 ( /) 103 201) (( /) 201 /) setNext:](http://img.homeworklib.com/questions/bd484460-319a-11eb-9b83-d326211370a4.png?x-oss-process=image/resize,w_560)
ANSWER:
Code in C++. Tested on Microsoft Visual Studio.
#include<iostream>
using namespace std;
/*
*class that represent the Skip list node
*where each node contains data of type double
*and variable number of pointers to the same
*class
*/
class SkipListNode{
double data;
SkipListNode** next;//pointer of pointers
int size;//size of array of pointers
public:
/*
*constructor that accepts @value as data in the
node
*and @size as number of pointers
*/
SkipListNode(double value,int size){
data = value;
next = new
SkipListNode*[size];
for (int i = 0; i < size;
i++){
next[i] =
nullptr;
}
this->size = size;
}
/*
*method to set the next pointers at @index with given
node
*@address
*/
void setNext(int index, SkipListNode*address){
next[index] = address;
}
/*
*method to display the information in the node
*/
ostream & write(ostream& out){
out << data;
for (int i = 0; i < size;
i++){
if (next[i] !=
nullptr){
out << " ( " << next[i]->data
<< " )";
}
else{
out << " ( / )";
}
}
return out;
}
friend ostream & operator << (ostream&
out, SkipListNode& node);
};
//<< operator overloaded to print SkipListNode class
object
ostream & operator << (ostream& out,
SkipListNode& node){
return node.write(out);
}
int main(){
SkipListNode n1(103, 3);
SkipListNode n2(201, 1);
cout << "w/o setNext : " << n1
<< endl<<"
"<<n2<<endl;
n1.setNext(0, &n2);
cout << "w/ setNext : " << n1
<< endl << " " <<
n2 << endl;
getchar();
return 0;
}
Output:
w/o setNext : 103 ( / ) ( / ) ( / )
201 ( / )
w/ setNext : 103 ( 201 ) ( / ) ( / )
201 ( / )

need c++ format need SkipListNode.h & .cpp and main.cpp ********************************************************** 1.3 The Skip List's Node Class...
PLEASE USE C++ Source Code
Attached is a linked list with 2 nodes. You can use this or
write a similar one. The assignment is to write 2 functions. One
function will add another node at the end of the list. The other
function will delete a node. Don't forget - No dangling pointers
!
Example linked source code attached below
#include<iostream>
using namespace std;
class Node
{
int data;
Node *next;
public:
void setdata(int d) {data = d;}
void...
Hi, I hope I can get some help with the following exercise in C++( CPP): 1.Write an additional method called push_back(int) that will add an integer to the end of the list. You can modify the provided code. 2.Modify the Node class and LinkedList class so that you can access your parent node (double linked-list). /* definition of the list node class */ class Node { friend class LinkedList; private: int value; Node *pNext; public: /* Constructors with No Arguments...
Working in C++, Complete the code. // Lab 9 code /* Insert leading comments with your name and the date. Describe the purpose of the code. Also, list each pointer and describe how it is used to enable the selection sort for the linked list structure. */ /* Insert code as described by the comments. */ /* Add comments to each line of code that uses a pointer, describing how it is being used. */ #include <iostream> using namespace std;...
You are required to write the following functions using this class:
class Doubly_linked_list // Use a class Doubly_linked_list to represent an object
{
public:
// constructor initialize the nextPtr
Doubly_linked_list()
{
prevPtr = 0; // point to null at the beginning
nextPtr = 0; // point to null at the beginning
}
// get a number
int GetNum()
{
return number;
}
// set a number
void SetNum(int num)
{
number = num;
}
// get the prev pointer
Doubly_linked_list ...
***CODE MUST BE IN C++*** Using the linked list in "basic linked list" which has a STRUCTURE for each node, write FUNCTION which starts at the head and outputs the value for each node until the last node is reached. Note: your function should work with the structure that is in this program. Please do not use the example which is for a class, but this example canbe helkpful. Also note that the function must work no matter how many nodes...
(C++) You are tasked with implementing a recursive function void distanceFrom(int key) on the IntList class (provided). The function will first search through the list for the provided key, and then, recursively, change all previous values in the list to instead be their distance from the node containing the key value. Do not update the node containing the key value or any nodes after it. If the key does not exist in the list, each node should contain its distance...
This is a c++ class utilizing class templates and linked lists. I need to implement the following member function(s) to List.cpp. Node.hpp/cpp should be fine but if you feel like there needs to be a change for compilation or testing, feel free to do so but make sure to comment on why it was done. /** @pre assumes position is valid, if position is > item_count_ it returns an empty List, also assumes that operators <= and >= are defined...
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...
Need this in C++ Goals: Your task is to implement a binary search tree of linked lists of movies. Tree nodes will contain a letter of the alphabet and a linked list. The linked list will be an alphabetically sorted list of movies which start with that letter. MovieTree() ➔ Constructor: Initialize any member variables of the class to default ~MovieTree() ➔ Destructor: Free all memory that was allocated void printMovieInventory() ➔ Print every movie in the data structure in...
You are tasked with implementing a recursive function void distanceFrom(int key) on the IntList class (provided). The function will first search through the list for the provided key, and then, recursively, change all previous values in the list to instead be their distance from the node containing the key value. Do not update the node containing the key value or any nodes after it. If the key does not exist in the list, each node should contain its distance from...