Question

Q9. Problem-solving techniques (a) Describe the basic principles and efficient operation of the problem-solving technique di

Hi, This question is from python unit

0 0
Add a comment Improve this question Transcribed image text
Answer #1

(a)Basic principle of Divide and conquer
step-1 Break the given problem into smaller subproblems of same type.
step-2 Recursively solve these smaller subproblems
step-3 Appropriately combine the answers of subproblem to get answer of main problem.


(b)Take an example to find maximum element in given list using divide and conquer technique.
For this problem,we first divide problem into two smaller subproblems.
find maximum element in both subproblem and return maximum of them.

#Python Program
def findMax(low,high,list1):
if low==high:
return list1[low]
mid = (low + high)//2
max1 = findMax(low,mid,list1)
max2 = findMax(mid+1,high,list1)
if max1>max2:
return max1
else:
return max2

list1 = [5,1,7,9,10,15,2]

print("Maximum element in list1 is ", findMax(0,len(list1)-1,list1))

#Screenshots

File Edit Format Run Options Window Help def findMax (low, high, listi): if low==high: return listi[low] mid = (low + high) /

Add a comment
Know the answer?
Add Answer to:
Hi, This question is from python unit Q9. Problem-solving techniques (a) Describe the basic principles and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT