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

Establishing Validation by Converting TypeScript Code to Zod Schemas Establishing Validation by Converting TypeScript Code to Zod Schemas

In this article, we'll explore how to establish validation by converting TypeScript code to Zod schemas. Zod is a TypeScript-first schema validation library that ensures data validity at runtime.

1 year ago By Mitali Gupta
Binary Tree

Binary Tree is a Non-Linear data structure which has atmost 2 child . A Binary tree is represented by a pointer to the topmost node (commonly known as the “root”) of the tree. If the tree is empty, then the value of the root is NULL. Each node of a Binary Tree contains the following parts:

1 year ago By Aniket Prajapati
10 common JavaScript interview questions that you might encounter !!!

In this article, we will discuss 10 JS questions that are commonly asked in interviews. These questions cover a range of JavaScript topics and are commonly asked in interviews to assess a candidate's understanding of the language. Make sure to practice and understand these concepts to perform well in JavaScript interviews.

1 year ago By Mitali Gupta
Web Development as a career !! Web Development as a career !!

Web development offers a fulfilling career designing, developing, and maintaining websites and applications, combining creativity and technical skills in the digital realm.

1 year ago By Mitali Gupta