Program: BE (Computer Engineering & Information Technology) Class: SE Course: Data Structure & Algorithm Unit 01: Introduction to DSA & Hashing Introduction to Data Structure & Algorithms Data a collection of discrete or continuous values that convey information, describing the quantity, quality, fact, statistics, other basic units of meaning, or simply sequences of symbols that may be further interpreted formally. Data : Information in a form a computer can use. Information : Any knowledge that can be communicated. A data structure is a specialized format for organizing, processing, retrieving and storing data. There are several basic and advanced types of data structures, all designed to arrange data to suit a specific purpose. Data structures make it easy for users to access and work with the data they need in appropriate ways. www.sandipuniversity.edu.in Department of Computer Engineering, PVGCOE&SSDIM, Nashik 04 Introduction to Data Structure & Algorithms www.sandipuniversity.edu.in Department of Computer Engineering, PVGCOE&SSDIM, Nashik 04 Why Data Structure & Algorithms www.sandipuniversity.edu.in Department of Computer Engineering, PVGCOE&SSDIM, Nashik 04 Why Data Structure & Algorithms www.sandipuniversity.edu.in Department of Computer Engineering, PVGCOE&SSDIM, Nashik 04 Why Data Structure & Algorithms www.sandipuniversity.edu.in Department of Computer Engineering, PVGCOE&SSDIM, Nashik 04 Why Data Structure & Algorithms www.sandipuniversity.edu.in Department of Computer Engineering, PVGCOE&SSDIM, Nashik 04 Why Data Structure & Algorithms www.sandipuniversity.edu.in Department of Computer Engineering, PVGCOE&SSDIM, Nashik 04 Why Data Structure & Algorithms www.sandipuniversity.edu.in Department of Computer Engineering, PVGCOE&SSDIM, Nashik 04 Why Data Structure & Algorithms www.sandipuniversity.edu.in Department of Computer Engineering, PVGCOE&SSDIM, Nashik 04 Hashing www.sandipuniversity.edu.in Department of Computer Engineering, PVGCOE&SSDIM, Nashik 04 Hashing Components of Hashing There are majorly three components of hashing: Key: A Key can be anything string or integer which is fed as input in the hash function the technique that determines an index or location for storage of an item in a data structure. Hash Function: The hash function receives the input key and returns the index of an element in an array called a hash table. The index is known as the hash index. Hash Table: Hash table is a data structure that maps keys to values using a special function called a hash function. Hash stores the data in an associative manner in an array where each data value has its own unique index. www.sandipuniversity.edu.in Department of Computer Engineering, PVGCOE&SSDIM, Nashik 04 Hash Function www.sandipuniversity.edu.in Department of Computer Engineering, PVGCOE&SSDIM, Nashik 04 Modular Hash Function www.sandipuniversity.edu.in Department of Computer Engineering, PVGCOE&SSDIM, Nashik 04 Modular Hash Function www.sandipuniversity.edu.in Department of Computer Engineering, PVGCOE&SSDIM, Nashik 04 Modular Hash Function www.sandipuniversity.edu.in Department of Computer Engineering, PVGCOE&SSDIM, Nashik 04 Hash Table www.sandipuniversity.edu.in Department of Computer Engineering, PVGCOE&SSDIM, Nashik 04 Hash Table www.sandipuniversity.edu.in Department of Computer Engineering, PVGCOE&SSDIM, Nashik 04 Hash Table www.sandipuniversity.edu.in Department of Computer Engineering, PVGCOE&SSDIM, Nashik 04 Hash Table www.sandipuniversity.edu.in Department of Computer Engineering, PVGCOE&SSDIM, Nashik 04 04 Collision Collision The hashing process generates a small number for a big key, so there is a possibility that two keys could produce the same value. The situation where the newly inserted key maps to an already occupied, and it must be handled using some collision handling technology. www.sandipuniversity.edu.in Department of Computer Engineering, PVGCOE&SSDIM, Nashik Collision How to handle Collisions? There are mainly two methods to handle collision: Separate Chaining: Open Addressing: www.sandipuniversity.edu.in Department of Computer Engineering, PVGCOE&SSDIM, Nashik 04 Separate Chaining www.sandipuniversity.edu.in Department of Computer Engineering, PVGCOE&SSDIM, Nashik 04 Separate Chaining www.sandipuniversity.edu.in Department of Computer Engineering, PVGCOE&SSDIM, Nashik 04 Separate Chaining www.sandipuniversity.edu.in Department of Computer Engineering, PVGCOE&SSDIM, Nashik 04 Separate Chaining www.sandipuniversity.edu.in Department of Computer Engineering, PVGCOE&SSDIM, Nashik 04 Hashing Applications of Hash Data structure Hash is used in databases for indexing. Hash is used in disk-based data structures. In some programming languages like Python, JavaScript hash is used to implement objects. Real-Time Applications of Hash Data structure Hash is used for cache mapping for fast access to the data. Hash can be used for password verification. Hash is used in cryptography as a message digest. Rabin-Karp algorithm for pattern matching in a string. Calculating the number of different substrings of a string. www.sandipuniversity.edu.in Department of Computer Engineering, PVGCOE&SSDIM, Nashik 04