a13e
a13e

Reputation: 928

Why do we use the term "non-descending" instead of "ascending" in sorting algorithms?

In the sorting algorithms like heapsort or quicksort, why do standard publications or research papers prefer the term "non-descending" or "non-ascending" when they can simply use ascending or descending respectively? I mean anyways the meaning is going to be the same.

Upvotes: 9

Views: 8159

Answers (3)

Prayskey
Prayskey

Reputation: 1

It means that the integers in the data structure are increasing, but there are possibilities of adjacent integers i.e [1,2,3,3,4]. When the integers ascends or descends, they do not repeat.

Upvotes: 0

Paul Hankin
Paul Hankin

Reputation: 58339

Non-ascending (and non-descending) include the possibility of adjacent terms being equal. [1, 2, 2] is non-descending, but isn't ascending.

But the publications you are reading probably define their terms.

Upvotes: 19

Chris Cousins
Chris Cousins

Reputation: 1912

"Ascending" is where for all elements 0 through length-2 as i in the array, element i+1 > element i. "Non-descending" means element i+1 >= element i rather than just greater than.

Upvotes: 3

Related Questions