Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

data structure (c++) 1 Singly Linked List A linked list is a data structure where elements are connected to form a chain where each node

image text in transcribed

data structure (c++)

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. #include #include #define INF INT_MAX// indicates infinity value using namespace std; struct Node { int key; Node* next; Node(int key) { this->key = key; this->next = NULL; } }; class SinglyLinkedList { public: SinglyLinkedList() { head = NULL; } void addFront (Node* node) 1 { } int remove(int val) { } private: Node* head; }; int main() { SinglyLinkedList* SLL = new SinglyLinkedList(); Node* node1 = new Node (5); Node* node2 = new Node (13); Node* node3 = new Node (7); SLL->addFront (node); 1/5 SLL->addFront (node2); //13 5 SLL->addFront (node); //7 13 5 cout remove (6) remove (7)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatio Temporal Database Management International Workshop Stdbm 99 Edinburgh Scotland September 10 11 1999 Proceedings Lncs 1678

Authors: Michael H. Bohlen ,Christian S. Jensen ,Michel O. Scholl

1999th Edition

3540664017, 978-3540664017

More Books

Students also viewed these Databases questions

Question

What is computer neworking ?

Answered: 1 week ago

Question

2. Discuss various aspects of the training design process.

Answered: 1 week ago