Anda di halaman 1dari 4

Data Structures and Algorithms

Objectives

In this session, you will learn to:


Apply trees to solve programming problems

Ver. 1.0 Session 14


Data Structures and Algorithms
Indexing

The
Datafollowing is anisexample
on disk files of an index.
usually organized as records containing
several fields, one of which is often used as a key field.
The key field is
Keyused
field to uniquely identify each record in a
Offset

file. 36 0
52 200
Indexing is one of the data access methods for accessing
24 400
records from the44disk files. 600
Indexing is implemented
40 through800a table called index.
Index consists of68two entries: 1000
59 1200
Key fields of all the records
55 1400
Offset position72of each record 1600
35 1800
43 2000

Ver. 1.0 Session 14


Data Structures and Algorithms
Indexing (Contd.)

To
Youaccess the recorda with
can implement key
binary field 59,
search treesearch thethese
to store indexindex
for
this key value to retrieve its corresponding offset value,
values.
which is 1200. enables faster search for a key value.
This approach
Read the record from the file starting from this offset
Key field Offset 52
position.
36 0
52 200
36 68
24 400
44 600
40 800 24 44 59 72
68 1000
59 1200 40 55
55 1400
72 1600
35 43
35 1800
43 2000
Index Key Fields Stored in a Binary Search Tree

Ver. 1.0 Session 14


Data Structures and Algorithms
Summary

In this session, you learned that:


Indexing is one of the data access methods for accessing
records from the disk files.
Indexing is implemented through a table called index.
Index consists of two entries:
Key fields of all the records
Offset position of each record
Binary search trees can be used to implement indexing.

Ver. 1.0 Session 14

Anda mungkin juga menyukai