Consider the following recursive function: def r(xs: list[in…
Consider the following recursive function: def r(xs: list[int]) -> list[int]: match xs: case []: return [] case [x]: return [x] case [first, second, *rest]: return [first] + r(rest) + [second] What list will r([1, 2, 3, 4]) return?
Read DetailsThe function at_least returns True if at least two values in…
The function at_least returns True if at least two values in a list of booleans are True. Provide the Big‑O running time for the following function. def at_least( arr: list[bool] ) -> None: count = 0 for i in range(0, len(arr)): if arr[i] == True: count += 1 return count >= 2
Read DetailsConsider the following recursive function: def p(xs: list[in…
Consider the following recursive function: def p(xs: list[int]) -> list[int]: match xs: case []: return [] case [x]: return [x] case [first, second, *rest]: return p(rest) + [first, second] What list will p([1, 2, 3, 4, 5]) return?
Read DetailsSuppose you want a recursive function, product(xs: list[int]…
Suppose you want a recursive function, product(xs: list[int]) -> int, that multiplies all the numbers it’s passed. Imagine the implementation — what do you suppose the base case for the product(..) function should return if [] is matched?
Read DetailsConsider the selection sort function and function call shown…
Consider the selection sort function and function call shown below: note: minimumPosition(values, i) returns the index of the smallest value in the values list starting from i (inclusive) def selectionSort(values: list[int]) -> None : for i in range(len(values)) : print(values) minPos = minimumPosition(values, i) swap(values, minPos, i) data = [1, 2, 3]selectionSort(data)print(data) What is displayed when this code segment executes?
Read DetailsDuring routine radiographic procedures, when a protective ap…
During routine radiographic procedures, when a protective apron is not being used, occupational personnel should place the primary dosimeter at the front of the body at the collar level to approximate the location of maximal radiation dose to which of the following body parts?
Read Details