Uploaded by Karthik Vinayagamurthi

Data Structures & Algorithms Worksheet 2

advertisement
CMPSC 465
Spring 2025
Data Structures & Algorithms
Maksym Lupei and Chunhao Wang
Worksheet 2
Wednesday, January 29, 2025
1. Multiplying Numbers with Basic (Naive) D&C Algorithm
Given two numbers X = 987 and Y = 765, split these numbers into two parts for the Karatsuba algorithm.
2. Multiplying Numbers with Karatsuba Algorithm
Using X = 392 and Y = 1938, compute the intermediate products P1 , P2 , and P3 for the Karatsuba
algorithm.
3. Comparing the Time Complexity of Multiplication Algorithms
Explain why the Karatsuba algorithm has a time complexity of O(nlog2 3 ) and compare it to the traditional O(n2 ) method.
What are the running times of each of these algorithms (in big-O notation), and which would you choose as
the fastest?
4. Sort array with Mergesort:
[1,23,34,1,7,2,112,234,131,1]
CMPSC 465, Spring 2025, Worksheet 2
1
Download