Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2. (16 pts.) Divide-and-Conquer An array A[1...n is said to have a majority element if more than half of its entries are the same. Given

image text in transcribed
image text in transcribed
2. (16 pts.) Divide-and-Conquer An array A[1...n is said to have a majority element if more than half of its entries are the same. Given an array, the task is to design an efficient algorithm to tell whether the array has a majority element, and, if so, to find that element. The elements of the array are not necessarily from some ordered domain like the integers, and so there can be no comparisons of the form "is Ali] > Aj}?" (Think of the array elements as GIF files, say.) However you can answer questions of the form: "is Ali] = A[j]?" in constant time. Design a dynamic programming algorithm to solve this problem in O(nlogn) time. You may assume that n is a power of two. (Hint: the divide step is simple: just split the array into the left half and right half. How does knowing the majority elements (if they exist) of the two halves help you figure out the majority element in the whole array? Consider all the possibilities.) (a) Describe the algorithm, either in pseudo-code or English. (b) Argue why your algorithm is correct (c) Do a running time analysis of your algorithm 1. There is a typo in problem 2. Where it says "dynamic programming" it should say "divide and conquer" 2. For problem 2, parts c and d, you can assume that the graph is undirected. We will accept any solution that uses directed graphs though

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

Name is needed for identifying organisms ?

Answered: 1 week ago

Question

Q.1. Taxonomic classification of peafowl, Tiger and cow ?

Answered: 1 week ago