








Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
In the subject of the Data Structures, the key concept and the main points, which are very important in the context of the data structures are listed below:Maps, Relation, Set of Keys, Values, Object, Duplicate Keys, Implemented, Java Map Interface, Hashmap, Hashtable
Typology: Slides
1 / 14
This page cannot be seen from the preview
Don't miss anything!









Map is a relation between set of keys and set ofvalues
Java provides a Map interface Some implementing classes Hashmap^ Hashtable implementation of a map interface Hashtable^ Extended dictionary class Map Hashmap Hashtable
Taurus;Kesden, Greg RX-8;Slater, Don Accord;Mouse, Mickey Camry;Roberts, Jim Dakota;Pattis, Rich F-150;Stehlik, Mark I-300;McElfresh, Scott big yellow bus;Cortina, Tom
The Dictionary class is the abstract parent ofHashtable, which maps keys to values.
A Dictionary object, every key is associated with atmost one value
Given a Dictionary and a key, the associatedelement can be looked up
Any non-null object can be used as a key and as avalue.
Some Methods : get ( Object key) put ( Object key, Object value) remove ( Object key)
This implements the Map interface HashMap permits null values and null keys. Constant time performance for get and put operations HashMap has two parameters that affect its performance: initial capacity and load factor Capacity – number of buckets in the Hash Table Load factor – How full the Hash Table is allowed to get beforecapacity is automatically increased using rehash function.
More on Java HashMaps HashMapHashMapHashMapHashMap (int initialCapacity) putputputput
Object key, Object value) getgetgetget
Object key) – returns Object keySetkeySetkeySetkeySet () Returns a setsetsetset view of the keys contained in this map. valuesvaluesvaluesvalues () Returns a collectioncollectioncollectioncollection view of the values contained in this map.
public class HashSet Implements Set interface using HashTable Offers constant time performance public class TreeSet Implements Set interface using TreeMap Sorted set will be ascending order according to thenatural order
Write a method public static Set intersect(Set A, Set B) That takes two sets A and B and return theintersection of the two sets Write a method public static Set union(Set A, Set B) That takes two sets A and B and return the union ofthe two sets