Posts

Showing posts from August, 2023

Data Structures : Linear List

Introduction Data Structure     A Data Structure is a named group of data of different data types which is stored in a specific way and can be processed as a single unit. A data structure has well-defined operations, behavior and properties.  Different Data structures  Data structures are very important in a computer system, as these not only allow the users to combine various data types in a group but also allow processing of the group as a single unit thereby making things much simpler and easier.  The data structures can be classified into two  types:   1. Simple Data Structures : These data structures are normally built from primitive data types like integers, characters, boolean etc. For example:- Arrays, Linear lists. 2. Compound Data Structures : Simple data structures can be used in various ways to form more complex structures called compound data structures. Compound data structures are classified into following two types:- Line...

File pointers and random access

Image
Introduction Every file maintains two pointers called get_pointer (in input mode file) and   put_pointer (in output mode file) which tell the current position in  the file where writing or reading will take place. These pointers help attain random access in file. That means moving directly to any location in the file instead of moving through it sequentially. There may be situations where random  access is the best choice. For example, if you have to modify a value in record no. 21 and then using a random access techniques, you can place the file pointer at the beginning of record 21 and then straightway process the record. If sequential access is used, then you'll have to unnecessarily go through first twenty records in order to reach at record 21. Functions used for random access In C++, random access is achieved by manipulating seekg(), seekp(), tellg() and   tellp()  functions.  The seekg() and tellg() functions allow you to set and examine ...