PA6_Recurrence

# 5 1 2 3 4 5 what the original array looked like public

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 3 4 Goal: Reach a base case where there is only one element or zero elements left to recurse on. 5 1 2 3 4 5 What the original array looked like public void reverse(int originalArray, int low, int high) 1 Middle Values to swap Goal: Reach a base case where there is only one element or zero elements left to recurse on. 5 1 2 3 4 5 What the original array looked like public void reverse(int originalArray, int low, int high) Next, increment and decrement your low/high indices and recurse onto a smaller problem 5 Middle 1 Array we are passing to the next recursive call Goal: Reach a base case where there is only one element or zero elements left to recurse on. 1 2 3 4 5 What the original array looked like public void reverse(int originalArray, int low, int high) 2 Middle 4 Values to swap Goal: Reach a base case where there is only one element or zero elements left to recurse on. 1 2 3 4 5 What the original array looked like public void reverse(int originalArray, int low, int high) Next, update low/high and recurse onto a smaller problem 2 Middle 4 Array we are passing to the next recursive call Goal: Reach a base case where there is only one element or zero elements left to recurse on. 1 2 3 4 5 What the original array looked like public void reverse(int originalArray, int low, int high) 3 There is only one element left, which satisfies our base case. Now we can return this array as the middle of the previous array. Goal: Reach a base case where there is only one element or zero elements left to recurse on. 1 2 3 4 5 Wh...
View Full Document

## This note was uploaded on 03/13/2014 for the course CSE 11 taught by Professor Staff during the Spring '08 term at UCSD.

Ask a homework question - tutors are online