00:00In the hash map, there is such a data structure in Java which works to store the table of information.
00:05For example, if I take an example of a restaurant menu. If you go to a canteen, restaurant, hotel, if
00:13you look at the menu, there are many items in the menu. For example, the menu is tea, tea, and
00:19then the price is written. The price is written in the menu. For example, the price is 10 rupees. Moreover,
00:23we have a samosa. The price is 15 rupees. Moreover, we have a pizza.
00:29Pizza price is $250. Burger price is $50. Coffee price is $50. In this way, there are many items on
00:43the menu and all the prices. Now, each item is unique on the menu.
00:49Unique means that if you give the chai price of 10 Rs, then you will not get the chai price
00:56of 30 Rs. So this is the key, this is the item, this is unique. This is the key value
01:03in the pairs form.
01:05Pair or Joda can visualize or store that data we store in HashMaps. Pair means that one has a key
01:15and one has a value. Key is our main identifier. That is the value which we will recognize and each
01:23key will have its value. If a tea becomes a key, it will be its price for the chai. If
01:29a pizza becomes a key, it will be value for its price.
01:35a key will become a value and its price will be 50. In this way, our key will become our
01:41objects and its value will become my price. Now there is another unique thing in this key value pair. This
01:48key value is unique in my data.
01:53You will see the chai, the samosa, the pizza, and the burger. It is not like that. The key will
02:00repeat the items. But yes, the price will repeat the items. Like the value in all the items, you can
02:05think that in this pair, I have value and in this pair, the value, both data are same. But it
02:13will never happen that the key is same. So the key is always unique. This is a very important point
02:19in the maps. If I thought yesterday that
02:22T which is the price of $15, so this will be a new
02:26We don't add items in the menu. Usually, what do we do? We cut the price of the old item
02:30and put a new price there. Or if we believe that we have the burger, it's finished in the shop.
02:37So, what do we do? Simply go there and remove this item. So, when we store this type of data,
02:42when we store it in the hash map type structure. We can also visualize the hash map in the table
02:48and in the notes. So, if I want this data, I can also make it like this.
02:55That I have my whole map. I have nodes in the map. Like my first node, which I have stored
03:01in tt with 15 rupees. My second data is samosa. I have stored in the samosa and its price is
03:0815. The third data I have is pizza. I have stored in pizza for 250. The fourth item is coffee.
03:15I have stored in coffee for 50 rupees. In this way, my whole data is stored in my map. Let's
03:23talk about time complexity here.
03:25In the hash maps, the time complexity of my insert, remove and search of time complexity is used in the
03:34big of one. You have a menu. If you want to find coffee on the normal user menu, then you
03:43will do one-one-one-one-one-one-one. Please call the waiter.
03:48in the hotel or in the restaurant or in the cafe. So you will ask what the price of coffee
03:52is, so you remember it first. So what do you need to do? You don't need to put a linear
03:56loop in your mind or in the menu. It's stored in your memory that for coffee, for it's key, this
04:04price means this value. So it has directly told you. So the waiter works for us, our HashMap, which stores
04:12all the data in this way, that in constant time, we get a price of some item.
04:18Besides, we can see another example. Let's take another example of a country map. Every country has a population of
04:26each country. Like if I make a table type data for my country and its populations. So, let's assume that
04:32the first country will come to me, whether or not, the population will be 150.
04:37Another country I would like to buy India. I would like to buy India's population of 100. Another country I
04:42would like to buy India's population of 50. Another country I would like to buy India's population of 50. Another
04:46country I would like to buy India's population of 50. Another country I would like to buy India's population of
04:5150.
04:53I will take Bhutan, so I will have one here. So in this way, many countries can have their own
04:59population. These data can be organized in a tabular form. These countries will be key for me and their population
05:08will be value for me. Because the name of the country will always be unique. It will be possible that
05:12Bhutan population will be equal to Indonesia, so this will be 6. So in that case, both population will be
05:19equal. So value
05:22So the same can happen. But the key always needs to be unique. So here the key value will be
05:27unique.