1. Trang chủ
  2. » Cao đẳng - Đại học

Lecture Data structures and other objects using C++ - Chapter 10b: Binary search trees - Trường Đại học Công nghiệp Thực phẩm Tp. Hồ Chí Minh

10 4 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Arizona Arkansas Colorado A Binary Search Tree of States The data in the  dictionary will  be stored in a  binary tree,  with each node  containing an . item  and a  key[r]

(1)

One of the tree applications in 

Chapter 10 is binary search trees In Chapter 10, binary search trees  are used to implement bags and  sets

This presentation illustrates how  another data type called a 

dictionary is implemented with  binary search trees

(2)(3)

The Dictionary Data Type A dictionary is a collection 

of items, similar to a bag But unlike a bag, each item  has a string attached to it,  called the item's key

Example:

(4)

A dictionary is a collection  of items, similar to a bag But unlike a bag, each item  has a string attached to it,  called the item's key

Example:

  The key for each   record is the name

(5)

The Dictionary Data Type

The insertion procedure for a  dictionary has two 

parameters

void dictionary::insert(The key for the new item, The new item);

Washing

(6)

When you want to retrieve an  item, you specify the key  

(7)

Item dictionary::retrieve("Washington");

The Dictionary Data Type

When you want to retrieve an  item, you specify the 

key    and the retrieval 

(8)

We'll look at how a binary  tree can be used as the 

(9)

Arizona Arkansas Colorado A Binary Search Tree of States The data in the  dictionary will  be stored in a  binary tree,  with each node  containing an 

item and a key Washington

(10)

Colorado Arizona Arkansas Washington Oklahoma Colorado Mass N ew H am ps hi re W es t V ir gi ni a Storage rules:

Every key to the left  of a node is 

Ngày đăng: 01/04/2021, 19:24

Xem thêm:

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN