The purpose of this lab is to implement the node insertion, remove, and
print reverse operations for a doubly linked list {where each Node contains
a pointer to next "successor" and prev "predecessor"}.
Constraints: the head node's prev will always be NULL, and the last node's
next will always be NULL.
Use the following pseudocode to implement the following operations:
if position is less than 1 or greater than count + 1 return false Create a newnode pointer by calling createNode passing elem if position is equal to 1 or if head is equal to NULL set newnode's next to head set newnode's prev to NULL // not necessary but safe if head is not equal to NULL set head's prev to newnode set head to newnode else create a node pointer (cur) and set to head declare an integer variable (i) and set to 1 while cur's next does not equal NULL and i does not equal pos - 1 set cur to cur's next and increment i set newnode's next to cur's next set newnode's prev to cur if cur's next does not equal NULL set cur's next's prev to new node set cur's next to newnode endif increment count return true
Create a node pointer (cur) and set to head while cur does not equal NULL | if cur's data is equal to the elem to remove { | | if cur is equal to head { | | | set head to head's next | | | if head does not equal NULL | | | L set head's prev to NULL | | L} | | else { | | | if cur's next does not equal NULL | | | L set cur's next's prev to cur's prev | | | if cur's prev does not equal NULL // not necessary but safe | | | L set cur's prev's next to cur's next | | | delete cur | | | set cur to NULL | | | decrement count | | | return true | | L} | L} | else { | | set cur to cur's next | L} endWhile return false (element was never found)
/* NOTE: the following is a procedural implementation and * * LinkedList does not contain a Tail member variable */ create a node pointer (cur) and set to head while cur's next does not equal null set cur to cur's next endWhile while cur does not equal NULL print out cur's data update cur to cur's prev endwhile print out count number of elements
Copy the following code and implement these functions
within LinkedList.cpp
Lab10 Files
~$wget http://www.cs.csubak.edu/~derrick/cs2020/examples/lab10/LinkedList.cpp .
~$wget http://www.cs.csubak.edu/~derrick/cs2020/examples/lab10/LinkedList.h .
~$wget http://www.cs.csubak.edu/~derrick/cs2020/examples/lab10/Node.cpp .
~$wget http://www.cs.csubak.edu/~derrick/cs2020/examples/lab10/Node.h .
~$wget http://www.cs.csubak.edu/~derrick/cs2020/examples/lab10/lab10.cpp .
Show me your completed code in class or have ALL the files within your depository directory. ~/2020_S18/wk10/