Unit5 Lect5 Hashing
Unit5 Lect5 Hashing
Programming
BTEXPE506C 3 Credits
Course Objectives:
• To assess how the choice of data structures and algorithm design methods impacts the performance of
programs.
· To choose the appropriate data structure and algorithm design method for a specified application.
· To solve problems using data structures such as linear lists, stacks, queues, binary trees, binary search trees,
and graphs and writing programs for these solutions.
To study the systematic way of solving problems, various methods of organizing large amounts of data.
To employ the different data structures to find the solutions for specific problems
Course Outcomes:
JAVA Information
https://www.javatpoint.com/features-of-java
UNIT – 1
Introduction
• Basic Terminologies: Elementary Data Organizations, Data Structure Operations: insertion, deletion, traversal
etc.; Analysis of an Algorithm, Asymptotic Notations, Time-Space trade off. Searching: Linear Search and
Binary Search Techniques and their complexity analysis.
UNIT – 2
Stacks and Queues
• ADT Stack and its operations: Algorithms and their complexity analysis,
• Applications of Stacks: Expression Conversion and evaluation – corresponding algorithms and complexity
analysis.
• ADT queue, Types of Queue: Simple Queue, Circular Queue, Priority Queue; Operations on each type of
Queues: Algorithms and their analysis.
UNIT – 3
Linked Lists
• Singly linked lists: Representation in memory, Algorithms of several operations: Traversing, Searching,
Insertion into, Deletion from linked list; Linked representation of Stack and Queue, Header nodes,
• doubly linked list: operations on it and algorithmic analysis;
• Circular Linked Lists: all operations their algorithms and the complexity analysis.
UNIT – 4
Trees
• Basic Tree Terminologies, Different types of Trees: Binary Tree, Threaded Binary Tree, Binary Search Tree,
AVL Tree; Tree operations on each of the trees and their algorithms with complexity analysis.
• Applications of Binary Trees, B Tree, B+ Tree: definitions, algorithms and analysis.
UNIT – 5
Sorting and Hashing
• Objective and properties of different sorting algorithms: Selection Sort, Bubble Sort,
• Insertion Sort, Quick Sort, Merge Sort, Heap Sort; Performance and Comparison among all the methods,
Hashing.
UNIT – 6
Graph
• Basic Terminologies and Representations, Graph search and traversal algorithms and complexity analysis.
• TEXT/REFERENCE BOOKS
1. “How to Solve it by Computer”, 2nd Impression by R. G. Dromey, Pearson Education.
2. Ellis Horowitz, Sartaj Sahni, “Fundamentals of Data Structures”, Galgotia Books Source. ISBN 10:
0716782928
3. Java: The Complete Reference, Seventh Edition, Herbert Schildt, McGraw Hill
4. Richard F. Gilberg & Behrouz A. Forouzan, Data Structures: A Pseudocode Approach with C, Cengage
Learning, second edition. ISBN-10: 0534390803.
5. Seymour Lipschutz, Data Structure with C, Schaum‟s Outlines, Tata Mc Graw Hill. ISBN-10: 1259029964.
6.John Hubbard Anita Huray, “ Data Structures with JAVA”, Person Education
UNIT – 5
https://www.youtube.com/watch?v=j612Fj-mgCY
https://www.youtube.com/watch?v=zeMa9sg-VJM
What is Hashing in Data
Structure?
• Hashing in the data structure is a technique of mapping a
large chunk of data into small tables using a hashing function.
It is also known as the message digest function. It is a
technique that uniquely identifies a specific item from a
collection of similar items.
• It uses hash tables to store the data in an array format. Each
value in the array has assigned a unique index number. Hash
tables use a technique to generate these unique index
numbers for each value stored in an array format. This
technique is called the hash technique.
• Hashing in a data structure is a two-step process.
1.The hash function converts the item into a small
integer or hash value. This integer is used as an index
to store the original data.
2.It stores the data in a hash table. You can use a hash
key to locate data quickly.
Hash Function
import java.util.*;
public class Hashing1 {
public static void main(String args[]) {
Hashtable<Integer, String> hm = new
Hashtable<Integer, String>(); hm.put(1,
"App"); hm.put(12, "Dividend"); hm.put(15,
"Best place to learn"); hm.put(3, "Java");
System.out.println(hm); }
}
Best Time
Algorithm Approach
Complexity
Split the array into smaller subarrays till pairs of
Merge Sort elements are achieved, and then combine them in O(n log (n))
such a way that they are in order.
Build a max (or min) heap and extract the first
element of the heap (or root), and then send it to the
Heap Sort O(n log (n))
end of the heap. Decrement the size of the heap and
repeat till the heap has only one node.
In every run, compare it with the predecessor. If the
current element is not in the correct location, keep
Insertion Sort O (n)
shifting the predecessor subarray till the correct
index for the element is found.
Find the minimum element in each run of the array
Selection Sort and swap it with the element at the current index is O(n^2)
compared.