CPSC 2430 Lab#3

$30.00

Category: You will Instantly receive a download link for .zip solution file upon Payment

Description

5/5 - (5 votes)

Lab3 exercises your understanding of LINKED LISTS and addresses as well as managing:
dynamic memory and pointers

Follow these steps:
1) place the given and requested code in file L3.cpp and upload when completed to Canvas
2) use the following type definition, given in class on Wednesday 10/7/15
struct Node
{ int data;
Node* link;
};
3) construct an ordered linked list containing 5 to 10 values. You may ‘cheat’ in this step (as a warmup; fully developed insertion routine is more difficult and is the last step of the lab) by simply inputting values in increasing order so that the list is ordered; in which case, your code should look similar to:
Node* head = new Node;
head->data = firstValue;
head->link = nullptr; // 0 also fine

Node* auxPtr = head;

while ( !terminatingCondition )
{ auxPtr->link = new Node;
auxPtr = auxPtr->link;
auxPtr->data = anotherValue;
}
auxPtr->link = nullptr;

4) write and test the code to traverse and print out contents of your linked list
5) write and test the code to DELETE the node containing a specific value, if it is stored in your LL
6) write the code to INSERT a specific value in your ordered LL. You may refine to omit duplicate values.