|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
how do i solve this Algorithm, proof by induction?
let the array be: a
and the array is an array of integers n+1 such that. a[1] <= a[0] and a[n - 1] <= a[n] how do i deduce that a must contain a local minimum in a[1]....a[n-1]. (a[k] is a local minimum if it satisfies) a[k] <= a[k - 1] and a[k] <= a[k + 1] i'm not sure but do i have to do it by proof by induction. can anyone help please? |
|
#2
|
|||
|
|||
|
This is a regular math problem, not an algorithm
![]() If a[1] is not a local minimum, it is a "decreasing point" (what does this mean?). Since the array is finite, there is a largest k such that a[k] is a decreasing point. k < n-1 (why?). What are the possibilities for a[k+1]? That's an outline of one possible proof. I left it incomplete; it's best for you to fill the gaps yourself. I hope that helps. |
|
#3
|
|||
|
|||
|
Thanks
many thanks!
|
|
#4
|
|||
|
|||
|
Quote:
order(In calculas we say function is increasing) =>a[1]>a[0],a[2]>a[1].............a[n]>a[n-1] =>our assumption is wrong... Take the second case let the array be in decreasing order =>a[1]<a[0],a[2]<a[1].......a[n]<a[n-1] =>our assumption is wrong... So the array is decreasing in some range and increasing in some range . In this case it is decreasing initially and then increasing So there is a local minima... The problem can be converted for local maxima also Such proofs are called as prooving by contradiction |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Software Design > how do i solve this Algorithm, proof by induction? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|