Question: In this lab, you have to implement functions for lists: During the class we considered the insert function within a class ( it was a

In this lab, you have to implement functions for lists:
During the class we considered the insert function within a class (it was a method)
We consider the class Node with the properties int data, Node* next, and Node* previous
Create a recursive function that insert an element in the list given as an input, where the list is only the pointer to the head.
Possibility 1: Node* Insert(Node* head,int x)// Insert the element x in the list head, and return the new list
Possibility 2: void Insert(Node** head,int x)// Insert the element x in the list head, and change the list given as an input (pointer)
Possibility 3: void Insert(Node* &head,int x)// Insert the element x in the list head, and change the list given as an input (reference)
We consider a an array of size n containing integers
1. Create a function that returns a list l containing the unique values of a
Example: the array [0102301] will return the list (0,1,2,3)
2. Create a function that return a list l containing the occurrence of each element in a
Example: the array [0102301] will return the list (3,2,1,1)
3. Create a sorted list that returns all the elements from an array that are above a given element x
Example: the array [481396] and x=5, the returned list is [689]
4. Create a Stack or a Queue class (the choice is yours) using a list instead of an array, as seen during the class
Submit only questions 1,2,3,4 in the same file, with a main that demonstrates each function.
code in c++

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!