Question: (30 pts.) Pseudocode and runtime analysis Consider the following simple procedure for filtering out all elements of a list which are within a given distance

(30 pts.) Pseudocode and runtime analysis Consider the following simple procedure for filtering out all elements of a list which are within a given distance d of the largest element: 1: function DELETE-CLOSE-TO-MAX(a list A of n integers, d > 0) 2: Find the largest elemente in A 3: Remove all elements of A which are > e-d 4: return A This is a high-level description, which could be implemented in different ways depending on the data struc- ture used to represent A. (a) If we represent A as a linked list, what is the asymptotic runtime of this procedure? (b) Suppose we instead represent A as an array, i.e., we use an integer l to keep track of the length of A, and store the list elements as A(O),...,All - 1) (with any values from index lonward being unused). If we then implement line 3 by iterating through the array and performing a deletion operation whenever the value is e-d, what will be the asymptotic runtime of the entire procedure? Make sure to justify your answer (c) Assuming the array representation in part (b), give detailed pseudocode showing a different way to implement line 3 which runs in linear time
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
