English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Keeping a sorted list vs sorting at the end?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-08-20 (09:59)
From: Oliver Bandel <oliver@f...>
Subject: Re: [Caml-list] Keeping a sorted list vs sorting at the end?
On Sat, Aug 19, 2006 at 08:57:02PM -0700, jean-david hsu wrote:
> Just wondering on the average if it is more efficient to take time to 
> keep a list sorted as we insert or simply sort the list at the end?

Sort list at the end.
If you want to sort at insertion time, then
trees are the better technique.

In OCaml there are the Set and the Map module, which
may be useful to you.

It depends on what you want to do, what kind of datastructure/module
is best suited.