3. Implement an algorithm using divide and conquer technique: Given two sorted arrays of size m and n respectively, find
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
3. Implement an algorithm using divide and conquer technique: Given two sorted arrays of size m and n respectively, find
3. Implement an algorithm using divide and conquer technique: Given two sorted arrays of size m and n respectively, find the element that would be at the kth position in combined sorted array. Write a pseudocode/describe your strategy for a function kthelement(Arr1, Arr2, k) that uses the concepts mentioned in the divide and conquer technique. The function would take two sorted arrays Arr1, Arr2 and position k as input and returns the element at the kth position in the combined sorted array. b. Implement the function kthElement(Arr1, Arr2, k) that was written in part a. Name your file Kth Element.py Examples: Arr1 = [1,2,3,5,6] ; Arr2= [3,4,5,6,7] ; k= 5 Returns: 4 Explanation: 5th element in the combined sorted array [1,2,3,3,4,5,5,6,6,7] is 4