Trees in java.util A set is an object that stores unique elements

Slides:



Advertisements
Similar presentations
B-tree. Why B-Trees When the data is too big, we will have to use disk storage instead of putting all the data in main memory In such case, we have to.
Advertisements

 Definition of B+ tree  How to create B+ tree  How to search for record  How to delete and insert a data.
Chapter 4 : File Systems What is a file system?
Data Compressor---Huffman Encoding and Decoding. Huffman Encoding Compression Typically, in files and messages, Each character requires 1 byte or 8 bits.
Sets and Maps Chapter 9. Chapter 9: Sets and Maps2 Chapter Objectives To understand the Java Map and Set interfaces and how to use them To learn about.
COMP 171 Data Structures and Algorithms Tutorial 10 Hash Tables.
ICS 220 – Data Structures and Algorithms Week 7 Dr. Ken Cosh.
ALGORITHMS FOR ISNE DR. KENNETH COSH WEEK 6.
Efficient Minimal Perfect Hash Language Models David Guthrie, Mark Hepple, Wei Liu University of Sheffield.
Multi-way Trees. M-way trees So far we have discussed binary trees only. In this lecture, we go over another type of tree called m- way trees or trees.
1 Chapter 17 Disk Storage, Basic File Structures, and Hashing Chapter 18 Index Structures for Files.
Big Java Chapter 16.
111 © 2002, Cisco Systems, Inc. All rights reserved.
© 2006 Pearson Addison-Wesley. All rights reserved13 B-1 Chapter 13 (continued) Advanced Implementation of Tables.
CSS446 Spring 2014 Nan Wang.  Java Collection Framework ◦ Set ◦ Map 2.
B-Trees And B+-Trees Jay Yim CS 157B Dr. Lee.
Higher Order Tries Key = Social Security Number.   9 decimal digits. 10-way trie (order 10 trie) Height
Collections Data structures in Java. OBJECTIVE “ WHEN TO USE WHICH DATA STRUCTURE ” D e b u g.
Sets and Maps Sets Maps The Comparator Interface Sets and Maps in Java Collections API – TreeSet – TreeMap Review for Exam Reading:
Priority Queues. Priority Queue ADT A priority queue stores a collection of entries Each entry is a pair (key, value) Main methods of the Priority Queue.
Nov 22, 2010IAT 2651 Java Collections. Nov 22, 2010IAT 2652 Data Structures  With a collection of data, we often want to do many things –Organize –Iterate.
Sets and Maps Chapter 9. Chapter Objectives  To understand the Java Map and Set interfaces and how to use them  To learn about hash coding and its use.
DS.H.1 Hashing Chapter 5 Overview The General Idea Hash Functions Separate Chaining Open Addressing Rehashing Extendible Hashing Application Example: Geometric.
Collections ABCD ABCD Head Node Tail Node array doubly linked list Traditional Arrays and linked list: Below is memory representation of traditional.
CS422 Principles of Database Systems Indexes
Generic Trees—Trie, Compressed Trie, Suffix Trie (with Analysi
Sets and Maps Chapter 9.
Slides by Donald W. Smith
11 Map ADTs Map concepts. Map applications.
Data Structures and Design in Java © Rick Mercer
CSE 214 – Computer Science II Maps
Design & Analysis of Algorithm Map
Subject Name: File Structures
Indexing Structures for Files and Physical Database Design
Indexing Goals: Store large files Support multiple search keys
Higher Order Tries Key = Social Security Number.
IP Routers – internal view
Wednesday Notecards. Wednesday Notecards Wednesday Notecards.
University of Central Florida COP 3330 Object Oriented Programming
Database System Implementation CSE 507
Oracle SQL*Loader
Tries 9/14/ :13 AM Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and.
External Methods Chapter 15 (continued)
JCF Hashmap & Hashset Winter 2005 CS-2851 Dr. Mark L. Hornick.
Efficiency add remove find unsorted array O(1) O(n) sorted array
Searching.
Road Map CS Concepts Data Structures Java Language Java Collections
Java Collections Overview
COP3530- Data Structures B Trees
Chapter 10 Hashing.
14.1 The java.util Package.
Multiway Trees Searching and B-Trees Advanced Tree Structures
Higher Order Tries Key = Social Security Number.
B-Trees CSE 373 Data Structures CSE AU B-Trees.
Advanced Implementation of Tables
File Storage and Indexing
Files Management – The interfacing
2018, Spring Pusan National University Ki-Joune Li
A Small and Fast IP Forwarding Table Using Hashing
CSE 1020: The Collection Framework
CPS216: Advanced Database Systems
Sets and Maps Chapter 9.
Indexing 4/11/2019.
Hash Tables By JJ Shepherd.
File Organization.
B-Trees CSE 373 Data Structures CSE AU B-Trees.
Hashing based on slides by Marty Stepp
CS210- Lecture 16 July 11, 2005 Agenda Maps and Dictionaries Map ADT
Indexing, Access and Database System Architecture
CS 240 – Advanced Programming Concepts
Presentation transcript:

Trees in java.util A set is an object that stores unique elements In Java, two implementations are available: The class HashSet implements the set with a hash table and a hash function The class TreeSet, which keeps elements of a set in a sorted order

Trees in java.util (continued) Figure 3-32 Methods of the class TreeSet

Trees in java.util (continued) Figure 3-32 Methods of the class TreeSet (continued)

Trees in java.util (continued) Figure 3-32 Methods of the class TreeSet (continued)

Trees in java.util (continued) Figure 3-32 Methods of the class TreeSet (continued)

Trees in java.util (continued) Figure 3-32 Methods of the class TreeSet (continued)

Trees in java.util (continued) Figure 7-33 An example of application of the TreeSet methods

Trees in java.util (continued) Figure 7-33 An example of application of the TreeSet methods (continued)

Trees in java.util (continued) Figure 7-33 An example of application of the TreeSet methods (continued)

Trees in java.util (continued) Figure 7-33 An example of application of the TreeSet methods (continued)

Trees in java.util (continued) Figure 7-33 An example of application of the TreeSet methods (continued)

Trees in java.util (continued) Figure 7-33 An example of application of the TreeSet methods (continued)

Trees in java.util (continued) Figure 7-33 An example of application of the TreeSet methods (continued)

Trees in java.util (continued) Figure 7-33 An example of application of the TreeSet methods (continued)

TreeMap Maps are tables that can be indexed with any type of data Maps use keys that are used as indexes and elements (values) to be accessed through the keys Keys in maps are unique in that one key is associated with one value only Tree maps implement maps store pairs (key, value) called entries that can be operated on by methods specified in the interface Map.Entry

TreeMap (continued) Figure 7-34 (a) Methods in the interface Map.Entry; (b) methods of the class TreeMap

TreeMap (continued) Figure 7-34 (a) Methods in the interface Map.Entry; (b) methods of the class TreeMap (continued)

TreeMap (continued) Figure 7-34 (a) Methods in the interface Map.Entry; (b) methods of the class TreeMap (continued)

TreeMap (continued) Figure 7-34 (a) Methods in the interface Map.Entry; (b) methods of the class TreeMap (continued)

TreeMap (continued) Figure 7-34 (a) Methods in the interface Map.Entry; (b) methods of the class TreeMap (continued)

TreeMap (continued) Figure 7-35 An example of application of the TreeMap methods. The class PersonByName is the same as in Figure 7-33.

TreeMap (continued) Figure 7-35 An example of application of the TreeMap methods (continued)

Tries A tree that uses parts of the key to navigate the search is called a trie Each key is a sequence of characters; a trie is organized around these characters rather than entire keys

Tries (continued) Figure 7-36 A trie of some words composed of the five letters A, E, I, R, and P

Tries (continued) Figure 7-37 The trie in Figure 7.36 with all unused reference fields removed

Tries (continued) Figure 7-38 The trie from Figure 7.37 implemented as a binary tree

Tries (continued) Figure 7-39 A part of a trie (a) before and (b) after compression using the compressTrie() algorithm and (c) after compressing it in an optimal way

Tries (continued) Figure 7-39 A part of a trie (a) before and (b) after compression using the compressTrie() algorithm and (c) after compressing it in an optimal way (continued)

Tries (continued) Figure 7-40 A fragment of the C-trie representation of the trie from Figure 7-36

Case Study: Spell Checker Figure 7-41 An implementation of a trie that uses pseudoflexible arrays. The trie has the same words as the trie in Figure 7-36.

Case Study: Spell Checker (continued) Figure 7-42 Implementation of a spell checker using tries

Case Study: Spell Checker (continued) Figure 7-42 Implementation of a spell checker using tries (continued)

Case Study: Spell Checker (continued) Figure 7-42 Implementation of a spell checker using tries (continued)

Case Study: Spell Checker (continued) Figure 7-42 Implementation of a spell checker using tries (continued)

Case Study: Spell Checker (continued) Figure 7-42 Implementation of a spell checker using tries (continued)

Case Study: Spell Checker (continued) Figure 7-42 Implementation of a spell checker using tries (continued)

Case Study: Spell Checker (continued) Figure 7-42 Implementation of a spell checker using tries (continued)

Case Study: Spell Checker (continued) Figure 7-42 Implementation of a spell checker using tries (continued)

Case Study: Spell Checker (continued) Figure 7-42 Implementation of a spell checker using tries (continued)

Case Study: Spell Checker (continued) Figure 7-42 Implementation of a spell checker using tries (continued)

Case Study: Spell Checker (continued) Figure 7-42 Implementation of a spell checker using tries (continued)

Case Study: Spell Checker (continued) Figure 7-42 Implementation of a spell checker using tries (continued)

Case Study: Spell Checker (continued) Figure 7-42 Implementation of a spell checker using tries (continued)

Case Study: Spell Checker (continued) Figure 7-42 Implementation of a spell checker using tries (continued)

Case Study: Spell Checker (continued) Figure 7-42 Implementation of a spell checker using tries (continued)

Case Study: Spell Checker (continued) Figure 7-42 Implementation of a spell checker using tries (continued)

Case Study: Spell Checker (continued) Figure 7-42 Implementation of a spell checker using tries (continued)

Case Study: Spell Checker (continued) Figure 7-42 Implementation of a spell checker using tries (continued)

Case Study: Spell Checker (continued) Figure 7-42 Implementation of a spell checker using tries (continued)

Case Study: Spell Checker (continued) Figure 7-42 Implementation of a spell checker using tries (continued)

Case Study: Spell Checker (continued) Figure 7-42 Implementation of a spell checker using tries (continued)

Case Study: Spell Checker (continued) Figure 7-42 Implementation of a spell checker using tries (continued)

Summary B+-trees are commonly used in the implementation of indexes in today’s relational databases Seek time depends on the mechanical movement of the disk head to position the head at the correct track of the disk Latency is the time required to position the head above the correct block and is equal to the time needed to make one-half of a revolution

Summary (continued) In a B*-tree, all nodes except the root are required to be at least two-thirds full, not just half full as in a B-tree A simple prefix B+-tree is a B+-tree in which the chosen separators are the shortest prefixes that allow us to distinguish two neighboring index keys A set is an object that stores unique elements. Maps are tables that can be indexed with any type of data

Summary (continued) The bit-tree is based on the concept of a distinction bit (D-bit) A variant of B-trees, 2–4 trees, is useful in processing information in memory A tree that uses parts of the key to navigate the search is called a trie