   Chapter 11.5, Problem 24ES ### Discrete Mathematics With Applicat...

5th Edition
EPP + 1 other
ISBN: 9781337694193

#### Solutions

Chapter
Section ### Discrete Mathematics With Applicat...

5th Edition
EPP + 1 other
ISBN: 9781337694193
Textbook Problem
1 views

# Show that given an array a [ b o t ] ,   a [ b o t + 1 ] ,   … ,   a [ t o p ] of length k. if mid = ⌊ ( b o t + t o p ) / 2 ⌋ thena. the subarray a [ m i d + 1 ] ,   a [ m i d + 2 ] ,   … ,   a [ t o p ] has length ⌊ k / 2 ⌋ .b. the subarray a [ b o t ] ,   a [ b o t + 1 ] ,   … ,   a [ m i d ] has length ⌊ k / 2 ⌋ .

To determine

(a)

Show that given an array a[bot],a[bot+1],...,a[top] of length k, if mid=(bot+top)/2 then the subarray a[mid],a[mid+1],...,a[top] has length k/2.

Explanation

Given information:

an array a[bot],a[bot+1],...,a[top] of length k.

Proof:

The array a[bot],a[bot+1],...,a[top] has length k and thus a[bot],a[bot+1],...,a[top] contains k elements.

By the number of elements in a list theorem, we also know that the number of integers from bot to top top is top − bot + 1 and thus a[bot],a[bot+1],...,a[top] contains top + bot − 1 elements.

top+bot1=k

We then assign mid to the lower of the two middle indices of the array.

mid=bot+top2

By the number of the elements in a list theorem, we also know that the number of integers from mid + 1 to top top is top − ( mid + 1) − 1 = top − mid and thus a[mid+1],a[mid+2],...,a[top] contains top − mid elements.

Length array = top − mid

=topbot+top2

=topk+12                                                         top+bot1=k

=kk+12                                  top is the kth element in the array

FIRST CASE: k even

If k is even, then k

To determine

(b)

Show that given an array a[bot],a[bot+1],...,a[top] of length k, if mid=(bot+top)/2 then subarray a[bot],a[bot+1],...,a[mid] has length k/2.

### Still sussing out bartleby?

Check out a sample textbook solution.

See a sample solution

#### The Solution to Your Study Problems

Bartleby provides explanations to thousands of textbook problems written by our experts, many with advanced degrees!

Get Started 