Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Consider counting inversions of the following sequence: 4,1,5,6,3,2, using the divide-and-conquer approach Sort-and-Count(). Suppose we already finished the recursive call on the left half,

image text in transcribed
1. Consider counting inversions of the following sequence: 4,1,5,6,3,2, using the divide-and-conquer approach Sort-and-Count(). Suppose we already finished the recursive call on the left half, which returns the sorted list 1, 4, 5 and the number of inversions rA=1, and the recursive call on the right half, which returns 2,3,6 and the number of inversions rB=3. Perform Merge-and-Count() on the two sorted halves to count the "across-half" inversions as well as computing the total number of inversions of this sequence. 2. Multiply (1000)2 with (0110)2 by Recursive-Multiply(). Assume the base case is when both x and y are 2-digit binary numbers. In other words, when both x and y have 2 or fewer digits, you do not have to perform additional recursions and can simply return their product. 3. When we discussed the divide and conquer algorithm for finding the closest pair of points in class, it was mentioned that if there were two or more points having the same x-coordinate or the same y-coordinate, we could rotate the points so that no two or more rotated points had the same x - or y-coordinates. Note, however, that it is unclear whether the rotation changes the solution to the problem. In other words, it may be possible that the closest pair of points after rotation are not the closest pair of points originally. Show that the above concern is unfounded. That is, show that rotating all of the points by the same angle about the origin does not change the solution. Note that when a point (x,y) is rotated by a counterclockwise angle about the origin, it is moved to (xcosysin,xsin+ycos). (Hint: Consider any two arbitrary points (x,y) and (x,y). What is the distance between the two points? Then rotate the two points by the same counterclockwise angle about the origin. What are the new coordinates of the two rotated points? What is the distance between the two rotated points? How does the new distance relate to the original distance?)

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

Conceptual Database Design An Entity Relationship Approach

Authors: Carol Batini, Stefano Ceri, Shamkant B. Navathe

1st Edition

0805302441, 978-0805302448

More Books

Students also viewed these Databases questions