Given these definitions:
struct node;
typedef node * ptrType;
struct node
{
int Data;
ptrType Next;
};
ptrType P = new node;
a. Write a line of code to assign the value 7 data field for the node dynamically allocated by the last line.
b. Write a line of code to deallocate the node dynamically allocated by the last line.
3.2 Using the struct of the previous question, write a program (all in the main function) that does the following:
a. Creates three nodes and gives them Data values of 1, 2, and 3.
b. Links the nodes together in a linked list.
c. Traverses the created list, displaying each Data value.
3.3Suppose that a circular linked list, using the struct of the previous question, has an external pointer List pointing to the "last" node in the list. Write a line of code to disconnect the node at the "beginning" of the list.
3.4Write a function that inserts a new node at the start of a doubly linked list.
3.5 Write a function that inserts a new node at the start of a (singly) linked list that uses a dummy head node.
3.6 A character string can be implemented as a linked list of characters. Create an ADT in C++ called Newstring that uses linked lists to implement the following string operations:
concatenate(Newstring addString)
copies contents of parameter onto the end of string; does not merely make end of string point to beginning of Newstring object
concatenate(char ch)
concatenates the single character ch onto the end of string
display()
display string on standard output
length()
returns the length of string
In all cases string refers to the private data of your ADT. In implementing this ADT, you may want to write additional, private methods to assist the others. Write a short program to test your ADT.
3.7 How can using strings instead of simple types like integers alter the O-notation of operations?