Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider two sets of integers, X = [x, x2, n] and Y= [y, 92, ..., yn]. Write two versions of a FINDUNCOMMON(X, Y) algorithm

 Consider two sets of integers, X = [x, x2, n] and Y= [y, 92, ..., yn]. Write two versions of a 

Consider two sets of integers, X = [x, x2, n] and Y= [y, 92, ..., yn]. Write two versions of a FINDUNCOMMON(X, Y) algorithm to find the uncommon elements in both sets. Each of your algorithms should return an array with the uncommon elements, or an empty array if there are no uncommon elements. You may make use of any algorithm introduced in the lectures to help you develop your solution. That is, you do not have to write the 'standard' algorithms - just use them. Therefore, you should be able to write each algorithm in about 10 lines of code. You must include appropriate comments in your pseudocode. (a) [2 Marks] Write a pre-sorting based algorithm of FINDUNCOMMON(X, Y). Your algorithm should strictly run in O (n log n). (b) [2 Marks] Write a Hashing based algorithm of FINDUNCOMMON(X,Y). Your algorithm should run in O(n).

Step by Step Solution

3.34 Rating (151 Votes )

There are 3 Steps involved in it

Step: 1

a Sort the array X using mergesort or quick sort include s... 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

Introduction to Algorithms

Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest

3rd edition

978-0262033848

More Books

Students also viewed these Computer Network questions