Question: 1 Singly Linked List A linked list is a data structure where elements are connected to form a chain where each node points to the

 1 Singly Linked List A linked list is a data structure

where elements are connected to form a chain where each node points

to the next one in the order. Exercise: Given the code of

the Node struct, implement a singly linked list with the following functionalities:

addFront: add an integer key to the front of the list. remove:

1 Singly Linked List A linked list is a data structure where elements are connected to form a chain where each node points to the next one in the order. Exercise: Given the code of the Node struct, implement a singly linked list with the following functionalities: addFront: add an integer key to the front of the list. remove: deletes the smallest number larger than or equal the passed integer and returns the deleted value. If no number is found, returns -1. All cases must be handled. You can define any helper method as needed. 1 Singly Linked List A linked list is a data structure where elements are connected to form a chain where each node points to the next one in the order. Exercise: Given the code of the Node struct, implement a singly linked list with the following functionalities: addFront: add an integer key to the front of the list. remove: deletes the smallest mimber larger than or equal the passed integer and returns the deleted value. If no mumber is found, returns - 1. All cases must be handled. You can define any helper method as needed. #include #include key = key; this->next = NULL; } }; class SinglyLinkedList { public: SinglyLinkedList { head = NULL; } void addFront (Node node) 1 { ) int remove(int val) { ) private: Node. head: 2/5 int main() { SinglyLinkedList- sLL = new SinglyLinkedlist(); Node* node1 = new Node (5); Node* node2 = new Node (13): Node* node3 - new Node (7): sLL->addFront (nodel); // SLL->addFront (node); //13 5 sLL->addFront (node3); 1/7 13 5 cout remove(6) remove(7) using namespace std; struct Node { int ID: char alpha; Node. left; Node. right; Node (int ID, char alpha) { this->ID = ID: this->alpha = alpha; left = NULL; right - NULL; ) clans Tree { public: Tree) { } bool insert(int PID, Node node) { 11 (PID = -1) { if (root - NULL) { root = node: return true; } else return false; 3 return insert (PID, node, root); 3 bool checkString(string str) { } 3/5 int charCount(charc) { } private: Node* root: bool insert(int PID, Mode* node, Node root) { if (root == NULL) return false; else if (root->ID = PID) { if (root->left == NULL) { root->left = node; return true; } else if (root->right == NULL) { root->right = node return true: } else { return false; } } else { return insert (PID, node, root->left) || insert (PID, node, root->right); } return false; } }; int main() { Tree tree; Node* nodei - new Node(1, 'a'); Node* node2 = new Node (2, 'b'); Node* node3 = new Node (3, 'c'); Node* node4 = new Node (4, 'd'); Node* node5 = new Node (5, 'd'); cout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!