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) February 23, 2025
Generated by manServer 1.08 from 411fcd6d-0453-48d6-b495-1a609d26bf2c using man macros.