C Library Functions - tree_insert (3)
NAME
tree_insert(3f) - [M_sort:sort:treesort] sort a number of integers by building a
tree, sorted in infix order
(LICENSE:MIT)
CONTENTS
Synopsis
Description
Author
Examples
SYNOPSIS
subroutine tree_insert(t,number)
type(tree_node), pointer :: t
integer :: number
DESCRIPTION
Sorts a number of integers by building a tree, sorted in infix order.
This sort has expected behavior n log n, but worst case (input is
sorted) n ** 2.
AUTHOR
Copyright (c) 1990 by Walter S. Brainerd, Charles H. Goldberg,
and Jeanne C. Adams. This code may be copied and used without
restriction as long as this notice is retained.
EXAMPLES
sample program
program tree_sort
use M_sort, only : tree_node, tree_insert, tree_print
implicit none
type(tree_node), pointer :: t ! A tree
integer :: number
integer :: ios
nullify(t) ! Start with empty tree
infinite: do
read (*,*,iostat=ios) number
if(ios.ne.0)exit infinite
call tree_insert(t,number) ! Put next number in tree
enddo infinite
call tree_print(t) ! Print nodes of tree in infix order
end program tree_sort
| Nemo Release 3.1 | tree_insert (3) | June 29, 2025 |
Generated by manServer 1.08 from 1a3ea057-03e5-46f7-8d0a-ed4f20777205 using man macros.