Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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,

  1. 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*& head, Object newValue);

  1. 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* setUnion(DoubleNode* head1,DoubleNode* head2);

  1. 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* setIntersection(DoubleNode* head1,DoubleNode* head2);

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

More Books

Students also viewed these Databases questions

Question

Explain what chain-weighting is.

Answered: 1 week ago