0% found this document useful (0 votes)
108 views2 pages

User-Defined Data Types and File Organization

Uploaded by

laibaoha
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
108 views2 pages

User-Defined Data Types and File Organization

Uploaded by

laibaoha
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd

CHAP 13.

what is user-defined data types?

-> A non-existing data type which the programmer has created fo


r use within a program to meet up some specific criteria.

Differ data types:

[Link]-composite data

+ Data defined without the referencing to other data type


a) Enumerated -> [TYPE <identifier> = (value1, value2, value3, ... )] b) P
ointer -> [TYPE <pointer> = ^<Typename>] refer to a memory location

[Link] data

+ Data defined referencing to other data type

CHAP 13.2

why organise file?


-> files are stored in order to be able to find data efficiently. Data i
s stored as RECORDS in file.

Differ file organisation method:

1. serial file organisation

+ Records of data are stored in chronological order in file.


+ Used for temporary files storing transaction.

2. sequential file organisation

+ Records of data are store in order which based on the key field
of the records (unique identifier) in file.

3. random file organisation

+ Records of data are sotred in random order that is available at


the time.

+ Can find the data using hashing algorithm.

Differ file access method:

1. sequential access

+ Searches for the records one after another from the begining til
l records is found.

benefits: less effort, simplicity (payroll systemt, month bill)

2. direct access

+ Can be accessed directly without having to read all preceding r


ecords.

+ Can find using key field or hashing algorithm

Hashing algorithm

1. open hash where the record is stored in the next free space.

2. closed hash where an overflow is occurs, records is stored in t


he next available in overflow area.

Common questions

Powered by AI

Serial file organisation is most effectively used in scenarios where data is processed in the order of arrival, such as logging systems or storing temporary transaction data. This approach is beneficial when records do not require frequent access or specific ordering, as it simplifies data storage and retrieval by maintaining a chronological sequence without needing complex indexing .

Non-composite user-defined data types do not reference other data types and include enumerated types and pointers. Enumerated types are defined with specific values, and pointers reference memory locations. Composite data types, on the other hand, are defined by referencing other data types, allowing for the creation of more complex data structures .

Sequential file organisation enhances efficient retrieval by storing records ordered by a key field, which acts as a unique identifier, allowing systematic searching. This contrasts with random file organisation, where records are stored at any available location and require hashing algorithms to locate them, potentially leading to longer retrieval times if collisions occur or if open hashing is employed .

Organising files is critical for efficient data retrieval in computing systems. It allows systems to store data in a structured manner, making it easier to locate, access, and manipulate. Proper file organisation minimizes the time and resources needed to manage data, supports consistency, and enhances system performance, especially in operations involving large data sets or frequent access .

Random file organisation can lead to inefficient data retrieval due to the lack of predictable ordering of records, necessitating more complex access methods like hashing, which can be slower if collisions are frequent. Unlike sequential file organisation, which allows straightforward access based on a key field, random organisation may also complicate data management and increase the risk of fragmentation, making it less suitable for systems prioritizing quick access and data integrity .

Direct access methods allow for immediate retrieval of data without the need to read preceding records. This significantly reduces search time compared to sequential access, which requires reading records one by one until the desired record is found. Direct access is particularly beneficial in systems where speed is crucial, such as databases with large volumes of transactions, utilizing key fields or hashing strategies for quick look-up .

A programmer might choose to use user-defined data types to tailor data structures to meet specific application requirements, allowing for more efficient and organized code. These types provide clarity by using meaningful descriptors, enable data integrity by restricting value ranges through enumerated types, and offer dynamic memory control via pointers. This enhances code readability, maintainability, and reduces the risk of errors .

Open hashing handles collisions by storing records in the next free space available, allowing the overflow of records into additional spaces within the same or a secondary storage area. Closed hashing, however, deals with collisions by using an overflow area specifically reserved for additional storage when the primary location is occupied, ensuring that records remain linked to their initial key location .

Hashing algorithms play a crucial role in random file organisation by providing a method to quickly locate records without a predefined order in file storage. They map key fields to specific memory locations, optimizing access time. In cases of collisions, where two keys hash to the same address, techniques such as open and closed hashing manage data storage efficiently. This process is essential for maintaining data retrieval efficiency in environments with large, unordered datasets .

An enumerated user-defined data type explicitly lists and restricts values it can hold, useful for variables that only need specific, predefined values, such as days of the week. In contrast, a pointer is a reference to a memory location, providing the flexibility to handle dynamic data structures and manage memory directly. This difference influences their application in terms of defining strict data lists versus managing dynamic data structures and memory allocation .

You might also like