CS 1321. CS1321: Introduction to Programming Georgia Institute of Technology College of Computing Lecture 11 Sept 27th, 2001 Fall Semester.

Slides:



Advertisements
Similar presentations
CS 206 Introduction to Computer Science II 03 / 23 / 2009 Instructor: Michael Eckmann.
Advertisements

Lecture 11 CSS314 Parallel Computing
Quiz3! Midterm! Assignment2! (most) Quiz4! Today’s special: 4 for 1.
Recursive Data 2 Mutually Recursive Data Definitions (HTDP sec 15.1)
Multi-way Trees CS 5010 Program Design Paradigms “Bootcamp” Lesson 6.6 © Mitchell Wand, This work is licensed under a Creative Commons Attribution-NonCommercial.
Developing Programs for Family Trees c. Kathi Fisler, 2001.
Lists CS 5010 Program Design Paradigms “Bootcamp” Lesson 4.1 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AAA 1 ©
CS 206 Introduction to Computer Science II 04 / 27 / 2009 Instructor: Michael Eckmann.
Developing Programs for Family Trees c. Kathi Fisler, 2001.
CS 206 Introduction to Computer Science II 10 / 31 / 2008 Happy Halloween!!! Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 12 / 05 / 2008 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 10 / 01 / 2008 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 09 / 22 / 2008 Instructor: Michael Eckmann.
Data Structures Data Structures Topic #8. Today’s Agenda Continue Discussing Table Abstractions But, this time, let’s talk about them in terms of new.
CS 206 Introduction to Computer Science II 12 / 03 / 2008 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 12 / 01 / 2008 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 11 / 24 / 2008 Instructor: Michael Eckmann.
B + -Trees (Part 2) Lecture 21 COMP171 Fall 2006.
By Jennifer Adams. The traditional approach (or algorithm) for large number division is the most abstract and difficult approach to division. Yet many.
Academic Computing Services 2010 Microsoft ® Office Visio ® 2007 Training Get to know Visio.
CS CS1321: Introduction to Programming Georgia Institute of Technology College of Computing Lecture 5 Sept 4th, 2001 Fall Semester.
Trees CS /02/05 L7: Trees Slide 2 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved Definition.
Data Structures Arrays both single and multiple dimensions Stacks Queues Trees Linked Lists.
I am ready to test!________ I am ready to test!________
Meet the Document Tree Your roadmap to Web Design.
1 21 COP 3540 Data Structures with OOP Overview: Chapter 1.
Database Systems Microsoft Access Practical #3 Queries Nos 215.
M1G Introduction to Database Development 2. Creating a Database.
Discrete Structures Lecture 12: Trees Ji Yanyan United International College Thanks to Professor Michael Hvidsten.
Busy Life in America by Melissa Wheeler. Table of Contents Reflection 1 The ‘Busy’ Trap By Tim Kreider Busy Busy By Tash Hughes Schedule 1 Schedule 2.
Introduction to Access. Access 2010 is a database creation and management program.
Trees CS 105. L9: Trees Slide 2 Definition The Tree Data Structure stores objects (nodes) hierarchically nodes have parent-child relationships operations.
Human Sexuality Final Project Utah vs. German beliefs Christina Randle Cathy Carey FHS 2450 July 19, 2012.
CS221: Algorithms and Data Structures Lecture #3 Mind Your Priority Queues Steve Wolfman 2014W1 1.
CS 206 Introduction to Computer Science II 04 / 22 / 2009 Instructor: Michael Eckmann.
CS CS1321: Introduction to Programming Georgia Institute of Technology College of Computing Lecture 10 Sept 25th, 2001 Fall Semester.
Generalizing Over Functions CS 5010 Program Design Paradigms “Bootcamp” Lesson TexPoint fonts used in EMF. Read the TexPoint manual before you delete.
Problem of the Day  Solve this equation by moving the numbers: 76 = 24.
Solving Your Problem by Generalization CS 5010 Program Design Paradigms “Bootcamp” Lesson 7.1 © Mitchell Wand, This work is licensed under a.
Sight Words.
Lecture on Set! And Local CS 2135 Copyright Kathi Fisler, 2002 This material requires Advanced Language Level.
High Frequency Words.
CS CS1321: Introduction to Programming Georgia Institute of Technology College of Computing Lecture 6 Sept 6th, 2001 Fall Semester.
CS CS1321: Introduction to Programming Georgia Institute of Technology College of Computing Lecture 13 October 4, 2001 Fall Semester.
CS CS1321: Introduction to Programming Georgia Institute of Technology College of Computing Lecture 16 October 18, 2001 Fall Semester.
Amortized Analysis and Heaps Intro David Kauchak cs302 Spring 2013.
Bell Question: Explain the difference between a phenotype and a genotype. The phenotype is what a trait looks like. The genotype is the specific alleles.
SurveyDIG 2.1 Tutorial. Tutorial Contents Introduction Introduction Item Groups Item Groups –Creating new Groups –Naming Convention –Searching/Editing.
Division Brought to you by powerpointpros.com. Lesson Menu Click on the links below to start with a specific topic. What is Division? Using Division Practice.
CMSC201 Computer Science I for Majors Lecture 19 – Recursion
CS 5010 Program Design Paradigms “Bootcamp” Lesson 5.2
Week 7 - Friday CS221.
Life in the Past Background Information for Teachers
My Family Tree 2018.
CMSC201 Computer Science I for Majors Lecture 18 – Recursion
CS 1321.
Btrees Insertion.
CMSC 341 Lecture 10 B-Trees Based on slides from Dr. Katherine Gibson.
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 10 Trees Slides are adopted from “Discrete.
B- Trees D. Frey with apologies to Tom Anastasio
Genetics.
Lecture 36 Section 12.2 Mon, Apr 23, 2007
My Family Tree 2017.
YOUR FAMILY TREE You will already know some information about your ancestors so there is little point in asking me to conduct research in to those people.
CS 5010 Program Design Paradigms “Bootcamp” Lesson 6.5
FAMILY TIES.
Developing Programs for Family Trees
Family Tree Infographic
CS 5010 Program Design Paradigms “Bootcamp” Lesson 4.1
Bringing it all Together: Family Trees
Presentation transcript:

CS 1321

CS1321: Introduction to Programming Georgia Institute of Technology College of Computing Lecture 11 Sept 27th, 2001 Fall Semester

Where are We? Section 14 of the book… “More Self-referential Data Definitions”

Today’s Menu More Self-referential Data Structures Trees

Up to this point… We’ve been dealing with the fairly simple self-referential data definition of a list empty A list-of-numbers is either: 1.the empty list empty or 2.(cons n lon) where n is a number and lon is a list-of-numbers

This has served us well… We’ve modeled sets of data where it is only necessary to have one reference to another location in the set of data. For example, a list of grocery items found on most college freshmen’s shopping lists… non-alcoholic beverages No-Doz Sugar-laden “food” of choices empty

non-alcoholic beverages No-Doz Sugar-laden “food” of choices empty We didn’t really need to know anything more than another grocery item will come after the current one if we’re not at the end of our list…

But what about more complicated situations? Let’s say you wanted to model data that inherently had more than just one relationship between items? Like a Family Tree…

The Family Tree… There are a couple of different ways to represent a family tree. The method that we’re going to go through will show an ancestor family tree. From a given location in the family tree, we will be able to easily access information about their ancestors, but not their descendants. Which means….

In this particular family tree, we add a new “node” to the tree every time a child is born. We record certain information about the child (name, year, eye color) as well as who the parents are (mother, father).

But if we stop to think about it, aren’t the father and mother both children themselves? So wouldn’t they too have properties like name, year, eye color and Father and Mother? So we need a self-referencing data definition that has two references within it!

Let’s develop a data definition… (define-struct child (father mother name bday eyes)) ;; A child is a structure: ;; (make-child father mother name bday eyes) ;; where father and mother are child structures; ;; name and eyes are symbols and bday is a number Looks good, right?

That almost works but… That data definition seems to work…but there are problems. Let’s say you have quite an extensive family history…goes all the way back to your great- great-great-great-great grandfather Billy-Bob Bubba Jones born in the year 1810 to … Well, the records of that portion of your family tree was destroyed in a tragic fire…so you don’t actually know who your great (x6) grandfather or grandmother actually was…

So we have to reflect that fact. Your father and mother values could be non-existent. They could be empty. So we change our data definition a little: A family-tree-node is either: 1)empty or 2)(make-child father mother name bday eyes) where father & mother are family-tree-nodes, name and eyes are symbols, and bday is a number

A family-tree-node is either: 1)empty or 2)(make-child father mother name bday eyes) where father and mother are family-tree-nodes, name and eyes are symbols, and bday is a number Note the difference in this abstract data definition and the structure we were creating before… ;; A child is a structure: ;; (make-child father mother name bday eyes) ;; where father and mother are child structures; ;; name and eyes are symbols and bday is a number

A family-tree-node is either: 1)empty or 2)(make-child father mother name bday eyes) where father and mother are family-tree-nodes, name and eyes are symbols, and bday is a number Note the difference in this abstract data definition and the structure we were creating before… ;; A child is a structure: ;; (make-child father mother name bday ;; eyes) ;; where father and mother are child ;; structures; name and eye are ;; symbols and bday is a number before after

So what have we made? We’ve created a data structure that references itself twice… If we wanted to think about it visually… name bday eyes fathermother

So what have we made? We’ve created a data structure that references itself twice… If we wanted to think about it visually… name bday eyes fathermother Why the vertical line? It makes things easier to visualize. You’ll see… Why the vertical line? It makes things easier to visualize. You’ll see…

Let’s say we start off with information about you… ‘Bubba 1981 ‘brown fathermother empty

Let’s say we start off with information about you… ‘Bubba 1981 ‘brown fathermother empty (make-child ??? ??? ‘Bubba 1981 ‘brown)

Let’s say we start off with information about you… ‘Bubba 1981 ‘brown fathermother empty (make-child empty empty ‘Bubba 1981 ‘brown empty empty)

Let’s say we start off with information about you… ‘Bubba 1981 ‘brown fathermother empty Until we enter information about a particular parent, we’ll just start them off as empty…

As time goes on we add more information about our family… ‘Bubba 1981 ‘brown ‘PaBubba 1960 ‘green ‘MaBubba 1961 ‘brown empty

‘Bubba 1981 ‘brown ‘PaBubba 1960 ‘green ‘MaBubba 1961 ‘brown empty (make-child (make-child empty empty ‘PaBubba 1960 ‘green) (make-child empty empty ‘MaBubba 1961 ‘brown) ‘Bubba 1981 ‘brown)

(define Dave (make-child (make-child empty empty ‘Carl 1926 ‘green) (make-child empty empty ‘Bettina 1926 ‘green) ‘Dave 1955 ‘black))) Could be done like this: (define Carl (make-child empty empty ‘Carl 1926 ‘green)) (define Bettina (make-child empty empty ‘Bettina 1926 ‘green)) (define Dave (make-child Carl Bettina ‘Dave 1955 ‘black))

And more information empty

What about code? Is this much more complex than what we’ve done before? Let’s see what a function template would look like for this family tree… We’ll derive a fun-for-ftn template short for function-for-processing-family-tree-node….