Searching and BST Exercises

Slides:



Advertisements
Similar presentations
Chapter 12 Binary Search Trees
Advertisements

InOrder Traversal Algorithm // InOrder traversal algorithm inOrder(TreeNode n) { if (n != null) { inOrder(n.getLeft()); visit(n) inOrder(n.getRight());
Design and Analysis of Algorithms – Chapter 61 Transform and Conquer Dr. Ying Lu RAIK 283: Data Structures & Algorithms.
Monday, 12/9/02, Slide #1 CS 106 Intro to CS 1 Monday, 12/9/02  QUESTIONS??  On HW #5 (Due 5 pm today)  Today:  Recursive functions  Reading: Chapter.
CS 104 Introduction to Computer Science and Graphics Problems Data Structure & Algorithms (4) Data Structures 11/18/2008 Yang Song.
1 Section 9.2 Tree Applications. 2 Binary Search Trees Goal is implementation of an efficient searching algorithm Binary Search Tree: –binary tree in.
© 2006 Pearson Addison-Wesley. All rights reserved13 A-1 Chapter 13 Advanced Implementation of Tables.
Binary Search Trees Chapter 7 Objectives
By : Budi Arifitama Pertemuan ke Objectives Upon completion you will be able to: Create and implement binary search trees Understand the operation.
Chapter 19 - basic definitions - order statistics ( findkth( ) ) - balanced binary search trees - Java implementations Binary Search Trees 1CSCI 3333 Data.
Data Structures - CSCI 102 Binary Tree In binary trees, each Node can point to two other Nodes and looks something like this: template class BTNode { public:
Review Binary Tree Binary Tree Representation Array Representation Link List Representation Operations on Binary Trees Traversing Binary Trees Pre-Order.
Lec 15 Oct 18 Binary Search Trees (Chapter 5 of text)
Searching and Binary Search Trees CSCI 3333 Data Structures.
Java Debugging in Eclipse by Dr. Bun Yue Professor of Computer Science 2013
Sorting and Searching by Dr P.Padmanabham Professor (CSE)&Director
Data Structures Using C++ 2E Chapter 9 Searching and Hashing Algorithms.
1 Chapter 7 Objectives Upon completion you will be able to: Create and implement binary search trees Understand the operation of the binary search tree.
CSS446 Spring 2014 Nan Wang.  to study trees and binary trees  to understand how binary search trees can implement sets  to learn how red-black trees.
Lecture 15 Jianjun Hu Department of Computer Science and Engineering University of South Carolina CSCE350 Algorithms and Data Structure.
Data Structures: A Pseudocode Approach with C, Second Edition1 Objectives Upon completion you will be able to: Explain the differences between a BST and.
Map ADT by Dr. Bun Yue Professor of Computer Science CSCI 3333 Data Structures.
Data Structures: A Pseudocode Approach with C, Second Edition 1 Chapter 7 Objectives Create and implement binary search trees Understand the operation.
Data Abstraction and Problem Solving with JAVA Walls and Mirrors Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley Data Abstraction and Problem.
Dictionaries and Hashing CSCI 3333 Data Structures.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To introduce the basic concepts of linked lists ❏ To introduce the basic concepts.
QuickSort by Dr. Bun Yue Professor of Computer Science CSCI 3333 Data.
CHAPTER 10.1 BINARY SEARCH TREES    1 ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS.
Question 4 Tutorial 8. Part A Insert 20, 10, 15, 5,7, 30, 25, 18, 37, 12 and 40 in sequence into an empty binary tree
Data Structures: A Pseudocode Approach with C 1 Chapter 5 Objectives Upon completion you will be able to: Explain the design, use, and operation of a linear.
Data Structures Red-Black Trees Design and Analysis of Algorithms I.
Binary Search Trees Chapter 7 Objectives
CSCI 3333 Data Structures Sorting Exercises
CSCI 3333 Data Structures Recursion Exercises
Recitation 3 (Heap Sort and Binary Search Tree)
Trees Chapter 11 (continued)
Trees Chapter 11 (continued)
Data Structures Using C++ 2E
Binary Search Trees A binary search tree is a binary tree
Binary Search Trees Rem Collier Room A1.02
PROJECT -1 (4 points) Week before midterm, C++.
Chapter 15 Lists Objectives
Binary Search Trees Chapter 7 Objectives
Efficiency of in Binary Trees
Binary Search Tree (BST)
Chapter 10.1 Binary Search Trees
Trees.
Chapter 16 Tree Implementations
Tree data structure.
ECET 370 HELPS Education Your Life-- ecet370helps.com.
Map interface Empty() - return true if the map is empty; else return false Size() - return the number of elements in the map Find(key) - if there is an.
Hash Table.
Chapter 15 Lists Objectives
Lec 12 March 9, 11 Mid-term # 1 (March 21?)
CSCI 3333 Data Structures Array
Data Structures: Binary Search Trees
Random inserting into a B+ Tree
Balanced Binary Search Trees
Binary Trees: Motivation
Binary Trees, Binary Search Trees
Binary Search Trees Chapter 7 Objectives
Chapter 12 Heap ADT © 2011 Pearson Addison-Wesley. All rights reserved.
Trees.
Array operations Dr. T. Kokilavani Assistant Professor
Tree Balancing: AVL Trees
Data Structures Using C++ 2E
Binary Trees, Binary Search Trees
Chapter 11 Trees © 2011 Pearson Addison-Wesley. All rights reserved.
Binary Search Binary Search Algorithm
Algorithm Analysis Exercise
Presentation transcript:

Searching and BST Exercises CSCI 3333 Data Structures Searching and BST Exercises by Dr. Bun Yue Professor of Computer Science yue@uhcl.edu http://sce.uhcl.edu/yue/ 2013

Binary Search Provide a recursive algorithm for binary search.

BST Insertion Show the BST after the insertion of the following records to an initially empty tree: 10, 4, 20, 22, 18, 35, 7, 9, 27, 60, 3, 44

BST Deletion Using the deletion algorithm in the slide, show the evolution of the BST [[3 4 [[] 7 9]] 10 [18 20 [[] 22 [27 35 [44 60 []]]]]] [[3 4 [[] 7 9]] 10 [18 20 [[] 22 [27 35 [44 60 []]]]]] after the records 10, 7, 22 and 20 are deleted in sequence.

BST Search Consider the BST [[3 4 [[] 7 9]] 10 [18 20 [[] 22 [27 35 [44 60 []]]]]]. What is the average number of key comparison for successful search?

BST Variation Suppose the BST ADT is modified so that key values are no longer unique (i.e. several records can have the same key values). Describe the implications to the ADT and the implementation.

Questions and Comments?