Karatsuba''s divide-and-conquer algorithm

Assignment Help Data Structure & Algorithms
Reference no: EM13168130

In class we discussed Karatsuba's divide-and-conquer algorithm for integer multiplication, which multiplies n-bit numbers by recursively multiplying n bit numbers. We take two numbers X and Y and split them each into their most significant half and least significant half: X = 2^n/2A + B and Y = 2^n/2C + D. Now, we can write the product

XY =(2^n - 2^n/2)AC+2^n/2(A+B)(C+D)+(1-2^n/2)BD.

Using this relation, write pseudocode for a recursive function Karatsuba(X,Y,n) to multiply two n-bit numbers X and Y . You may assume that you have access to a routine shift(U,m) that will shift the number U by m bits to the left (you may use negative values of m to shift to the right) as well as access to routines add(U,V) and subtract(U,V) that respectively compute U + V and U - V and run in linear time. You can assume that the usual -, /, +, and * operators can be used on small numbers (like n) as well as on X and Y for your base-cases when n <=4.

If you like, you can assume you have a split(X,A,B) operator that splits X into its left and right halves A and B, but see if you can implement this using the shift operator.

Reference no: EM13168130

Questions Cloud

United broke artists (uba) is a broker : United Broke Artists (UBA) is a broker for not-so-famous artists. UBA maintains a small database to track painters, paintings, and galleries. A painting is created by a particular artist and then exhibited in a particular gallery
You are to create a program : You are to create a program that will input a group of floating point values, storing them as double values in an array. This array will then be sent to three functions.
You are the admissions office at abc medical university : You are the Admissions Office at ABC Medical University. You have a large number of applicants for a very few number of available openings at your school. As a result, you need to set some high admission standards. To be accepted, a student ..
Numbers until the user wants and in the end display : Write a C program to enter the numbers until the user wants and in the end display the product of numbers entered by the user. The program should terminate once the user enters the character 'n' and continue computing product if user enters 'y'
Karatsuba''s divide-and-conquer algorithm : In class we discussed Karatsuba's divide-and-conquer algorithm for integer multiplication, which multiplies n-bit numbers by recursively multiplying n bit numbers. We take two numbers X and Y and split them each into their most significant half a..
Creates an array of six divsales objects : Write a program that creates an array of six DivSales objects. The program should ask the user to enter the sales for four quarters for each division. After the data are entered, the program should display a table showing the division sales for ..
Create a class in java to enable its object to be persiste : How do you create a class in Java to enable its object to be persistent? What are Java data streams and how are they used to facilitate storage and retrieval of persistent objects?
A sorting algorithm is described as stable : A sorting algorithm is described as stable if equal elements are in the same relative order in the sorted sequence as in the original sequence.
Create a flowchart that programs a robot to recognize : Create a flowchart that programs a robot to recognize how many playing cards you have and to put them in order from smallest to largest

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Implement an open hash table

In this programming assignment you will implement an open hash table and compare the performance of four hash functions using various prime table sizes.

  Use a search tree to find the solution

Explain how will use a search tree to find the solution.

  How to access virtualised applications through unicore

How to access virtualised applications through UNICORE

  Recursive tree algorithms

Write a recursive function to determine if a binary tree is a binary search tree.

  Determine the mean salary as well as the number of salaries

Determine the mean salary as well as the number of salaries.

  Currency conversion development

Currency Conversion Development

  Cloud computing assignment

WSDL service that receives a request for a stock market quote and returns the quote

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  Recursive implementation of euclids algorithm

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers

  Data structures for a single algorithm

Data structures for a single algorithm

  Write the selection sort algorithm

Write the selection sort algorithm

  Design of sample and hold amplifiers for 100 msps by using n

The report is divided into four main parts. The introduction about sample, hold amplifier and design, bootstrap switch design followed by simulation results.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd