This is a course web page of David Casperson |
|
Generally speaking, questions that have been assigned but not yet give a due date can be found on this page. Questions that have been given a due date can be found here. There is now homework due.
#lang racket (define (fred) (define x 64) (define ichabod (gertrude)) (ichabod 5)) (define (gertrude) (define x 32) (define (harriet y) (+ x y)) harriet) (module+ main (displayln (format "(fred) returns ~v" (fred))) )
Consider the Racket program shown to the right:
x
by a globally defined parameter,
and recode the example to illustrate dynamic binding.
Consider the Java code shown in Figure 3. This is the partitioning algorithm from Quick sort.
Figure 3public static <E extends Comparable<E>> void partition(E [] data, E key, Box<Integer> cut) { int left = -1 ; int right = data.length ; while(left<right) { do {++left ; } while (data[left ].compareTo(key)<0) ; do {--right ; } while (data[right].compareTo(key)>0) ; if (left<right) swap(data,left,right) ; } cut.set(left) ; }
while
-loop?
do
-while
loop.
do
-while
loop. What condition needs to be true for the loop to terminate?
data
modified by
this routine?
Explain.
cut
argument?
Why isn't this just passed back as an int
?
fall-2024