this post was submitted on 28 Jan 2024
280 points (95.5% liked)

Programmer Humor

18971 readers
743 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
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 9 points 6 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).

[–] [email protected] 12 points 6 months ago (2 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

[–] [email protected] 5 points 6 months ago

I set k to 50,000,000,000... that's more items than my shitty computer can fit in memory (including swsp) but I am now happy to celebrate my O(1) algorithm.

[–] [email protected] 1 points 6 months ago

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