From owner-freebsd-hackers@freebsd.org Sat Nov 26 17:14:13 2016 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 20C0CC579D8 for ; Sat, 26 Nov 2016 17:14:13 +0000 (UTC) (envelope-from adf@idi.ntnu.no) Received: from hylle05.itea.ntnu.no (hylle05.itea.ntnu.no [IPv6:2001:700:300:3::225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D6F121BF2 for ; Sat, 26 Nov 2016 17:14:12 +0000 (UTC) (envelope-from adf@idi.ntnu.no) Received: from localhost (localhost [127.0.0.1]) by hylle05.itea.ntnu.no (Postfix) with ESMTP id A147A907151; Sat, 26 Nov 2016 18:14:08 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at hylle05.itea.ntnu.no Received: from [10.10.10.166] (unknown [109.201.137.162]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: adf) by hylle05.itea.ntnu.no (Postfix) with ESMTPSA id CE8EE907134; Sat, 26 Nov 2016 18:14:07 +0100 (CET) Subject: Re: qsort switching to insertsort Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Content-Type: text/plain; charset=utf-8 From: =?utf-8?Q?Arne_Dag_Fidjest=C3=B8l?= In-Reply-To: Date: Sat, 26 Nov 2016 18:14:06 +0100 Cc: Tristan Verniquet , Hans Petter Selasky , freebsd hackers Content-Transfer-Encoding: quoted-printable Message-Id: References: <0bfb49b0-5d24-2766-6982-b4e49b0d5e81@selasky.org> To: Mehmet Erol Sanliturk X-Mailer: Apple Mail (2.3124) X-Mailman-Approved-At: Sat, 26 Nov 2016 17:45:21 +0000 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Nov 2016 17:14:13 -0000 > On 26 Nov 2016, at 15:35, Mehmet Erol Sanliturk = wrote: >=20 > In quick sort , it is necessary to check worst case and switch to = another > sort method if it is detected . > When this is not done , end result is stack overflow , etc . , but not > success . > Therefore , it is not possible to eliminate an alternative sort method = . I you sort the smaller partition recursively first, and then sort the = larger partition either by tail recursion or iteration, you will only = consume O(log n) of stack, so stack overflow needn=E2=80=99t be an = issue, regardless of the input. -adf=