GradePack

    • Home
    • Blog
Skip to content
bg
bg
bg
bg

GradePack

Suppose you have the following function and another function…

Suppose you have the following function and another function — moo(m) (not shown) — that runs in O(log n). What is the Big‑O runtime of the goo function shown below? def goo(widgets: list[Widget]) -> None:    for x in widgets:        moo(x)

Read Details

Consider the following “odd” implementation of a list contai…

Consider the following “odd” implementation of a list contains method: def bizarre_contains(a: list[float], key: float) -> bool:    for i in range(0, len(a)):        if key in a:           return True     return False What’s the Big O runtime for bizzare_contains?

Read Details

You are adding an item to the middle of a python list. What’…

You are adding an item to the middle of a python list. What’s the Big O?

Read Details

The root node of a binary tree is any node in which ________…

The root node of a binary tree is any node in which ______________

Read Details

Which sorting algorithm sorts selects the next item, finds a…

Which sorting algorithm sorts selects the next item, finds and inserts it into the correct position in the sorted sequence of the list? 

Read Details

Given an ordered list with 15 elements, how many elements mu…

Given an ordered list with 15 elements, how many elements must be visited in the worst case of binary search?

Read Details

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 Details

The 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 Details

Consider 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 Details

Suppose 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 Details

Posts pagination

Newer posts 1 … 1,891 1,892 1,893 1,894 1,895 … 86,275 Older posts

GradePack

  • Privacy Policy
  • Terms of Service
Top