CS208 Coursework 2 Neil Ghani Mark Dukes Handin: Friday 11 March, 12pm, Departmental Office.

Slides:



Advertisements
Similar presentations
Chapter 7. Binary Search Trees
Advertisements

Alyce Brady CS 470: Data Structures CS 510: Computer Algorithms Post-order Traversal: Left Child - Right Child - Root Depth-First Search.
Chapter 12 Binary Search Trees
CS Fall 2012, Lab 08 Haohan Zhu. Boston University Slideshow Title Goes Here CS Fall 2012, Lab /17/2015 Tree - Data Structure  Basic.
Cs1120 Fall 2009 David Evans Lecture 16: Power Analysis.
Lecture 16: Tree Traversal.
Binary Trees, Binary Search Trees CMPS 2133 Spring 2008.
CS 206 Introduction to Computer Science II 09 / 24 / 2008 Instructor: Michael Eckmann.
Binary Trees, Binary Search Trees COMP171 Fall 2006.
Trees. Faster than linear data structures More natural fit for some kinds of data Examples? Why a tree?
CS 206 Introduction to Computer Science II 04 / 29 / 2009 Instructor: Michael Eckmann.
1.1 Data Structure and Algorithm Lecture 12 Binary Search Trees Topics Reference: Introduction to Algorithm by Cormen Chapter 13: Binary Search Trees.
Trees. Faster than linear data structures More natural fit for some kinds of data Examples? Why a tree?
Trees. Faster than linear data structures More natural fit for some kinds of data Examples? Why a tree?
Three Types of Depth-First Search Alyce Brady CS 470: Data Structures CS 510: Computer Algorithms.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Data Structures Trees.
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.
Trees Chapter 8. 2 Tree Terminology A tree consists of a collection of elements or nodes, organized hierarchically. The node at the top of a tree is called.
Review Binary Tree Binary Tree Representation Array Representation Link List Representation Operations on Binary Trees Traversing Binary Trees Pre-Order.
Lecture 6: An Introduction to Trees Neil Ghani University of Strathclyde.
ICOM 4035 – Data Structures Lecture 13 – Trees ADT Manuel Rodriguez Martinez Electrical and Computer Engineering University of Puerto Rico, Mayagüez ©Manuel.
Midterm Review CSE 2011 Winter October 2015.
Emma Price 1.  To be able to:  Explain what a binary tree is.  To traverse a binary tree using the three different methods. 2.
CISC220 Fall 2009 James Atlas Lecture 13: Trees. Skip Lists.
1 Trees A tree is a data structure used to represent different kinds of data and help solve a number of algorithmic problems Game trees (i.e., chess ),
Trees – Part 2 CS 367 – Introduction to Data Structures.
Data Structures and Algorithm Analysis Trees Lecturer: Jing Liu Homepage:
CS 206 Introduction to Computer Science II 10 / 05 / 2009 Instructor: Michael Eckmann.
Tree Traversal.
Trees  Linear access time of linked lists is prohibitive Does there exist any simple data structure for which the running time of most operations (search,
Lecture – Searching a Tree Neil Ghani University of Strathclyde.
S. Raskhodnikova and A. Smith. Based on slides by C. Leiserson and E. Demaine. 1 Adam Smith L ECTURES Binary Search Trees Algorithms and Data Structures.
CS 206 Introduction to Computer Science II 02 / 13 / 2009 Instructor: Michael Eckmann.
+ David Kauchak cs312 Review. + Midterm Will be posted online this afternoon You will have 2 hours to take it watch your time! if you get stuck on a problem,
Week 7 - Friday.  What did we talk about last time?  Trees in general  Binary search trees.
COMP 103 Traversing Trees. 2 RECAP-TODAY RECAP  Building and Traversing Trees TODAY  Traversing Trees  Chapter 16, especially 16.2.
Binary Search Trees Data Structures Ananda Gunawardena
CS 206 Introduction to Computer Science II 09 / 26 / 2008 Instructor: Michael Eckmann.
Binary Tree. Some Terminologies Short review on binary tree Tree traversals Binary Search Tree (BST)‏ Questions.
1/14/20161 BST Operations Data Structures Ananda Gunawardena.
Binary Search Trees (BST)
Traversing a tree means visiting each node in a specified order. There are different ways to traverse a tree. Tree Traversing Depth first search Pre-orderIn-orderPost-order.
Concepts of Algorithms CSC-244 Unit 19 & 20 Binary Search Tree (BST) Shahid Iqbal Lone Computer College Qassim University K.S.A.
Week 7 - Wednesday.  What did we talk about last time?  Recursive running time  Master Theorem  Symbol tables.
CH 7 : TREE ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++, GOODRICH, TAMASSIA AND MOUNT (WILEY.
CS321 Spring 2016 Lecture 3 Jan Admin A1 Due this Friday – 11:00PM Thursday = Recurrence Equations – Important. Everyone Should be added to class.
Lecture 7: Searching a Tree Neil Ghani University of Strathclyde.
Recursive Objects (Part 4)
Lecture No.13 Data Structures Dr. Sohail Aslam
Week 6 - Wednesday CS221.
Binary Search Tree (BST)
Tree.
Trees.
CSC 172– Data Structures and Algorithms
CS223 Advanced Data Structures and Algorithms
COSC2100: Data Structures and Algorithms
Alyce Brady CS 470: Data Structures CS 510: Computer Algorithms
CS212: Data Structures and Algorithms
Abstract Data Structures
Trees.
Trees (part 2) CSE 2320 – Algorithms and Data Structures
Principles of Computing – UFCFA3-30-1
Chapter 9 Binary Trees.
Data Structures and Algorithm Analysis Trees
2018, Fall Pusan National University Ki-Joune Li
Traverse this binary search tree using:
Trees.
Algorithms CSCI 235, Spring 2019 Lecture 8 Recurrences III
Binary Tree Implementation And Applications
107-1 Data Structure Homework 2
Presentation transcript:

CS208 Coursework 2 Neil Ghani Mark Dukes Handin: Friday 11 March, 12pm, Departmental Office

Question 1: Write an algorithm that takes a tree as input and returns the largest element stored in the tree Question 2: Write an algorithm that counts the number of pieces of data stored in a tree Trees

More Trees Question 3: Write an algorithm that takes as input a number n and a tree and prints out all data stored at depth n. So if t is the tree 6 / \ 5 7 / \ 9 12

Q3 Continued … then printAt 0 t = 6 printAt 1 t = 5, 7 printAt 2 t = 9, 12 Hint: Use recursion on the number as well as the tree. Look at cutAt in the lecture slides.

BSTs Q4: Give all the BSTs which store the numbers 1, 2, 3, 4, 5 Q5: Look at the tree given in Q3. What are the results of printing out the data stored in that tree using i) preorder traversal; ii) inorder traversal; and iii) post order traversal

Even More Trees Q6 Define an algorithm which takes two trees as input and returns the depth at which they first differ