SlideShare a Scribd company logo
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
1
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
2
 The purpose of standard data organization methods
 Various file organizations and their application-specific
suitability such as sequential file, indexed sequential file, and
direct access file
 The advantages and disadvantages of file organizations
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
3
 Records that hold information about similar items of data are
usually grouped together into ‘file’
 A file is a collection of records where each record consists of one
or more fields
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
4
 External storage devices are mainly used for the
following:
 Overlay or backup of programs during execution
 Storage of programs for future use
 Storage of information in files
External storage device
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
5
 The most common external storage devices in order of their
use, and study :
 magnetic tapes,
 drums, and
 disk drives
 When we organize data in ‘file’ data structure, the data is non-
volatile, which means data will reside on storage after data
processing is over
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
6
 A tape is made up of a plastic material coated with a
ferrite substance that is easily magnetized
 The physical appearance of the tape is similar to the
tape used for sound recording.
 A limitation of magnetic tape devices is that records
must be processed in the order in which they reside
on the tape
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
7
 A magnetic drum is a metal cylinder, from 10 to 36 inches
in diameter, which has an outside surface coated with a
magnetic recording material
 The cylindrical surface of the drum is divided into a
number of parallel bands called tracks
 The tracks are further divided into either sectors or blocks,
depending on the nature of the drum
 The sector or block is the smallest addressable unit
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
8
 The magnetic disk is a direct access storage
device, which has become more widely used than
the magnetic drum, mainly because of its lower
cost
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
9
 The proper arrangement of records within a
file is called as file organization
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
10
 Different Schemes of File Organizations
 Sequential file
 Direct or random access file
 Indexed sequential file
 Multi-Indexed file
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
11
 In sequential file, records are stored in the
sequential order of their entry
 This is the simplest kind of data organization
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
12
 Though we search records using key, we still need to know
the address of the record to retrieve it directly
 The file organization that supports Files such access is
called as direct or random file organization
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
13
 File—Records are stored sequentially but the index file is
prepared for accessing the record directly
 An index file contains records ordered by a record key
 The record key uniquely identifies the record and
determines the sequence in which it is accessed with
respect to other records
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
14
 In multi-indexed file, the data file is associated with one
or more logically separated index files
 Inverted files and multilist files are examples of
multiindexed files
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
15
 The factors that affect file organization are mainly
the following:
 Storage device
 Type of query
 Number of keys
 Mode of retrieval/update of record
Factors Affecting File
Organization
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
16
 Speed
 Operations
 Capacity
 Size
 Security
Factors Involved in Selecting
File Organization
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
17
 File I/O Classes
 Primitive Functions Files
 Binary and Text File
FILES USING C++
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
18
 The I/O system of C++ contains a set of classes that
define the file handling methods
 They are ifstream, ofstream, and fstream
 These classes are included in ‘fstream.h’ header file
 ifstream—This class provides input operations
 ofstream—This class provides output operations
 fstream—This class provides both input and
output operations

File I/O Classes
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
19
 There are several ways of reading (or writing) the
text from (or to) a file
 But all of them have a common approach as follows
 Open the file
 Read (or write) the data
 Close the file
Primitive Functions
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
20
 Binary and Text File
 The binary file consists of binary data
 It can store text, graphics, sound data in binary format
 The binary files cannot be read directly
 Text File
 The text file contains the plain ASCII characters
 It contains text data which is marked by ‘end of line’ at th
end of each record
 This end of record marks help easily to perform
operations such as read and write
 Text file cannot store graphical data
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
21
 The order of the records is fixed
 Within each block, the records are in sequence
 A sequential file stores records in the order they are entered
 New records always appear at the end of the file
 Primitive Operations
 Features of Sequential File Organization
 Drawbacks of Sequential File Organization
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
22
 Open—This opens the file and sets the file pointer to
immediately before the first record
 Read-next—This returns the next record to the user. If
no record is present, then EOF condition will be set
 Close—This closes the file and terminates the access to
the file
 Write-next—File pointers are set to next of last record
and write the record to the file
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
23
 Write-next—File pointers are set to next of last record
and write the record to the file
 EOF—If EOF condition occurs, it returns true,
otherwise it returns false
 Search—Search for the record with a given key
 Update—Current record is written at the same position
with updated values
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
24
 Insertion and deletion of records in in-between positions huge
data movement
 Accessing any record requires a pass through all the preceding
records, which is time consuming. Therefore, searching a record
also takes more time.
 Needs reorganization of file from time to time. If too many
records are deleted logically, then the file must be reorganized
to free the space occupied by unwanted records
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
25
 Files that have been designed to make direct record
retrieval as easy and efficiently as possible is known as
directly organized files
 Direct access files are of great use for immediate access to
large amounts of information
 They are often used in accessing large databases
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
26
Beginning of file
Current position
End of file
0
1
2
SEEK_SET
SEEK_CUR
SEEK_END
Origin Value Macro Name
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
27
0
Origin Value Macro Name
Beginning of file
Current position
End of file
0
1
2
SEEK_SET
SEEK_CUR
SEEK_END
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
28
0
Origin Value Macro Name
Beginning of file
Current position
End of file
0
1
2
SEEK_SET
SEEK_CUR
SEEK_END
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
29
 A file that is loaded in key sequence but can be accessed
directly by use of one or more indices is known as an
indexed sequential file
 A sequential data file that is indexed is called as
indexed sequential file
 A solution to improve speed of retrieving target is index
sequential file
 An indexed file contains records ordered by a record key
 Each record contains a field that contains the record key
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
30
Advantages
 Accessing any record is more efficient than sequential file
organization
 Large amount of data can be stored using this type of file
organization
Disadvantages
 Often more than one indices are needed which occupies
large storage area
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
31
 Primary index
 It is an index ordered in the same way as the data file,
which is sequentially ordered according to a key
 The indexing field is equal to this key
 Secondary index
 An index that is defined on a non-ordering field of the
data file
 In this case, the indexing field need not contain
unique values
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
32
 Clustering indexes
 A data file can associate with utmost one primary
index and several secondary indexes
 The single-level indexing structure is the simplest one
where a file, whose records are pairs, contains a key
and a pointer
 The single-level indexing structure is the simplest one
where a file, whose records are pairs, contains a key
and a pointer
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
33
Index file consists of three areas:
 A primary storage area—This includes some unused space
to allow for additions made in data
 A separate index or indexes—Each query will reference
this index first; it will redirect query to part of data file in
which the target record is saved
 An overflow area—This is optional separate overflow area
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
34
 Records are stored sequentially but the index file is
prepared for accessing the record directly
 Records can be accessed randomly
 File has records and also the index
Magnetic tape is not suitable for index sequential storage
 Index is the address of physical storage of a record
 When randomly very few are required/accessed, then
index sequential is better
 Faster access method
Addition overhead is to maintain index
Index sequential files are popularly used in many
applications like digital library
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
35
 In linked organization, the physical sequence of
records is different from the logical sequence of
records
 The next logical record is obtained by following a
link value from the present record
 Multilist Files
 Coral Rings
 Inverted Files
 Cellular Partitions
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
36
 To make searching easy, several indexes are
maintained as per primary key and secondary
keys, one index per key
 The record may be present in different lists as per
key
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
37
 Consider the following file of office staff
Staff ID Occupation Salary Record
106 Clerk 5000 A
150 Account 4000 B
360 clerk 3000 C
400 Account 3500 D
700 Clerk 2000 E
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
38
 We can maintain index on the staff ID
 We can group staff ID with range 101–
300, 301–600, 601–900, etc
 Now all the records with staff ID in the
same range will be linked together as
shown in Figure
Sample multilist file
Staff range Link
101-300
301-600
601-900
rec A
rec C
rec E
rec B
rec D
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
39
 In this doubly linked multilist structure is used.
Each list is circular list with headnode
 A C E Alink
Clerk Blink S Blink
Sample doubly linked list
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
40
 ‘Alink’ field is used to link all records with same key
value
 ‘Blink’ is used for some records back pointer and
for others it is pointer to head node
 Owing to these back pointers, deletion is easy
without going to start.
 Indexes are maintained as per multilists
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
41
 With the same key value are linked together and
links are kept in each record
 But in the inverted files, the link information is
kept in the index itself
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
42
106 A
150 B
360 C
400 D
700 E
Accountant B,D
Clerk A,C,E
Salary Index
2000 E
4000 B,C,D
6000 A
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
43
 The inversion process is associated with the
information of inverted list
 In inverted files, the record is accessed in two steps.
First, the indices are searched to obtain a list of
required records and then second, records are retrieved
using these lists
 The number of disk accesses required is equal to the
number of records being retrieved plus the number to
process the indices
 In inverted files, only the index structures are
important
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
44
 To decrease file search time, the storage media may be
divided into cells
 A cell may be an entire disk or a cylinder. Lists are
localized to lie within a cell
 If a cylinder is used as a cell, then all records on the
same cylinder may be accessed without moving the
read/write heads
 We divide multilists organized on several different
cylinders into several small lists which are stored on
the same cylinder
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
45
Position Student ID T. ID Link
1 100 A
2 200 B Null
3 300 C Null
4 400 A Null
1 500 D
2 600 B Null
3 700 A Null
4 800 D Null
1 900 E Null
2 1000 C Null
3 1100 D Null
4 1200 A Null
Primary key Secondary key
Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil
46

More Related Content

What's hot

Concurrency control
Concurrency controlConcurrency control
Concurrency control
Subhasish Pati
 
Modes of data transfer
Modes of data transferModes of data transfer
Modes of data transfer
Shah Ishtiyaq Mehfooze
 
Timing and-control-unit
Timing and-control-unitTiming and-control-unit
Timing and-control-unitAnuj Modi
 
COMPUTER INSTRUCTIONS & TIMING & CONTROL.
COMPUTER INSTRUCTIONS & TIMING & CONTROL.COMPUTER INSTRUCTIONS & TIMING & CONTROL.
COMPUTER INSTRUCTIONS & TIMING & CONTROL.
ATUL KUMAR YADAV
 
17. Recovery System in DBMS
17. Recovery System in DBMS17. Recovery System in DBMS
17. Recovery System in DBMSkoolkampus
 
File organization 1
File organization 1File organization 1
File organization 1
Rupali Rana
 
Register transfer and micro operation
Register transfer and micro operationRegister transfer and micro operation
Register transfer and micro operation
Kamal Acharya
 
File organization and indexing
File organization and indexingFile organization and indexing
File organization and indexing
raveena sharma
 
Macro assembler
 Macro assembler Macro assembler
Macro assembler
Meghaj Mallick
 
Distributed concurrency control
Distributed concurrency controlDistributed concurrency control
Distributed concurrency control
Binte fatima
 
DBMS: Types of keys
DBMS:  Types of keysDBMS:  Types of keys
DBMS: Types of keys
Bharati Ugale
 
Data Designs (Software Engg.)
Data Designs (Software Engg.)Data Designs (Software Engg.)
Data Designs (Software Engg.)
Arun Shukla
 
Peephole Optimization
Peephole OptimizationPeephole Optimization
Peephole Optimization
United International University
 
System calls
System callsSystem calls
System calls
Bernard Senam
 
Computer architecture
Computer architectureComputer architecture
Computer architecture
Rama senthilkumar
 
SHA 1 Algorithm.ppt
SHA 1 Algorithm.pptSHA 1 Algorithm.ppt
SHA 1 Algorithm.ppt
Rajapriya82
 
Control Function - Computer Architecture
Control Function - Computer ArchitectureControl Function - Computer Architecture
Control Function - Computer Architecture
Adeel Rasheed
 
2 phase locking protocol DBMS
2 phase locking protocol DBMS2 phase locking protocol DBMS
2 phase locking protocol DBMS
Dhananjaysinh Jhala
 
Microprogrammed Control Unit
Microprogrammed Control UnitMicroprogrammed Control Unit
Microprogrammed Control Unit
PreethiSureshkumar1
 

What's hot (20)

Concurrency control
Concurrency controlConcurrency control
Concurrency control
 
Modes of data transfer
Modes of data transferModes of data transfer
Modes of data transfer
 
Timing and-control-unit
Timing and-control-unitTiming and-control-unit
Timing and-control-unit
 
COMPUTER INSTRUCTIONS & TIMING & CONTROL.
COMPUTER INSTRUCTIONS & TIMING & CONTROL.COMPUTER INSTRUCTIONS & TIMING & CONTROL.
COMPUTER INSTRUCTIONS & TIMING & CONTROL.
 
17. Recovery System in DBMS
17. Recovery System in DBMS17. Recovery System in DBMS
17. Recovery System in DBMS
 
File organization 1
File organization 1File organization 1
File organization 1
 
Register transfer and micro operation
Register transfer and micro operationRegister transfer and micro operation
Register transfer and micro operation
 
File organization and indexing
File organization and indexingFile organization and indexing
File organization and indexing
 
Macro assembler
 Macro assembler Macro assembler
Macro assembler
 
Distributed concurrency control
Distributed concurrency controlDistributed concurrency control
Distributed concurrency control
 
DBMS: Types of keys
DBMS:  Types of keysDBMS:  Types of keys
DBMS: Types of keys
 
Data Designs (Software Engg.)
Data Designs (Software Engg.)Data Designs (Software Engg.)
Data Designs (Software Engg.)
 
Peephole Optimization
Peephole OptimizationPeephole Optimization
Peephole Optimization
 
Memory management
Memory managementMemory management
Memory management
 
System calls
System callsSystem calls
System calls
 
Computer architecture
Computer architectureComputer architecture
Computer architecture
 
SHA 1 Algorithm.ppt
SHA 1 Algorithm.pptSHA 1 Algorithm.ppt
SHA 1 Algorithm.ppt
 
Control Function - Computer Architecture
Control Function - Computer ArchitectureControl Function - Computer Architecture
Control Function - Computer Architecture
 
2 phase locking protocol DBMS
2 phase locking protocol DBMS2 phase locking protocol DBMS
2 phase locking protocol DBMS
 
Microprogrammed Control Unit
Microprogrammed Control UnitMicroprogrammed Control Unit
Microprogrammed Control Unit
 

Viewers also liked

15. STL - Data Structures using C++ by Varsha Patil
15. STL - Data Structures using C++ by Varsha Patil15. STL - Data Structures using C++ by Varsha Patil
15. STL - Data Structures using C++ by Varsha Patil
widespreadpromotion
 
10. Search Tree - Data Structures using C++ by Varsha Patil
10. Search Tree - Data Structures using C++ by Varsha Patil10. Search Tree - Data Structures using C++ by Varsha Patil
10. Search Tree - Data Structures using C++ by Varsha Patil
widespreadpromotion
 
12. Heaps - Data Structures using C++ by Varsha Patil
12. Heaps - Data Structures using C++ by Varsha Patil12. Heaps - Data Structures using C++ by Varsha Patil
12. Heaps - Data Structures using C++ by Varsha Patil
widespreadpromotion
 
9. Searching & Sorting - Data Structures using C++ by Varsha Patil
9. Searching & Sorting - Data Structures using C++ by Varsha Patil9. Searching & Sorting - Data Structures using C++ by Varsha Patil
9. Searching & Sorting - Data Structures using C++ by Varsha Patil
widespreadpromotion
 
13. Indexing MTrees - Data Structures using C++ by Varsha Patil
13. Indexing MTrees - Data Structures using C++ by Varsha Patil13. Indexing MTrees - Data Structures using C++ by Varsha Patil
13. Indexing MTrees - Data Structures using C++ by Varsha Patil
widespreadpromotion
 
Discrete Mathematics S. Lipschutz, M. Lipson And V. H. Patil
Discrete Mathematics S. Lipschutz, M. Lipson And V. H. PatilDiscrete Mathematics S. Lipschutz, M. Lipson And V. H. Patil
Discrete Mathematics S. Lipschutz, M. Lipson And V. H. Patil
widespreadpromotion
 
16. Algo analysis & Design - Data Structures using C++ by Varsha Patil
16. Algo analysis & Design - Data Structures using C++ by Varsha Patil16. Algo analysis & Design - Data Structures using C++ by Varsha Patil
16. Algo analysis & Design - Data Structures using C++ by Varsha Patil
widespreadpromotion
 
11. Hashing - Data Structures using C++ by Varsha Patil
11. Hashing - Data Structures using C++ by Varsha Patil11. Hashing - Data Structures using C++ by Varsha Patil
11. Hashing - Data Structures using C++ by Varsha Patil
widespreadpromotion
 
3. Stack - Data Structures using C++ by Varsha Patil
3. Stack - Data Structures using C++ by Varsha Patil3. Stack - Data Structures using C++ by Varsha Patil
3. Stack - Data Structures using C++ by Varsha Patil
widespreadpromotion
 
4. Recursion - Data Structures using C++ by Varsha Patil
4. Recursion - Data Structures using C++ by Varsha Patil4. Recursion - Data Structures using C++ by Varsha Patil
4. Recursion - Data Structures using C++ by Varsha Patil
widespreadpromotion
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
Vineeta Garg
 
6. Linked list - Data Structures using C++ by Varsha Patil
6. Linked list - Data Structures using C++ by Varsha Patil6. Linked list - Data Structures using C++ by Varsha Patil
6. Linked list - Data Structures using C++ by Varsha Patil
widespreadpromotion
 
Lists, queues and stacks
Lists, queues and stacksLists, queues and stacks
Lists, queues and stacksandreeamolnar
 
Array,lists and hashes in perl
Array,lists and hashes in perlArray,lists and hashes in perl
Array,lists and hashes in perl
sana mateen
 
Data structures question paper anna university
Data structures question paper anna universityData structures question paper anna university
Data structures question paper anna universitysangeethajames07
 
Classes and objects1
Classes and objects1Classes and objects1
Classes and objects1
Vineeta Garg
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructors
Vineeta Garg
 
Structured query language functions
Structured query language functionsStructured query language functions
Structured query language functions
Vineeta Garg
 
Advanced data structures using c++ 3
Advanced data structures using c++ 3Advanced data structures using c++ 3
Advanced data structures using c++ 3Shaili Choudhary
 

Viewers also liked (20)

15. STL - Data Structures using C++ by Varsha Patil
15. STL - Data Structures using C++ by Varsha Patil15. STL - Data Structures using C++ by Varsha Patil
15. STL - Data Structures using C++ by Varsha Patil
 
10. Search Tree - Data Structures using C++ by Varsha Patil
10. Search Tree - Data Structures using C++ by Varsha Patil10. Search Tree - Data Structures using C++ by Varsha Patil
10. Search Tree - Data Structures using C++ by Varsha Patil
 
12. Heaps - Data Structures using C++ by Varsha Patil
12. Heaps - Data Structures using C++ by Varsha Patil12. Heaps - Data Structures using C++ by Varsha Patil
12. Heaps - Data Structures using C++ by Varsha Patil
 
9. Searching & Sorting - Data Structures using C++ by Varsha Patil
9. Searching & Sorting - Data Structures using C++ by Varsha Patil9. Searching & Sorting - Data Structures using C++ by Varsha Patil
9. Searching & Sorting - Data Structures using C++ by Varsha Patil
 
13. Indexing MTrees - Data Structures using C++ by Varsha Patil
13. Indexing MTrees - Data Structures using C++ by Varsha Patil13. Indexing MTrees - Data Structures using C++ by Varsha Patil
13. Indexing MTrees - Data Structures using C++ by Varsha Patil
 
Discrete Mathematics S. Lipschutz, M. Lipson And V. H. Patil
Discrete Mathematics S. Lipschutz, M. Lipson And V. H. PatilDiscrete Mathematics S. Lipschutz, M. Lipson And V. H. Patil
Discrete Mathematics S. Lipschutz, M. Lipson And V. H. Patil
 
16. Algo analysis & Design - Data Structures using C++ by Varsha Patil
16. Algo analysis & Design - Data Structures using C++ by Varsha Patil16. Algo analysis & Design - Data Structures using C++ by Varsha Patil
16. Algo analysis & Design - Data Structures using C++ by Varsha Patil
 
11. Hashing - Data Structures using C++ by Varsha Patil
11. Hashing - Data Structures using C++ by Varsha Patil11. Hashing - Data Structures using C++ by Varsha Patil
11. Hashing - Data Structures using C++ by Varsha Patil
 
3. Stack - Data Structures using C++ by Varsha Patil
3. Stack - Data Structures using C++ by Varsha Patil3. Stack - Data Structures using C++ by Varsha Patil
3. Stack - Data Structures using C++ by Varsha Patil
 
4. Recursion - Data Structures using C++ by Varsha Patil
4. Recursion - Data Structures using C++ by Varsha Patil4. Recursion - Data Structures using C++ by Varsha Patil
4. Recursion - Data Structures using C++ by Varsha Patil
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 
6. Linked list - Data Structures using C++ by Varsha Patil
6. Linked list - Data Structures using C++ by Varsha Patil6. Linked list - Data Structures using C++ by Varsha Patil
6. Linked list - Data Structures using C++ by Varsha Patil
 
2 4 Tree
2 4 Tree2 4 Tree
2 4 Tree
 
Lists, queues and stacks
Lists, queues and stacksLists, queues and stacks
Lists, queues and stacks
 
Array,lists and hashes in perl
Array,lists and hashes in perlArray,lists and hashes in perl
Array,lists and hashes in perl
 
Data structures question paper anna university
Data structures question paper anna universityData structures question paper anna university
Data structures question paper anna university
 
Classes and objects1
Classes and objects1Classes and objects1
Classes and objects1
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructors
 
Structured query language functions
Structured query language functionsStructured query language functions
Structured query language functions
 
Advanced data structures using c++ 3
Advanced data structures using c++ 3Advanced data structures using c++ 3
Advanced data structures using c++ 3
 

Similar to 14. Files - Data Structures using C++ by Varsha Patil

Research Data Management Fundamentals for MSU Engineering Students
Research Data Management Fundamentals for MSU Engineering StudentsResearch Data Management Fundamentals for MSU Engineering Students
Research Data Management Fundamentals for MSU Engineering Students
Aaron Collie
 
L3_Electronic Data Processing.pptx
L3_Electronic Data Processing.pptxL3_Electronic Data Processing.pptx
L3_Electronic Data Processing.pptx
UsamaSatti11
 
L3_Electronic Data Processing.pptx
L3_Electronic Data Processing.pptxL3_Electronic Data Processing.pptx
L3_Electronic Data Processing.pptx
UsamaSatti11
 
L3_Electronic Data Processing.pptx
L3_Electronic Data Processing.pptxL3_Electronic Data Processing.pptx
L3_Electronic Data Processing.pptx
UsamaSatti11
 
Ch12-OS9e-modified (1).pptx
Ch12-OS9e-modified (1).pptxCh12-OS9e-modified (1).pptx
Ch12-OS9e-modified (1).pptx
udithaisur
 
Research Data Management: An Overview - 2014-05-12 - Humanities Division, Uni...
Research Data Management: An Overview - 2014-05-12 - Humanities Division, Uni...Research Data Management: An Overview - 2014-05-12 - Humanities Division, Uni...
Research Data Management: An Overview - 2014-05-12 - Humanities Division, Uni...
Research Support Team, IT Services, University of Oxford
 
Dbms
DbmsDbms
Introduction to Research Data Management - 2014-02-26 - Mathematical, Physica...
Introduction to Research Data Management - 2014-02-26 - Mathematical, Physica...Introduction to Research Data Management - 2014-02-26 - Mathematical, Physica...
Introduction to Research Data Management - 2014-02-26 - Mathematical, Physica...
Research Support Team, IT Services, University of Oxford
 
Chapter 12.pptx
Chapter 12.pptxChapter 12.pptx
Chapter 12.pptx
AsmaaFaried1
 
Introduction to File System
Introduction to File SystemIntroduction to File System
Introduction to File System
SanthiNivas
 
Computer Science 12th Topic- introduction to syllabus.pdf
Computer Science 12th Topic- introduction to syllabus.pdfComputer Science 12th Topic- introduction to syllabus.pdf
Computer Science 12th Topic- introduction to syllabus.pdf
iqbalaabi01
 
An Efficient Approach to Manage Small Files in Distributed File Systems
An Efficient Approach to Manage Small Files in Distributed File SystemsAn Efficient Approach to Manage Small Files in Distributed File Systems
An Efficient Approach to Manage Small Files in Distributed File Systems
IRJET Journal
 
Electronic Data Processing
Electronic Data ProcessingElectronic Data Processing
Electronic Data Processing
Anjan Mahanta
 
Chapter12
Chapter12Chapter12
Chapter12
Loyd Morales
 
Data management for TA's
Data management for TA'sData management for TA's
Data management for TA'saaroncollie
 
David Shotton - Research Integrity: Integrity of the published record
David Shotton - Research Integrity: Integrity of the published recordDavid Shotton - Research Integrity: Integrity of the published record
David Shotton - Research Integrity: Integrity of the published record
Jisc
 

Similar to 14. Files - Data Structures using C++ by Varsha Patil (20)

Research Data Management Fundamentals for MSU Engineering Students
Research Data Management Fundamentals for MSU Engineering StudentsResearch Data Management Fundamentals for MSU Engineering Students
Research Data Management Fundamentals for MSU Engineering Students
 
L3_Electronic Data Processing.pptx
L3_Electronic Data Processing.pptxL3_Electronic Data Processing.pptx
L3_Electronic Data Processing.pptx
 
L3_Electronic Data Processing.pptx
L3_Electronic Data Processing.pptxL3_Electronic Data Processing.pptx
L3_Electronic Data Processing.pptx
 
L3_Electronic Data Processing.pptx
L3_Electronic Data Processing.pptxL3_Electronic Data Processing.pptx
L3_Electronic Data Processing.pptx
 
Ch12-OS9e-modified (1).pptx
Ch12-OS9e-modified (1).pptxCh12-OS9e-modified (1).pptx
Ch12-OS9e-modified (1).pptx
 
Research Data Management: An Overview - 2014-05-12 - Humanities Division, Uni...
Research Data Management: An Overview - 2014-05-12 - Humanities Division, Uni...Research Data Management: An Overview - 2014-05-12 - Humanities Division, Uni...
Research Data Management: An Overview - 2014-05-12 - Humanities Division, Uni...
 
Dbms
DbmsDbms
Dbms
 
Introduction to Research Data Management - 2014-02-26 - Mathematical, Physica...
Introduction to Research Data Management - 2014-02-26 - Mathematical, Physica...Introduction to Research Data Management - 2014-02-26 - Mathematical, Physica...
Introduction to Research Data Management - 2014-02-26 - Mathematical, Physica...
 
Chapter 12.pptx
Chapter 12.pptxChapter 12.pptx
Chapter 12.pptx
 
Introduction to File System
Introduction to File SystemIntroduction to File System
Introduction to File System
 
Computer Science 12th Topic- introduction to syllabus.pdf
Computer Science 12th Topic- introduction to syllabus.pdfComputer Science 12th Topic- introduction to syllabus.pdf
Computer Science 12th Topic- introduction to syllabus.pdf
 
An Efficient Approach to Manage Small Files in Distributed File Systems
An Efficient Approach to Manage Small Files in Distributed File SystemsAn Efficient Approach to Manage Small Files in Distributed File Systems
An Efficient Approach to Manage Small Files in Distributed File Systems
 
Dbms
DbmsDbms
Dbms
 
Dbms
Dbms Dbms
Dbms
 
27 fcs157al2
27 fcs157al227 fcs157al2
27 fcs157al2
 
Electronic Data Processing
Electronic Data ProcessingElectronic Data Processing
Electronic Data Processing
 
Chapter12
Chapter12Chapter12
Chapter12
 
Data management for TA's
Data management for TA'sData management for TA's
Data management for TA's
 
David Shotton - Research Integrity: Integrity of the published record
David Shotton - Research Integrity: Integrity of the published recordDavid Shotton - Research Integrity: Integrity of the published record
David Shotton - Research Integrity: Integrity of the published record
 
Dbms
DbmsDbms
Dbms
 

Recently uploaded

一比一原版(BU毕业证)波士顿大学毕业证成绩单
一比一原版(BU毕业证)波士顿大学毕业证成绩单一比一原版(BU毕业证)波士顿大学毕业证成绩单
一比一原版(BU毕业证)波士顿大学毕业证成绩单
ewymefz
 
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
ewymefz
 
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Subhajit Sahu
 
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
slg6lamcq
 
一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单
ocavb
 
standardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghhstandardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghh
ArpitMalhotra16
 
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdfCh03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
haila53
 
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
nscud
 
SOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape ReportSOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape Report
SOCRadar
 
一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单
enxupq
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
ewymefz
 
一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单
enxupq
 
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
ahzuo
 
Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...
Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...
Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...
pchutichetpong
 
Machine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptxMachine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptx
balafet
 
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
ukgaet
 
Adjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTESAdjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTES
Subhajit Sahu
 
一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单
ewymefz
 
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
ewymefz
 
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
yhkoc
 

Recently uploaded (20)

一比一原版(BU毕业证)波士顿大学毕业证成绩单
一比一原版(BU毕业证)波士顿大学毕业证成绩单一比一原版(BU毕业证)波士顿大学毕业证成绩单
一比一原版(BU毕业证)波士顿大学毕业证成绩单
 
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
 
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
 
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
 
一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单
 
standardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghhstandardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghh
 
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdfCh03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
 
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
 
SOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape ReportSOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape Report
 
一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
 
一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单
 
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
 
Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...
Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...
Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...
 
Machine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptxMachine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptx
 
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
 
Adjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTESAdjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTES
 
一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单
 
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
 
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
 

14. Files - Data Structures using C++ by Varsha Patil

  • 1. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 1
  • 2. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 2  The purpose of standard data organization methods  Various file organizations and their application-specific suitability such as sequential file, indexed sequential file, and direct access file  The advantages and disadvantages of file organizations
  • 3. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 3  Records that hold information about similar items of data are usually grouped together into ‘file’  A file is a collection of records where each record consists of one or more fields
  • 4. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 4  External storage devices are mainly used for the following:  Overlay or backup of programs during execution  Storage of programs for future use  Storage of information in files External storage device
  • 5. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 5  The most common external storage devices in order of their use, and study :  magnetic tapes,  drums, and  disk drives  When we organize data in ‘file’ data structure, the data is non- volatile, which means data will reside on storage after data processing is over
  • 6. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 6  A tape is made up of a plastic material coated with a ferrite substance that is easily magnetized  The physical appearance of the tape is similar to the tape used for sound recording.  A limitation of magnetic tape devices is that records must be processed in the order in which they reside on the tape
  • 7. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 7  A magnetic drum is a metal cylinder, from 10 to 36 inches in diameter, which has an outside surface coated with a magnetic recording material  The cylindrical surface of the drum is divided into a number of parallel bands called tracks  The tracks are further divided into either sectors or blocks, depending on the nature of the drum  The sector or block is the smallest addressable unit
  • 8. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 8  The magnetic disk is a direct access storage device, which has become more widely used than the magnetic drum, mainly because of its lower cost
  • 9. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 9  The proper arrangement of records within a file is called as file organization
  • 10. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 10  Different Schemes of File Organizations  Sequential file  Direct or random access file  Indexed sequential file  Multi-Indexed file
  • 11. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 11  In sequential file, records are stored in the sequential order of their entry  This is the simplest kind of data organization
  • 12. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 12  Though we search records using key, we still need to know the address of the record to retrieve it directly  The file organization that supports Files such access is called as direct or random file organization
  • 13. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 13  File—Records are stored sequentially but the index file is prepared for accessing the record directly  An index file contains records ordered by a record key  The record key uniquely identifies the record and determines the sequence in which it is accessed with respect to other records
  • 14. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 14  In multi-indexed file, the data file is associated with one or more logically separated index files  Inverted files and multilist files are examples of multiindexed files
  • 15. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 15  The factors that affect file organization are mainly the following:  Storage device  Type of query  Number of keys  Mode of retrieval/update of record Factors Affecting File Organization
  • 16. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 16  Speed  Operations  Capacity  Size  Security Factors Involved in Selecting File Organization
  • 17. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 17  File I/O Classes  Primitive Functions Files  Binary and Text File FILES USING C++
  • 18. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 18  The I/O system of C++ contains a set of classes that define the file handling methods  They are ifstream, ofstream, and fstream  These classes are included in ‘fstream.h’ header file  ifstream—This class provides input operations  ofstream—This class provides output operations  fstream—This class provides both input and output operations  File I/O Classes
  • 19. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 19  There are several ways of reading (or writing) the text from (or to) a file  But all of them have a common approach as follows  Open the file  Read (or write) the data  Close the file Primitive Functions
  • 20. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 20  Binary and Text File  The binary file consists of binary data  It can store text, graphics, sound data in binary format  The binary files cannot be read directly  Text File  The text file contains the plain ASCII characters  It contains text data which is marked by ‘end of line’ at th end of each record  This end of record marks help easily to perform operations such as read and write  Text file cannot store graphical data
  • 21. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 21  The order of the records is fixed  Within each block, the records are in sequence  A sequential file stores records in the order they are entered  New records always appear at the end of the file  Primitive Operations  Features of Sequential File Organization  Drawbacks of Sequential File Organization
  • 22. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 22  Open—This opens the file and sets the file pointer to immediately before the first record  Read-next—This returns the next record to the user. If no record is present, then EOF condition will be set  Close—This closes the file and terminates the access to the file  Write-next—File pointers are set to next of last record and write the record to the file
  • 23. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 23  Write-next—File pointers are set to next of last record and write the record to the file  EOF—If EOF condition occurs, it returns true, otherwise it returns false  Search—Search for the record with a given key  Update—Current record is written at the same position with updated values
  • 24. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 24  Insertion and deletion of records in in-between positions huge data movement  Accessing any record requires a pass through all the preceding records, which is time consuming. Therefore, searching a record also takes more time.  Needs reorganization of file from time to time. If too many records are deleted logically, then the file must be reorganized to free the space occupied by unwanted records
  • 25. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 25  Files that have been designed to make direct record retrieval as easy and efficiently as possible is known as directly organized files  Direct access files are of great use for immediate access to large amounts of information  They are often used in accessing large databases
  • 26. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 26 Beginning of file Current position End of file 0 1 2 SEEK_SET SEEK_CUR SEEK_END Origin Value Macro Name
  • 27. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 27 0 Origin Value Macro Name Beginning of file Current position End of file 0 1 2 SEEK_SET SEEK_CUR SEEK_END
  • 28. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 28 0 Origin Value Macro Name Beginning of file Current position End of file 0 1 2 SEEK_SET SEEK_CUR SEEK_END
  • 29. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 29  A file that is loaded in key sequence but can be accessed directly by use of one or more indices is known as an indexed sequential file  A sequential data file that is indexed is called as indexed sequential file  A solution to improve speed of retrieving target is index sequential file  An indexed file contains records ordered by a record key  Each record contains a field that contains the record key
  • 30. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 30 Advantages  Accessing any record is more efficient than sequential file organization  Large amount of data can be stored using this type of file organization Disadvantages  Often more than one indices are needed which occupies large storage area
  • 31. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 31  Primary index  It is an index ordered in the same way as the data file, which is sequentially ordered according to a key  The indexing field is equal to this key  Secondary index  An index that is defined on a non-ordering field of the data file  In this case, the indexing field need not contain unique values
  • 32. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 32  Clustering indexes  A data file can associate with utmost one primary index and several secondary indexes  The single-level indexing structure is the simplest one where a file, whose records are pairs, contains a key and a pointer  The single-level indexing structure is the simplest one where a file, whose records are pairs, contains a key and a pointer
  • 33. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 33 Index file consists of three areas:  A primary storage area—This includes some unused space to allow for additions made in data  A separate index or indexes—Each query will reference this index first; it will redirect query to part of data file in which the target record is saved  An overflow area—This is optional separate overflow area
  • 34. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 34  Records are stored sequentially but the index file is prepared for accessing the record directly  Records can be accessed randomly  File has records and also the index Magnetic tape is not suitable for index sequential storage  Index is the address of physical storage of a record  When randomly very few are required/accessed, then index sequential is better  Faster access method Addition overhead is to maintain index Index sequential files are popularly used in many applications like digital library
  • 35. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 35  In linked organization, the physical sequence of records is different from the logical sequence of records  The next logical record is obtained by following a link value from the present record  Multilist Files  Coral Rings  Inverted Files  Cellular Partitions
  • 36. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 36  To make searching easy, several indexes are maintained as per primary key and secondary keys, one index per key  The record may be present in different lists as per key
  • 37. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 37  Consider the following file of office staff Staff ID Occupation Salary Record 106 Clerk 5000 A 150 Account 4000 B 360 clerk 3000 C 400 Account 3500 D 700 Clerk 2000 E
  • 38. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 38  We can maintain index on the staff ID  We can group staff ID with range 101– 300, 301–600, 601–900, etc  Now all the records with staff ID in the same range will be linked together as shown in Figure Sample multilist file Staff range Link 101-300 301-600 601-900 rec A rec C rec E rec B rec D
  • 39. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 39  In this doubly linked multilist structure is used. Each list is circular list with headnode  A C E Alink Clerk Blink S Blink Sample doubly linked list
  • 40. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 40  ‘Alink’ field is used to link all records with same key value  ‘Blink’ is used for some records back pointer and for others it is pointer to head node  Owing to these back pointers, deletion is easy without going to start.  Indexes are maintained as per multilists
  • 41. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 41  With the same key value are linked together and links are kept in each record  But in the inverted files, the link information is kept in the index itself
  • 42. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 42 106 A 150 B 360 C 400 D 700 E Accountant B,D Clerk A,C,E Salary Index 2000 E 4000 B,C,D 6000 A
  • 43. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 43  The inversion process is associated with the information of inverted list  In inverted files, the record is accessed in two steps. First, the indices are searched to obtain a list of required records and then second, records are retrieved using these lists  The number of disk accesses required is equal to the number of records being retrieved plus the number to process the indices  In inverted files, only the index structures are important
  • 44. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 44  To decrease file search time, the storage media may be divided into cells  A cell may be an entire disk or a cylinder. Lists are localized to lie within a cell  If a cylinder is used as a cell, then all records on the same cylinder may be accessed without moving the read/write heads  We divide multilists organized on several different cylinders into several small lists which are stored on the same cylinder
  • 45. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 45 Position Student ID T. ID Link 1 100 A 2 200 B Null 3 300 C Null 4 400 A Null 1 500 D 2 600 B Null 3 700 A Null 4 800 D Null 1 900 E Null 2 1000 C Null 3 1100 D Null 4 1200 A Null Primary key Secondary key
  • 46. Oxford University Press © 2012Data Structures Using C++ by Dr Varsha Patil 46