Ques-1- Hashed indexing and binary tree indexing.

Ans - Hash Indexing
A Hash table is one of the simplest index structures which a database can implement. The major components of a hash index are the "hash function" and the "buckets". Effectively the DBMS constructs an index for every table you create that has a PRIMARY KEY attribute, like: CREATE TABLE test ( id INTEGER PRIMARY KEY , name varchar (100) ); The algorithm splits the places which the rows are to be stored into areas. These areas are called buckets. If a row's primary key matches the requirements to be stored in that bucket, then that is where it will be stored. The algorithm to decide which bucket to use is called the hash function. For our example we will have a nice simple hash function, where the bucket number equals the primary key. When the index is created we have to also decide how many buckets there are. In this example we have decided on 4.

Figure: Hash Table with no collisions Now we can find id 3 quickly and easily by visiting bucket 3 and looking into it.

And then finally 6. . The more collisions we have the longer the collision chain and the slower the system will get. For instance. This is called a hash collision. And then finding id 2. Then 10.Figure: Hash Table with collisions We have had to put more than 1 row in some of the buckets. finding id 6 means visiting bucket 2.

It is easier as compared to a B-Tree. a copy of low-order key value from the rightmost node is promoted to be the separator key value in the parent node.e. row ids) in which the corresponding records are stored. The top most level of the index is called the root.It terminates in a node in the sequence set. D H A B C D E F G H I J K L B. All other levels in between are called branches. Also not every key in the index set need to appear in the sequence set.B-Tree Indexing The B-Tree Index is the default index for most relational database systems. When a key value is deleted from a leaf. Leaf nodes consisting of the index key and pointers pointing to the physical location (i.It is done almost the same way as insertion of a new key into a B-tree. When a leak node is split into two nodes. since the deleted keys are retained in the index set. there is no need to delete that key from the index of the tree. the preceding pointer is followed until the correct leaf is reached. Both the root and branch contain entries that point to the next level in the index. The lowest level is called the leaf node. Searching a B Tree. The key value still can direct searches to proper leaves. Inserting a new key. Deleting a key. The new node also must be inserted in the linked list of the sequence set..Tree Indexing . If there is a key in the index that matches the sought key.

And these modules can be further divided thus forming a Tree. So. For example. 3) We can insert/delete keys in moderate time (quicker than Arrays and slower than Unordered Linked Lists)..Used in almost every 3D video game to determine what objects need to be rendered.Used in almost every high-bandwidth router for storing router-tables.g.) There is no restriction as to how many children each node has in a heap. a heap is a specialized tree-based data structure that satisfies the heap property: if B is a child node of A. and in the sorting algorithm heap sort. Father / \ st Child (1 Born) Child (2nd Born) Hence we can have many such hierarchical structures like Family Tree. tree is hierarchical (or non-linear) data structure.Grand Father / \ . 5) Heaps: In computer science. Self-balancing search trees like AVL guarantee an upper bound of O (Logn) for insertion/deletion. although in practice each node has at most two Heaps are crucial in several efficient graph algorithms such as Dijkstra's algorithm. It aims at dividing complex software system into functionally independent modules.Ques-2.Applications of Trees Unlike Array and Linked List. BST). 7) Binary Trees . 1) One reason to use trees might be because you want to store information that naturally forms a hierarchy.What is Application of Trees? Ans . and so such a heap is sometimes called a max-heap. This reduces the time to develop software. Business Corporate Structure. Self-balancing search trees like AVL guarantee an upper bound of O (Logn) for search. . the smallest element is always in the root node. that each can be developed independently. if the comparison is reversed. then key (A) ≥ key (B). and Government Structure. 6) Binary Space Partition . we can search for a given key in moderate time (quicker than Linked List and slower than arrays). which results in a min-heap. which are linear data structures. the file system on a computer: Family Tree ———/ ----. 2) If we organize keys in form of a tree (with some ordering e. This implies that an element with the greatest key is always in the root node.. 4) Development Software Technique Modularization. (Alternatively.

4. • This minimizes number of block accesses. use it. • Records in a sequential file can be of varying lengths 5. • Problem: we now have some records out of physical sequential order. Sequential File Organization 1. • Deletion can be managed with the pointer chains. • Records are chained together by pointers to permit fast retrieval in search key order. • Adjust pointers accordingly. • If very few records in overflow blocks. It is difficult to maintain physical sequential order as records are inserted and deleted.Ques-3. the pointer fields are no longer required.Write a short note on different types of file organisations? Ans . Advantages • Easy to handle • Involves no overhead • Can be stored on tapes as well as disks • Well suited for batch-oriented applications. If insertions rarely occur. 2. • Insertion poses problems if no space where new record should go. • If space. • Records are stored physically in search key order (or as close to this as possible). In this case. Disadvantages • Records can only be accessed in sequence • Does not support updating operation in place • Does not support interactive applications . A sequential file is designed for efficient processing of records in sorted order on some search key. 3. • Reorganizations are expensive and done when system load is low.(a). we could keep the file in physically sorted order and reorganize when insertion occurs. else put new record in an overflow block. • Pointer points to next record in order. this will work well. • If order is lost. reorganize the file.

4. • The records are stored at known address. Random or Relative File Organisation 1. • Records do not necessarily appear physically in sorted order by their keys • A random file would have to be stored on a direct access backing storage medium e. • Serial access can also be made by a program while generating mailing labels for each customer 3. but the keys may not be in logical sequence. randomly • Well suited for interactive (on-line) applications • Support updating operation in place • Concurrent processing is possible. • There is a predictable relationship between the key and record's location in file • Address is calculated by applying a mathematical function to the key field. Basic Features • Records are read directly from or written on to the file. Advantages • Records can be accessed out-of-sequence. • Speed of record processing is very fast. Disadvantages • Can only be stored on disks • Involve more overhead in the form of maintenance of indexes • Handling bit complex as compared to sequential files • Records can only be of fixed length • Does not fully use memory locations • More security and backup problems . magnetic disc.g. • It can be accessed serially when input to a sort/merge utility. Other types of access of a random file • Random file can be accessed sequentially. CD.(b). DVD 2.

When querying a file there are certain circumstances when the query is designed to be modal which means that rules are set which require that different information be held in the index. These types of file are also known as "inverted indexes. .. Thus. • A full index to a file is one in which there is an entry for every record. • An indexed sequential file can only be stored on a random access device e.." Inverted list files use more space and the storage devices get full quickly with this type of organization. The benefits are apparent immediately because searching is fast. 2. • Indexed sequential files are important for applications where data needs to be accessed. updating is much slower. sorted into order of a key field) which has an index. Here's an example. Disadvantages • Extra storage space required • Can only be stored on disks • Involve more overhead in the form of maintenance of indexes • Handling bit complex as compared to sequential files • Records can only be of fixed length (d) Inverted File Organisation In file organization. Randomly using the index. an index could be maintained for all products. but indexes are updated for the record keys and location. sequentially 2. and another one might be maintained for product types. Advantages • Records can be accessed sequentially or randomly • Supports interactive as well as batch-oriented applications • Support updating operation in place • Faster than sequential 3. • An indexed sequential file is a sequential file (i..g.(c) Indexed or Linked File Organisation 1. Basic Features • Each record of a file has a key field which uniquely identifies that record.. The records are not necessarily stored in a sequence. 1. it is faster to search the indexes than every record. CD. The inverted list method has a single index for each key type. Data items in these systems are usually stored compressed which would normally slow the retrieval process. Content-based queries in text retrieval systems use inverted indexes as their preferred mechanism. • An index consists of keys and addresses. but the compression algorithm will be chosen to support this technique. a file is indexed on many of the attributes of the data itself. They are placed in the data storage area.e. in a company file. magnetic disc. However.

In C it is the compound data in a structure.Records: A record is an instance of a product of primitive data types called a tuple. a month field represented as a string. typically in fixed number and sequence and typically indexed by names. For example. each field has a name. The definition includes specifying the data type of each field and an identifier (name or label) by which it can be accessed. including main memory and mass storage devices such as magnetic tapes or hard disks. A record is a value that contains other values. A record type is a data type that describes such values and variables.Write a short note on records? Ans . . often grouped into larger physical records or blocks for efficiency. a date may be stored as a record containing a numeric year field. in most object-oriented languages. Records are distinguished from arrays by the fact that their number of fields is typically fixed. the return address. in the call stack that is often used to implement procedure calls. and that each field may have a different type. or the implementation of an abstract product type in a specific language. each entry is an activation record or call frame. Most modern computer languages allow the programmer to define new record types. and object data types (often called object classes) are an elaboration of record types. especially linked data structures. and the arguments passed to that function can be viewed as a record value that gets assigned to that variable at the time of the call. The elements of records are usually called fields or members. An object in object-oriented language is essentially a record that contains procedures specialized to handle that record. and other internal fields. Many computer files are organized as arrays of logical records. Indeed. Records are among the simplest data structures. The parameters of a function or procedure can often be viewed as the fields of a record variable. records are just special cases of objects. containing the procedure parameters and local variables. Records are a fundamental component of most data structures. In the same vein.Ques-4. a record type can be viewed as the computer language analogue of the Cartesian product of two or more mathematical sets. Also. Records can exist in any storage medium. A record can be viewed as the computer analogue of a mathematical tuple. and a numeric day-of-month field.

Sign up to vote on this title
UsefulNot useful