Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(Make sure the program is in C) Given an array of N elements, you notice that there are some duplicate values. Implement a modified merge

(Make sure the program is in C) Given an array of N elements, you notice that there are some duplicate values. Implement a modified merge function such that the mergesort code we saw in class both sorts the array and removes all duplicates from the array. Your algorithm should run in O(N log N) time; briefly argue/justify that your program runs in O(N log N) time. Note: You are not allowed to simply call mergesort, and then remove duplicates by scanning the array after sorting it. You must modify the merge function. You may assume all elements in the original array are positive, and fill in empty spots with -1. Make sure there are no duplicate positive numbers, and as long as positive numbers are in sorted order if all -1 elements are ignored, the output would correct. You dont need to sort the -1s.

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

Rules In Database Systems Third International Workshop Rids 97 Sk Vde Sweden June 26 28 1997 Proceedings Lncs 1312

Authors: Andreas Geppert ,Mikael Berndtsson

1997th Edition

3540635165, 978-3540635161

More Books

Students also viewed these Databases questions