From c4ffd7746cbd9ec9386adc4a8fc79d09c8d647c0 Mon Sep 17 00:00:00 2001 From: Stephen Adams Date: Wed, 3 Nov 1993 22:57:59 +0000 Subject: [PATCH] Fixed typos in wt-tree documentation --- v7/doc/ref-manual/scheme.texinfo | 210 ++++++++++++++++--------------- 1 file changed, 106 insertions(+), 104 deletions(-) diff --git a/v7/doc/ref-manual/scheme.texinfo b/v7/doc/ref-manual/scheme.texinfo index 8b9ca6bc9..992516cb3 100644 --- a/v7/doc/ref-manual/scheme.texinfo +++ b/v7/doc/ref-manual/scheme.texinfo @@ -2,7 +2,7 @@ @iftex @finalout @end iftex -@comment $Id: scheme.texinfo,v 1.33 1993/11/03 03:37:26 adams Exp $ +@comment $Id: scheme.texinfo,v 1.34 1993/11/03 22:57:59 adams Exp $ @comment %**start of header (This is for running Texinfo on a region.) @setfilename scheme @settitle MIT Scheme Reference @@ -8740,12 +8740,10 @@ with a good constant factor. @item @dfn{Weight-Balanced trees} are a kind of balanced binary. The -implementation supports non-destructive operations. For insertion and -deletion the implementation is slower than Red-Black trees but weight -balanced trees support a constant time size operation, and many -high-level operations such as the set operations union, intersection and -difference, and indexing of elements by position are implememted -efficiently. +implementation provides non-destructive operations. There is a +comprehensive set of operations including a constant time size +operation, many high-level operations such as the set operations union, +intersection and difference, and indexing of elements by position. @end itemize @@ -9063,7 +9061,7 @@ customizable growth parameters, and customizable hash procedures. The average times for the insertion, deletion, and lookup operations on a hash table are bounded by a constant. The space required by the table -is linearly proportional to the number of associations in the table; the +is proportional to the number of associations in the table; the constant of proportionality is described below (@pxref{Resizing of Hash Tables}). @@ -9262,13 +9260,13 @@ Returns the contents of @var{hash-table} as a newly allocated alist. Each element of the alist is a pair @code{(@var{key} . @var{datum})} where @var{key} is one of the keys of @var{hash-table}, and @var{datum} is its associated datum. The average and worst-case times required by -this operation are linearly proportional to the number of associations +this operation are linear in the number of associations in the table. @end deffn @deffn {procedure+} hash-table/key-list hash-table Returns a newly allocated list of the keys in @var{hash-table}. The -average and worst-case times required by this operation are linearly +average and worst-case times required by this operation are proportional to the number of associations in the table. @end deffn @@ -9277,7 +9275,7 @@ Returns a newly allocated list of the datums in @var{hash-table}. Each element of the list corresponds to one of the associations in @var{hash-table}; if the table contains multiple associations with the same datum, so will this list. The average and worst-case times -required by this operation are linearly proportional to the number of +required by this operation are proportional to the number of associations in the table. @end deffn @@ -9423,12 +9421,12 @@ The default rehash size of a newly constructed hash table is @code{2.0}. size is almost always undesirable; this option is provided solely for compatibility with the Common Lisp hash-table mechanism. The reason for this has to do with the time penalty for resizing the hash table. The -time needed to resize a hash table is linearly proportional to the +time needed to resize a hash table is proportional to the number of associations in the table. This resizing cost is @dfn{amortized} across the insertions required to fill the table to the point where it needs to grow again. If the table grows by an amount -linearly proportional to the number of associations, then the cost of -resizing and the increase in size are both linearly proportional to the +proportional to the number of associations, then the cost of +resizing and the increase in size are both proportional to the number of associations, so the @dfn{amortized cost} of an insertion operation is still bounded by a constant. However, if the table grows by a constant amount, this is not true: the amortized cost of an @@ -9764,7 +9762,7 @@ have two advantages over hash tables: @itemize @bullet @item The contents of a binary tree can be converted to an alist, sorted by -key, in time linearly proportional to the number of associations in the +key, in time proportional to the number of associations in the tree. A hash table can be converted into an unsorted alist in linear time; sorting it requires additional time. @@ -9844,16 +9842,16 @@ Returns the contents of @var{rb-tree} as a newly allocated alist. Each element of the alist is a pair @code{(@var{key} . @var{datum})} where @var{key} is one of the keys of @var{rb-tree}, and @var{datum} is its associated datum. The alist is sorted by key according to the -@var{keyrb-tree alist key=? keyalist tree) - (fold (lambda (key datum list) (cons (cons key datum) list)) - '() - tree)) +(fold (lambda (key datum list) + (cons (cons key datum) list)) + '() + @var{wt-tree})) @end example The data in the associations can be summed like this: @example -(define (sum-wt-tree-data tree) - (fold (lambda (key datum sum) (+ sum datum)) 0 tree) +(fold (lambda (key datum sum) (+ sum datum)) 0 @var{wt-tree}) @end example @end deffn - @deffn {procedure+} wt-tree/for-each action wt-tree This procedure traverses the tree in-order, applying @var{action} to each association. @@ -10334,9 +10334,9 @@ Provided @var{action} takes time bounded by a constant, The example prints the tree: @example -(define (print-tree tree) - (for-each (lambda (key value) (display (list key value))) - tree)) +(for-each (lambda (key value) + (display (list key value))) + @var{wt-tree})) @end example @end deffn @@ -10357,7 +10357,7 @@ sorted sequence under the tree's ordering relation on the keys. @code{wt-tree/index} returns the @var{index}th key, @code{wt-tree/index-datum} returns the datum associated with the @var{index}th key and @code{wt-tree/index-pair} returns a new pair -@code{(@var{key} . @var{datum})} which is the @code{cons} of the minimum +@code{(@var{key} . @var{datum})} which is the @code{cons} of the @var{index}th key and its datum. The average and worst-case times required by this operation are proportional to the logarithm of the number of associations in the tree. @@ -10366,11 +10366,13 @@ These operations signal an error if the tree is empty, if @var{index}@code{<0}, or if @var{index} is greater than or equal to the number of associations in the tree. -Indexing can be used to find the median key in the tree as follows: +Indexing can be used to find the median and maximum keys in the tree as +follows: @example -(define (median tree) - (wt-tree/index tree (quotient (wt-tree/size tree) 2))) +median: (wt-tree/index @var{wt-tree} (quotient (wt-tree/size @var{wt-tree}) 2)) + +maximum: (wt-tree/index @var{wt-tree} (-1+ (wt-tree/size @var{wt-tree}))) @end example @end deffn @@ -10390,7 +10392,7 @@ Returns the association of @var{wt-tree} that has the least key under the tree's @code{wt-tree/min} returns the least key, @code{wt-tree/min-datum} returns the datum associated with the least key and @code{wt-tree/min-pair} returns a new pair -@code{(key . datum) }which is the @code{cons} of the key and the datum. +@code{(key . datum)} which is the @code{cons} of the minimum key and its datum. The average and worst-case times required by this operation are proportional to the logarithm of the number of associations in the tree. -- 2.25.1