lecture5-6

Triangles

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: sometimes
it
is
simply
the
easiest
way
to
break
down
a
problem
though
perhaps
not
the
most
efficient.
 A
recursive
function
that
pushes
the
limits
of
computers
quite
quickly
is
the
harmless
looking
 Ackermann
function
 
 
 
 
 if
m
=
0
 A(m,n)


=
 A(m‐1,1)
 
 if
m
>
0
and
n
=
0
 
 A(m‐1,A(m,n‐1))
 if
m
>
0
and
n
>
0
 
 n
+
1
 Try
writing
it
as
a
recursive
function.
 Triangles
 In
Project
Euler

(projecteuler.net)
there
is
a
problem
where
you
are
given
1000
triangles
in
a
file,
as
 1000
lines
with
three
pairs
of
points
per
line.
 function [count] = countTriangles(filename) %countTriangles counts the number of triangles in the file train...
View Full Document

This document was uploaded on 03/16/2014 for the course CS 106 at Mt. Holyoke.

Ask a homework question - tutors are online