Generally the Number of entries in the page table = the Number of Pages in which the process is divided. Some of the characteristics of the Page Table are as follows: The above diagram shows the paging model of Physical and logical memory. Thus page table mainly provides the corresponding frame number (base address of the frame) where that page is stored in the main memory.The data structure that is used by the virtual memory system in the operating system of a computer in order to store the mapping between physical and logical addresses is commonly known as Page Table.Īs we had already told you that the logical address that is generated by the CPU is translated into the physical address with the help of the page table. In this tutorial, we will cover some of the most common techniques used for structuring the Page table. Longest Remaining Time First Scheduling.* (A null return can also indicate that the mapįor (Entry e = table e != null e = e.next) operation may be used to distinguish these two cases.įor (Entry e = table e != null e = e. * the previous value associated with key, or * value value to be associated with the specified key * key key with which the specified value is to be associated * If the map previously contained a mapping for the key, the old * Associates the specified value with the specified key in this map. #Hash table in hindi codeNow, let’s see how put() method works in detail.īelow is the code implementation of put() method in the HashMap class. This method returns the index in the table array for that particular key-value pair. number of collisions (approximately 8 at default load factor).Īfter calculating the hash code of the key, it calls indexFor() method by passing the hash code of the key and length of the table array. constant multiples at each bit position have a bounded This function ensures that hashCodes that differ only by Note: Null keys always map to hash 0, thus index 0. * otherwise encounter collisions for hashCodes that do not differ * critical because HashMap uses power-of-two length hash tables, that * result hash, which defends against poor quality hash functions. * Retrieve object hash code and applies a supplemental hash function to the This function is implemented so that it overcomes poorly implemented hashCode() methods. HashMap has its own hash function to calculate the hash code of the key. Instead it calls hash function on the key. Whenever you insert new key-value pair using put() method, HashMap blindly doesn’t allocate slot in the table array. Hash function or simply hash said to be the best if it returns the same hash code each time it is called on the same object. This unique integer value is called hash code. Hashing is nothing but the function or algorithm or method which when applied on any object/variable returns an unique integer value representing that object/variable. The whole HashMap data structure is based on the principle of Hashing. Instead it uses the hashcode of the key to decide the index for a particular key-value pair. But how HashMap allocates slot in table array to each of its key-value pair is very interesting. It doesn’t inserts the objects as you put them into HashMap i.e first element at index 0, second element at index 1 and so on. Internally it uses an array of Entry class called table to store the key-value pairs. The above image roughly shows how the HashMap stores its elements. HashMap is the most sought after data structure when you are handling the big data with more preference to insertion and retrieval operations. These things will matter even more when you are handling the big data. Because insertion and retrieval are two operations which you perform very frequently in your applications. First one is that the data structure must give better performance while inserting the new elements and second one is that it should give even more better performance while searching for an element. While selecting the data structure, you must keep two things in your mind. If your application demands faster insertion and faster retrieval then HashMap is the ultimate choice. It is up to you to select which one is better for your application. Each of these are used in different scenarios. You can choose array, list, queue, set or map. Java provides wide range of data structures to handle the data. Because, data structure arranges the data so that insertion of new elements or searching of old elements will be faster. If the data is the most important part of an application, then data structure chosen to handle that data is even more important.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |