Commit 51a2eb55 authored by Thomas Huetter's avatar Thomas Huetter
Browse files

statistics: added a script that outputs the min, max and average tree sizes of a given input file

parent 3113fb85
# file:
# usage: ./ <inputfile>
# Program: Counts the number of nodes per line. Ouputs the maximal,
# minimal and average number of nodes per line of the given
# inputfile containing a tree in bracket notation per line.
# Author: Thomas Huetter
if [ -z "$1" ]
echo "Argument missing."
echo "Usage: ./ <inputfile>"
exit 1
awk -F '\{' '{print NF-1}' $1 | awk 'NR == 1 { max=$1; min=$1; sum=0 }
{ if ($1>max) max=$1; if ($1<min) min=$1; sum+=$1;}
END {printf "Min: %d\tMax: %d\tAverage: %f\n", min, max, sum/NR}'
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment