8000 Solution of the problem 5-2.(a) seems to be incorrect · Issue #534 · walkccc/CLRS · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Solution of the problem 5-2.(a) seems to be incorrect #534
Open
@KnightChaser

Description

@KnightChaser

Problem location: https://walkccc.me/CLRS/Chap05/Problems/5-2/ (Chapter 5, 5-2.a)

The answer in the given solution is like below.

RANDOM-SEARCH(x, A, n)
    v = Ø
    while |Ø| != n
        i = RANDOM(1, n)
        if A[i] = x
            return i
        else
            v = v ∩ i
    return NIL

However, v ∩ i would imply taking the intersection between v and i, which doesn't make sense since i is not a set, it's just a number taken from RANDOM(1, n). I expect it should be corrected to v = v ∪ {i} or v.add(i) to add i to the set v.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0