[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Length implementation
- From: "Soni L." <fakedme@...>
- Date: Fri, 12 May 2017 16:39:51 -0300
Lua has O(logn) length and searches from the end:
Lua 5.3.4 Copyright (C) 1994-2017 Lua.org, PUC-Rio
for i,v in ipairs(t) do t[i]=nil end
for i=8,1,-1 do t[i]=1 print(#t) t[i]=nil end
Pretty, isn't it?
I'm not sure what the time complexity of t[#t+1]=v vs t[i]=v is... I
know the latter is O(n), but the former doesn't seem to be O(n log n)...
O(n log log n) maybe?
Disclaimer: these emails may be made public at any given time, with or without reason. If you don't agree with this, DO NOT REPLY.