derek-zhou

derek-zhou

Keep in mind that ++ is O(n) so if you try to build up a non trivial list by adding elements to the end, one at a time, it is most likely not the right way.

2
Post #11
lc0815

lc0815 OP

at the risk of sounding like a twit, what is O(n). I seen this before but don’t know what it means…

apologies for such a dumb question but might as well get it out of the way once and for all, LoL

0
Post #12
derek-zhou

derek-zhou

It means the run time of appending is proportional to the the length of the first list. If you are repeatably adding element at the end, then the run time will be 0 + 1 + 2 + .. + n = n*(n-1)/2 or O(n^2)

On the other hand, [d | t] is O(1) constant time. So if you are going to build the same list from scratch, you add to the head, then do a reverse (O(n) and one time) in the end to get the proper order. the run time will be still O(n)

If you still don’t understand, you better check some wikipedia or text books.

2
Post #13
dimitarvp

dimitarvp

Can you give us an idea what are you trying to do?

0
Post #14
lc0815

lc0815 OP

at the time I did not any idea what this code was doing, now I understand it but it’s not something I would use, it’s not clear to some in the group work with. obviously the person that wrote that code is no longer here and the people hare now say “oh he was just crazy”

Crazy… anywho: thanks for the responses, great group…

0
Post #15
— All posts loaded —