Question
Must answer in racket ;************************************************************ ; ** problem 1 ** (10 points) ; Write two procedures ; (lorint count bound) ; (time-calls reps proc args)
Must answer in racket
;************************************************************ ; ** problem 1 ** (10 points)
; Write two procedures
; (lorint count bound) ; (time-calls reps proc args)
; (lorint count bound) takes a nonnegative ; integer count and a positive integer bound ; and returns a list of count randomly chosen integers ; in the range from 0 through bound - 1.
; (time-calls reps proc args) takes ; a nonnegative integer, reps, ; a procedure, proc, ; a list of arguments for the procedure, args, ; and returns the amount of time in SECONDS elapsed ; in calling proc on args a number of times equal to reps.
; Recall that we can apply a proc to args with (apply proc args). ; Note that a millisecond is 1/1000 of a second.
; Examples of lorint ;> (lorint 10 100) ;'(49 14 28 15 12 80 33 69 18 57) ;> (lorint 10 3) ;'(0 0 2 1 0 0 1 2 0 1)
; The following examples of time-calls were run on my workstation and ; show that calling the built-in plus procedure 10,000 times on ; the arguments 13 and 14 took somewhat more than 0.001 seconds, ; while doing the same thing 100,000 times took somewhat more ; than 0.01 seconds, and a million times took somewhat more than 0.1 ; seconds. The first two runs show random variation in the measured times.
; When the number of repetitions is multiplied by 10, the time is ; also (approximately) multiplied by 10.
;> (time-calls 10000 + (list 13 14)) ;0.00168701171875 ;> (time-calls 10000 + (list 13 14)) ;0.00122412109375 ;> (time-calls 100000 + (list 13 14)) ;0.012380859375 ;> (time-calls 1000000 + (list 13 14)) ;0.12706494140625
; The following examples show timings (on my workstation) ; for creating lists of 100,000 or 200,000 or 300,000 ; random numbers in the range 0 to 9 inclusive. ; About a third of a second suffices in the last case.
;> (time-calls 1 lorint (list 100000 10)) ;0.074503173828125 ;> (time-calls 1 lorint (list 200000 10)) ;0.19560009765625 ;> (time-calls 1 lorint (list 300000 10)) ;0.33381982421875 ;******************************(******************************
(define (lorint count bound) "lorint is not defined yet")
(define (time-calls reps proc args) "time-calls is not defined yet")
;************************************************************
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started