Question 2: For function f below: a. Provide the running time T(n). Provide the order of growth (Big-O). b. Assume v is an array, and assume that each of the operators ‘aref', ':=', 'length', and '+'take 1 (one) unit of running time. You may ignore the running time of the loop test. (defun f (a) (let ((b (aref a 10)) (z 8) (y 0) (n (length a)) (dotimes (i n) ; loop stop test (: z (aref a i)) (:= y (+ z 8)))))

icon
Related questions
Question

(Q2) This is a Data Structures problem and the programming language used is Lisp. Solve the question we detailed steps and make it concise and easy to understand. Please and thank you.

Question 2:
For function f below:
a.
Provide the running time T(n).
Provide the order of growth (Big-O).
b.
Assume v is an array, and assume that each of the operators 'aref', ':=', ‘length',
and '+' take 1 (one) unit of running time. You may ignore the running time of
the loop test.
(defun f (a)
(let ((b (aref a 10))
(z 8)
(y 0)
(n (length a))
(dotimes (i n) ; loop stop test
(:= z (aref a i))
(:= y (+ z 8)))))
Transcribed Image Text:Question 2: For function f below: a. Provide the running time T(n). Provide the order of growth (Big-O). b. Assume v is an array, and assume that each of the operators 'aref', ':=', ‘length', and '+' take 1 (one) unit of running time. You may ignore the running time of the loop test. (defun f (a) (let ((b (aref a 10)) (z 8) (y 0) (n (length a)) (dotimes (i n) ; loop stop test (:= z (aref a i)) (:= y (+ z 8)))))
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer