Question: Create the following methods in c++ -private class node: includes public members int val, node *next, and a constructor node(int v, node *ptr) initialize node
Create the following methods in c++
-private class node: includes public members int val, node *next, and a constructor node(int v, node *ptr) initialize node *root and node *last. int count must also record the number of entries in the list. This will go in a header file
-int insertAt(int v, int index)- inserts the value v at the index "index". Values at that position need to shift right. Returns the index into which it was inserted. Returns -1 if the list was full or if the index was greater than count. Goes in cpp file.
-int add(int v)- inserts the value v at the beginning of the list. Returns the index into which it was inserted. Returns -1 if the list is full. Goes in cpp file.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
