this post was submitted on 28 Jan 2024
177 points (100.0% liked)

Programmer Humor

418 readers
32 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
 
top 5 comments
sorted by: hot top controversial new old
[–] YaBoyMax@programming.dev 24 points 8 months ago
[–] 0x0@lemmy.dbzer0.com 10 points 8 months ago

Besides the obvious flaws... is that parameter a list named list, shadowing the list() constructor?

[–] mcmodknower@programming.dev 8 points 8 months ago (1 children)

you can even have a case where you return the first element of the list if the list is not empty, and it will still be O(1).

[–] murtaza64@programming.dev 10 points 8 months ago (1 children)

you can make it sort the first k elements and it will still be O(1). Set k high enough and it might even be useful

[–] kuberoot@discuss.tchncs.de 1 points 8 months ago

By that logic, any sorting implementation is O(1), as the indexing variable/address type has limited size