Jump to page: 1 212  
Page
Thread overview
Complexity nomenclature
Dec 04, 2015
Jack Stouffer
Dec 04, 2015
Timon Gehr
Dec 04, 2015
Timon Gehr
Dec 04, 2015
Andrea Fontana
Dec 04, 2015
Timon Gehr
Dec 04, 2015
Timon Gehr
Dec 04, 2015
Timon Gehr
Dec 04, 2015
Timon Gehr
Dec 04, 2015
Xinok
Dec 04, 2015
Timon Gehr
Dec 04, 2015
Idan Arye
Dec 04, 2015
Jack Stouffer
Dec 04, 2015
Tofu Ninja
Dec 04, 2015
Jakob Ovrum
Dec 04, 2015
ZombineDev
Dec 04, 2015
Jonathan M Davis
Dec 04, 2015
ref2401
Dec 04, 2015
Jack Stouffer
Dec 04, 2015
Timon Gehr
Dec 04, 2015
Timon Gehr
Dec 05, 2015
Timon Gehr
Dec 05, 2015
Timon Gehr
Dec 05, 2015
BLM768
Dec 05, 2015
H. S. Teoh
Dec 06, 2015
BLM768
Dec 06, 2015
Timon Gehr
Dec 06, 2015
BLM768
Dec 06, 2015
Timon Gehr
Dec 06, 2015
tsbockman
Dec 06, 2015
Timon Gehr
Dec 06, 2015
Timon Gehr
Dec 06, 2015
Timon Gehr
Dec 06, 2015
Timon Gehr
Dec 06, 2015
Timon Gehr
Dec 07, 2015
Timon Gehr
Dec 07, 2015
Timon Gehr
Dec 07, 2015
Timon Gehr
Dec 08, 2015
ZombineDev
Dec 10, 2015
Jonny
Dec 07, 2015
Timon Gehr
Dec 07, 2015
Timon Gehr
Mar 17, 2016
Nordlöw
Dec 04, 2015
H. S. Teoh
Dec 04, 2015
H. S. Teoh
Dec 04, 2015
Dmitry Olshansky
Dec 04, 2015
Walter Bright
Dec 04, 2015
Minas Mina
Dec 04, 2015
H. S. Teoh
Dec 04, 2015
Walter Bright
Dec 05, 2015
Dmitry Olshansky
Dec 04, 2015
Walter Bright
Dec 04, 2015
tn
Dec 04, 2015
Jakob Ovrum
Dec 04, 2015
tn
Dec 04, 2015
tn
Dec 04, 2015
Idan Arye
Dec 04, 2015
Walter Bright
Dec 04, 2015
Minas Mina
Dec 04, 2015
ZombineDev
Dec 04, 2015
ZombineDev
Dec 04, 2015
ZombineDev
Dec 04, 2015
Jonathan M Davis
Dec 04, 2015
CraigDillabaugh
Dec 04, 2015
Jonathan M Davis
Dec 04, 2015
Walter Bright
Dec 04, 2015
BLM768
Dec 04, 2015
Jonathan M Davis
Dec 05, 2015
BLM768
Dec 05, 2015
BLM768
Dec 09, 2015
Jonny
Mar 17, 2016
Nordlöw
December 03, 2015
Consider the collections universe. So we have an imperative primitive like:

c.insertAfter(r, x)

where c is a collection, r is a range previously extracted from c, and x is a value convertible to collection's element type. The expression imperatively inserts x in the collection right after r.

Now this primitive may have three complexities:

* linear in the length of r (e.g. c is a singly-linked list)

* linear in the number of elements after r in the collection (e.g. c is an array)

* constant (c is a doubly-linked list)

These complexities must be reflected in the name of the primitives. Or perhaps it's okay to conflate a couple of them. I know names are something we're awfully good at discussing :o). Destroy!


Andrei
December 04, 2015
On Friday, 4 December 2015 at 01:27:42 UTC, Andrei Alexandrescu wrote:
> These complexities must be reflected in the name of the primitives.

I don't see why. IMO, names should convey what the function does, not how it does it. Complexity is usually put in the function documentation in Phobos when it's not constant, especially for range based ones, I don't see a reason to change that.
December 04, 2015
On 12/04/2015 02:27 AM, Andrei Alexandrescu wrote:
> Consider the collections universe. So we have an imperative primitive like:
>
> c.insertAfter(r, x)
>
> where c is a collection, r is a range previously extracted from c, and x
> is a value convertible to collection's element type. The expression
> imperatively inserts x in the collection right after r.
>
> Now this primitive may have three complexities:
>
> * linear in the length of r (e.g. c is a singly-linked list)
>
> * linear in the number of elements after r in the collection (e.g. c is
> an array)
>
> * constant (c is a doubly-linked list)
>
> These complexities must be reflected in the name of the primitives. Or
> perhaps it's okay to conflate a couple of them. I know names are
> something we're awfully good at discussing :o). Destroy!
>
>
> Andrei

Regarding nomenclature, it would be awesome if we could call this "running time" instead of "complexity". Algorithms have running times and memory usages. Problems have (time and space) complexities. I know that calling running time 'complexity' is awfully popular outside of actual complexity theory papers. I don't really understand what calling it 'complexity' actually buys though.
December 04, 2015
On Friday, 4 December 2015 at 01:27:42 UTC, Andrei Alexandrescu wrote:
> Consider the collections universe. So we have an imperative primitive like:
>
> c.insertAfter(r, x)
>
> where c is a collection, r is a range previously extracted from c, and x is a value convertible to collection's element type. The expression imperatively inserts x in the collection right after r.
>
> Now this primitive may have three complexities:
>
> * linear in the length of r (e.g. c is a singly-linked list)
>
> * linear in the number of elements after r in the collection (e.g. c is an array)
>
> * constant (c is a doubly-linked list)
>
> These complexities must be reflected in the name of the primitives. Or perhaps it's okay to conflate a couple of them. I know names are something we're awfully good at discussing :o). Destroy!
>
>
> Andrei

The complexities of the operations is a property of the data structure being used. If each collection type will have it's own set of method names based on the complexity of operations on it, we won't be able to have templated functions that operate on any kind of collection(or at the very least, these functions will be really tedious to code).
December 03, 2015
On 12/03/2015 08:37 PM, Jack Stouffer wrote:
> On Friday, 4 December 2015 at 01:27:42 UTC, Andrei Alexandrescu wrote:
>> These complexities must be reflected in the name of the primitives.
>
> I don't see why. IMO, names should convey what the function does, not
> how it does it. Complexity is usually put in the function documentation
> in Phobos when it's not constant, especially for range based ones, I
> don't see a reason to change that.

Complexity is part of the semantics, and in my design names and their semantics go hand in hand. -- Andrei

December 03, 2015
On 12/03/2015 08:55 PM, Timon Gehr wrote:
> I don't really understand what calling it 'complexity' actually buys
> though.

Instant understanding by everyone. -- Andrei
December 03, 2015
On 12/03/2015 09:10 PM, Idan Arye wrote:
> The complexities of the operations is a property of the data structure
> being used. If each collection type will have it's own set of method
> names based on the complexity of operations on it, we won't be able to
> have templated functions that operate on any kind of collection(or at
> the very least, these functions will be really tedious to code).

Your premise is right but you reach the negation of the correct conclusion. -- Andrei
December 04, 2015
On 12/04/2015 03:18 AM, Andrei Alexandrescu wrote:
> On 12/03/2015 08:37 PM, Jack Stouffer wrote:
>> On Friday, 4 December 2015 at 01:27:42 UTC, Andrei Alexandrescu wrote:
>>> These complexities must be reflected in the name of the primitives.
>>
>> I don't see why. IMO, names should convey what the function does, not
>> how it does it. Complexity is usually put in the function documentation
>> in Phobos when it's not constant, especially for range based ones, I
>> don't see a reason to change that.
>
> Complexity is part of the semantics, and in my design names and their
> semantics go hand in hand. -- Andrei
>

Which is sensible. But in any given context, some parts of the semantics are usually abstracted away. Sometimes one wants to abstract over running times of called methods. ("This function calls this other function at most O(n) times.")
December 04, 2015
On 12/04/2015 03:19 AM, Andrei Alexandrescu wrote:
> On 12/03/2015 08:55 PM, Timon Gehr wrote:
>> I don't really understand what calling it 'complexity' actually buys
>> though.
>
> Instant understanding by everyone. -- Andrei

Well, no. "running time" is actually more descriptive.
December 04, 2015
On Friday, 4 December 2015 at 01:55:15 UTC, Timon Gehr wrote:
> Regarding nomenclature, it would be awesome if we could call this "running time" instead of "complexity". Algorithms have running times and memory usages. Problems have (time and space) complexities. I know that calling running time 'complexity' is awfully popular outside of actual complexity theory papers. I don't really understand what calling it 'complexity' actually buys though.

I've seen you mention this before, and while you may be correct, the term "complexity" is so widely applied to algorithms that it's not worth going against the norm. For the vast majority of computer scientists, when they hear the term "time complexity", they immediately understand it as running time. In fact, what I've seen most often is that algorithms have complexities and problems fall into a *complexity class*. For example, just take a look at the Wikipedia page on time complexity:

https://en.wikipedia.org/wiki/Time_complexity
« First   ‹ Prev
1 2 3 4 5 6 7 8 9 10 11