Question: You are to use doubly linked lists to implement mathematical sets. Note that in a set each element is unique.Write the below functions, insert: Inserts
You are to use doubly linked lists to implement mathematical sets. Note that in a set each element is unique.Write the below functions,
- insert: Inserts a new node with a newValue if it does not exist in the list (set). Returns true if the insertion is successful, else false.
template
bool insertSet(DoubleNode
- setUnion: Returns a pointer to a newly created list (set) that is the union of two lists: head1 and head2. The union contains all elements that are either in list1 or in list2.
template
DoubleNode
- setIntersection: Returns a pointer to newly created list (set) that is the intersection of two lists (sets): head1 and head2. The intersection containing all elements that are both in list1 and in list2.
template
DoubleNode
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
