CS 112
Lecture 15
Finish Recursion
- Simple recursive definitions for: finding the minimum,
searching an element in an array, sequentially and by binary
search; adding all elements of an
array. Here is
Sum, a function
to add all the numbers in an array a. If n is 0, it returns a[0].
Otherwise, it adds a[n] to the
sum of the first (n-1) elements, computed recursively.
- Quick Sort, a "divide-and-conquer" recursive algorithm
for sorting. I will explain it, then you will implemet it as
part of your next homework.
Queues
Our next data structure is the queue. I will describe in
class the basic functionality of the queue, then you start
working on it. It will be part of your next homework assignement.
Ileana Streinu