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

  Java program to assign passengers seats in airplane

Prepare a Java program to assign passengers seats in an airplane. Suppose a small airplane with seats numbered as follows:

  Designing asp.net assignment

Design an ASP.NET assignment with Visual Studio.NET 2005. Create an event handler that assigns the entry in the TextBox control to Label control's Text property when the consumer clicks the Button control.

  Function to swap all the left-right subtrees of binary tree

Write a function, swapSubTrees, that swaps all of the left and right subtrees of a binary tree. write a method singleParent, that returns the number of nodes in a binary tree that have only one child.

  Determine minimum number of total nodes tree can have

If binary tree has height 4, determine minimum number of total nodes tree can have? c. If binary tree has height 4, determine the maximum number of total nodes tree can have?

  Creating a unix shell script

Design a Unix shell script that searches for a text document with most occurrences of a given keyword. For instance, if I would like to search for a script with most usages of if statement,

  Create efficient algorithm to find path in graph

Given connected undirected graph G described by the adjacency list representation create the efficient algorithm to find the path in G which goes through exactly once in each direction.

  Design a simple algorithm by giving pseudocode

Design a simple algorithm by giving pseudocode, for constructing a binary search tree T on n elements in O(nlogn) time with the property that any Find operation on T takes O(logn) time.

  Find the shortest path from a to all other vertices

Find the shortest path from A to all other vertices for the following graph:

  Draw flowchart to print average for each student

Draw a flowchart to print the average for each student in a class. Input. Input consists of student records each containing a student's name(STUDENT-NAME), score for first test(TEST), score for second test(TEST2), and score for third test(TEST3)..

  Question about disk writing speed

Think about a disk holding documents with an average file length of 5 KB. Each document is allocated contiguously on adjacent sectors.

  Simplify rsa cryptosystem using prime number

Assume we tried to simplify RSA cryptosystem using just prime p instead of composite modulus N = pq. As in RSA, we would have encryption exponent.

  Dynamic-programming algorithm for rod-cutting problem

Consider a modification of the rod-cutting problem in which, in addition to a price pi for each rod, each cut incurs a fixed cost of c. Give a dynamic-programming algorithm to solve this modified problem.

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