Limited Period Offer : 20% Discount on online/offline courses, for more details call/whatsapp

HashMaps

0 min read
1 year ago By Aniket Prajapati

HashMaps:

HashMaps are used to store the data as in the form of its keys and vales . Also Maps can be used so that suppose you have to do certain operation but for that you need to store the previous traversed data so for that you can use maps and store the data with its address so that you can access it and manipulate it however you want.

Ususally hashmaps are of two type (1) Ordered Map: -> The data is stored in increasing order ->Self balancing Binary Search Tree ->Search time complexity : O(log n) ->Inserting time : O(N) ->Deleting time : O(N)

(2) Unordered Map: -> The data is stored in no ordering ->Hashtables ->Search time complexity : O(N) ->Inserting time : O(N) ->Deleting time : O(N)

Code to implementing maps and printing data
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int arr[5]={10,20,30,40,50};
    map<int,int>mp; // declaring map which have 2 values of int type where first is key and another is value.
    for(int i=0;i<5;i++)
    {
        mp[i]=arr[i];
    }
    for(auto x:mp)
    {
        cout<<x.first<<" - "<<x.second<<endl;
    }

    return 0;
}
Sep 06, 2023 19:08 Back to Articles

Other Articles

HashMaps

Hashing is a technique or process of mapping keys, and values into the hash table by using a hash function. It is done for faster access to elements.

1 year ago By Aniket Prajapati
EdKool.com Launches: A New Destination for All Things Education & Technology

We're delighted to announce the launch of EdKool.com, a unique platform designed to bridge the gap between education and technology.

1 year ago By Santosh Kshirsagar
Stack all Interview Questions .

In this Article all the problems related to stack is been uploaded for coding interview. Here there are questions which will help building your concept on stack from beginner to advance and you will be able to tackle any stack interview problem very easily.

1 year ago By Aniket Prajapati
Creating a Spinner Using Pure HTML and CSS Creating a Spinner Using Pure HTML and CSS

In this article, we will explore how to create a stylish spinner using pure HTML and CSS. The animated circle rotates indefinitely, offering visual feedback for ongoing processes on your web pages.

1 year ago By Mitali Gupta