07-trees-post3up

07-trees-post3up - Trees Readings: HtDP, section 14, 15,...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

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

Unformatted text preview: Trees Readings: HtDP, section 14, 15, 16. We will cover the ideas in the text using different examples and different terminology. The readings are still important as an additional source of examples. CS 135 Fall 2009 07: Trees 1 Lists are a natural way to represent sequences, but some forms of data are structured differently. HtDP uses the example of “ancestor family trees”. you father mother grandmother grandmother grandfather great-grandmother CS 135 Fall 2009 07: Trees 2 Family trees represent a “combining” process. Trees can also be used to represent “branching” processes. For example, an evolutionary event can create two distinct (but related) species of animals. Each of these may then be subject to further evolutionary events. We will call the tree representing all this an evolution tree (though in bioinformatics, the proper term is phylogenetic tree ). CS 135 Fall 2009 07: Trees 3 Evolution trees • a data structure recording information about the evolution of species. • contains two kinds of information: – modern species (e.g. humans) with population count; – evolutionary history via evolution events , with an estimate of how long ago the event occurred. An “evolution event” leads to a splitting of one species into two distinct species (for example, through physical separation). CS 135 Fall 2009 07: Trees 4 human 6.5 bil chimp 100000 rat 1 bil fruitFy 100 bil chicken 15 bil primate 5 mammal 65 vertebrate 320 animal 535 worm 50 bil invertebrate 530 CS 135 Fall 2009 07: Trees 5 We need two different types of structures to hold the data, resulting in a mixed data type we will call a taxon . Data on a modern species is stored in a t-modern structure. Data on a evolution event is stored in a t-ancient structure. ( define-struct t-modern ( name pop )) ( define-struct t-ancient ( name age left right )) These structures will be used in the base case and recursive cases (respectively) of our data definition. CS 135 Fall 2009 07: Trees 6 Data definition: a taxon is either • a ( make-t-modern n p ) , where ? n is a string representing the species’ name ? p is a number representing the population • or a ( make-t-ancient n a l r ) , where ? n is a string representing the name of the species that split ? a is a number representing the age of the evolution event ? l is a taxon ? r is a taxon CS 135 Fall 2009 07: Trees 7 Each of the constants defined below (corresponding to our example) satisfies the data definition for a taxon. ( define human ( make-t-modern " Homo Sapiens " 6500000000 )) ( define chimp ( make-t-modern " Pan Troglodytes " 100000 )) ( define rat ( make-t-modern " Rattus Norvegicus " 1000000000 )) ( define worm ( make-t-modern " Caenorhabditis Elegans " 50000000000 )) ( define fruit-fly ( make-t-modern " Drosophila Melanogaster " 100000000000 )) ( define chicken ( make-t-modern " Gallus Gallus " 15000000000 )) CS 135 Fall 2009 07: Trees 8 ( define primate ( make-t-ancient " Primate " 5 human chimp )) ( define mammal...
View Full Document

This note was uploaded on 02/12/2010 for the course CS 135 taught by Professor Vasiga during the Fall '07 term at Waterloo.

Page1 / 24

07-trees-post3up - Trees Readings: HtDP, section 14, 15,...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online