rightly said by vinod sir. From the beginning we have an impression that only if you do the conventional desk jobs,you'll get respect from society. maybe its wrong but the truth so everyone has to study
@@yashwantmoharil5892 i dont't know why collsege faculty's are more focus on conversation and personal development we have lots of stuff to learn in engineering , and we take just a 40% of importance to coding and project and 60% how to face interviews and all fuck this all !!!!!!!!!!!!!!!!!
Saw the video today morning for interview prep , got a question using map ds in my round-3, Solved it. And got placed, Thanx alott for making these videos....
An alternative is Map.insert({"LilSyntax",888}) for your example... The argument is a simple example of std::initializer_list ... This is a briefer syntax. std::make_pair is not always necessary today.
Hello Rupesh! Generally speaking all your videos are very useful and carefully done! The content is also great. I am very glad of being the member if your channel. It will be also great to present, beside "the theory" some small projects to utilize the theory in practice. Anyway., please continue your channel. Keep fingers for you!
Simple and amazing 1)map template structure 2)map key should be unique. different way to insert the values in map a)Map.insert(std::make_pair(key,value)) b)Map.insert(std::pair(key,value)) c)Map[key] ; in this case value will be default 3)How map is Internally implemented. self balance search tree how to traverse In-order 4) By default map is ordered in Ascending, If we want to sort in descending order we need to use mapMap. You used vector as value. Value can be anything.Vector or map or any object. Probably, you could have included the time complexity of inserting the element although most people know it.
Clutch! I just got help from reddit's r/cplusplus, and the code the guy/gal wrote had std::map in it, and I was JUST reading the docs on map, then I remembered you : ) Perfecto!
one of the best explanations of maps.. sir can you also explain how to do search between two maps.. vlookup one column against keys of other maps and write to another file ?
I am following ur videos, and they r really helpful.Thanks for that. But i want to ask u when r u uploading Data Structures videos? Kindly do it soon..👍
That's a great insight☺️. Please cover the working of unordered_map/unordered_set also in next videos. Reason I am asking this because i have tried to understand about how the collisions are handled in these unordered associative containers but still not sure how it is done exactly. It will be great if you can give some insights, from the time complexity point of view also.
awesome tutorial !! I have a doubt. You have told that keys once created cannot be deleted, but by using erase ( ) function i think we can. Please clarify
The point is you always update the value not the key. That's how it is fixed and can't be changed. And yes with erase you can delete key and value both togather.
Hello and thank you for the video I am having this question assignment can anyone help me in this issue? interval_map is a data structure that efficiently associates intervals of keys of type K with values of type V. Your task is to implement the assign member function of this data structure, which is outlined below. interval_map is implemented on top of std::map. In case you are not entirely sure which functions std::map provides, what they do and which guarantees they provide, we provide an excerpt of the C++ standard here: Each key-value-pair (k,v) in the std::map means that the value v is associated with the interval from k (including) to the next key (excluding) in the std::map. Example: the std::map (0,'A'), (3,'B'), (5,'A') represents the mapping 0 -> 'A' 1 -> 'A' 2 -> 'A' 3 -> 'B' 4 -> 'B' 5 -> 'A' 6 -> 'A' 7 -> 'A' ... all the way to numeric_limits::max() The representation in the std::map must be canonical, that is, consecutive map entries must not have the same value: ..., (0,'A'), (3,'A'), ... is not allowed. Initially, the whole range of K is associated with a given initial value, passed to the constructor of the interval_map data structure. Key type K besides being copyable and assignable, is less-than comparable via operator< is bounded below, with the lowest value being std::numeric_limits::lowest() does not implement any other operations, in particular no equality comparison or arithmetic operators Value type V besides being copyable and assignable, is equality-comparable via operator== does not implement any other operations You are given the following source code: #include #include template class interval_map { std::map m_map; public: // constructor associates whole range of K with val by inserting (K_min, val) // into the map interval_map( V const& val) { m_map.insert(m_map.end(),std::make_pair(std::numeric_limits::lowest(),val)); } // Assign value val to interval [keyBegin, keyEnd). // Overwrite previous values in this interval. // Conforming to the C++ Standard Library conventions, the interval // includes keyBegin, but excludes keyEnd. // If !( keyBegin < keyEnd ), this designates an empty interval, // and assign must do nothing. void assign( K const& keyBegin, K const& keyEnd, V const& val ) {
Can you expand on the comparison of data within two different objects? You mentioned a function. value_comp is exclusively for comparisons within the same object? I am not sure where you were going with that.
I had a doubt but my program clarified .what if the key is string and the key Value is "aBC" "ABC" . Are these same or different and insert into the map.It is inserted
Hey your videos have been really helpful for understanding the stl topic...😄 Can you please suggest me a platform where I can practice its basics so I can get a better command on this topic.
@ Vighnesh Kadam whenever you iterate through a map you should have a loop like that if the map is called mp, you're not able to do mp.first or mp.second for (auto& m : mp)
@@Schoolroom9 Its simple... ' Key' is unique and value can be anything, since he added vector now, so values are now stored in vector. So its like [Amit ] : vector of values. Had it not been vector and int then 2nd value will replace first one.
he is correct in video, here Amit is pointing to a vector (although it is not name but let's say it is vector v1) Amit(key) -> v1[ 234123413 2343413] Chotu(key) ->v2[90909009]
I think you did not get the point, my english is not well but i'll try to explain. At the beginning of the video he explained the concept of map as a collection of entries key-value (string as Key and int as value). If the map Is organized as a bucket at the generic key "k" you can store more values (as he did in the last part using Vector). This seems great but leads to a problem called "collision"
he said that you're not able to have 2 of the same key, even if the values are different but you are able to have 2 of the same value as long as the keys are different.
MY PROGRAM IS NOT WORKING AND ITS SHOWING THIS ERROR, PLEASE HELP C:\Users\best buy\Desktop\Coding C++\Example_Map\main.cpp|15|error: request for member 'first' in 'el1', which is of non-class type 'int'| C:\Users\best buy\Desktop\Coding C++\Example_Map\main.cpp|15|error: request for member 'second' in 'el1', which is of non-class type 'int'| ||=== Build failed: 2 error(s), 2 warning(s) (0 minute(s), 0 second(s)) ===|
Hi Rupesh, Please help me, I am not able to understood the below program how to correct ---------------------------------------------------------------------------------------------------------------------------------- #include #include using namespace std; typedef struct { int id; }Test; typedef struct { int x;
std::map infoOfTest; }Resource; // We compare Test objects by their ids. bool operator
It has become a joke, but the Indian (I assume you're indian) guy on youtube is always way better than any university professor on the globe!
because we need to pass exams and want a job. It's in our blood.
@@vinoddiwan5792 true, getting job is too hard, and the competition!
Thanks dude..
rightly said by vinod sir.
From the beginning we have an impression that only if you do the conventional desk jobs,you'll get respect from society.
maybe its wrong but the truth so everyone has to study
@@yashwantmoharil5892 i dont't know why collsege faculty's are more focus on conversation and personal development
we have lots of stuff to learn in engineering , and we take just a 40% of importance to coding and project and 60% how to face interviews and all
fuck this all !!!!!!!!!!!!!!!!!
I am paying a bunch of money in a Canadian University and learning from you fella, you are awesome.
Thanks man..
Fr to India wapas aaja bhai
sorry for being racist,but why do most punjabis go to canada?
@@vikaspai294 We have a lot money and very little methods to spend it.
Saw the video today morning for interview prep , got a question using map ds in my round-3, Solved it. And got placed, Thanx alott for making these videos....
Wao...
Instant results.. 😀
Hats off to your work !!!
I really do appreciate your presence here on TH-cam behalf of all our developers community. 👏🏻👏🏻👏🏻
An alternative is Map.insert({"LilSyntax",888}) for your example... The argument is a simple example of std::initializer_list ... This is a briefer syntax. std::make_pair is not always necessary today.
Yes, i forgot to mention this i guess.
Hello Rupesh! Generally speaking all your videos are very useful and carefully done! The content is also great. I am very glad of being the member if your channel. It will be also great to present, beside "the theory" some small projects to utilize the theory in practice. Anyway., please continue your channel. Keep fingers for you!
Sure man!!
Today it self this thought crossed my, sure i will try this in future.
Thanks for the suggestion and comment.
Better and more professional than code with harry , lol!
that cleared my concept on maps
hey mr rupesh your knowledge of c++ is good and your explanation is exellent .keep it up!
Thanks a ton
Simple and amazing
1)map template structure 2)map key should be unique. different way to insert the values in map a)Map.insert(std::make_pair(key,value)) b)Map.insert(std::pair(key,value)) c)Map[key] ; in this case value will be default 3)How map is Internally implemented. self balance search tree how to traverse In-order 4) By default map is ordered in Ascending, If we want to sort in descending order we need to use mapMap. You used vector as value. Value can be anything.Vector or map or any object. Probably, you could have included the time complexity of inserting the element although most people know it.
Nice tutorial, simple and straightforward!
Clutch! I just got help from reddit's r/cplusplus, and the code the guy/gal wrote had std::map in it, and I was JUST reading the docs on map, then I remembered you : ) Perfecto!
Thank you youtube algorithms for suggesting this video, just what I wanted, subscribed... liked...
Thanks man!!
@@CppNuts no no no , i should thank you, so thank you
one of the best explanations of maps.. sir can you also explain how to do search between two maps.. vlookup one column against keys of other maps and write to another file ?
Thank you, CppNuts! I can now work on my data structures assignment with a better idea lol
Thanks...
All the best..
Perfectly explained👏
Glad you liked it
I am following ur videos, and they r really helpful.Thanks for that.
But i want to ask u when r u uploading Data Structures videos?
Kindly do it soon..👍
Thanks man..
Sure i am trying my best..
You will get it soon.
thank you so much,All these concepts telling how the high level programing languages evolving .
Thanks man!!
Thanks for the great explanation!
Thanks man..
That's a great insight☺️. Please cover the working of unordered_map/unordered_set also in next videos. Reason I am asking this because i have tried to understand about how the collisions are handled in these unordered associative containers but still not sure how it is done exactly. It will be great if you can give some insights, from the time complexity point of view also.
Sure 👍
Sir in the multiset video why //for(const auto & e:multiset) I didn't understand it could you clarify. Thank you
Hello Sir ! I didn't understand meaning of auto&ell : m . Anybody help me for explanation.
th-cam.com/video/dvaqLnbdEcM/w-d-xo.html
Rupesh, I am wondering how index operator must be working on underlying BST!
I can not thank you enough for this video.
Glad it helped!
I have subscribed, need more videos like this.
Thanks..
Sure..
awesome tutorial !! I have a doubt. You have told that keys once created cannot be deleted, but by using erase ( ) function i think we can. Please clarify
Thanks, please specify what point in video I said that?
@@CppNuts at 9:12 you mentioned it as once created it remains forever.
The point is you always update the value not the key. That's how it is fixed and can't be changed. And yes with erase you can delete key and value both togather.
@@CppNuts ohh ok thankyou
Awesome bro...Keep on doing in cpp
Thank you, I will
thank u so much for putting out such good quality videos on stl.
Glad you like them!
Hello and thank you for the video I am having this question assignment can anyone help me in this issue?
interval_map is a data structure that efficiently associates intervals of keys of type K with values of type V. Your task is to implement the assign member function of this data structure, which is outlined below.
interval_map is implemented on top of std::map. In case you are not entirely sure which functions std::map provides, what they do and which guarantees they provide, we provide an excerpt of the C++ standard here:
Each key-value-pair (k,v) in the std::map means that the value v is associated with the interval from k (including) to the next key (excluding) in the std::map.
Example: the std::map (0,'A'), (3,'B'), (5,'A') represents the mapping
0 -> 'A'
1 -> 'A'
2 -> 'A'
3 -> 'B'
4 -> 'B'
5 -> 'A'
6 -> 'A'
7 -> 'A'
... all the way to numeric_limits::max()
The representation in the std::map must be canonical, that is, consecutive map entries must not have the same value: ..., (0,'A'), (3,'A'), ... is not allowed. Initially, the whole range of K is associated with a given initial value, passed to the constructor of the interval_map data structure.
Key type K
besides being copyable and assignable, is less-than comparable via operator<
is bounded below, with the lowest value being std::numeric_limits::lowest()
does not implement any other operations, in particular no equality comparison or arithmetic operators
Value type V
besides being copyable and assignable, is equality-comparable via operator==
does not implement any other operations
You are given the following source code:
#include
#include
template
class interval_map {
std::map m_map;
public:
// constructor associates whole range of K with val by inserting (K_min, val)
// into the map
interval_map( V const& val) {
m_map.insert(m_map.end(),std::make_pair(std::numeric_limits::lowest(),val));
}
// Assign value val to interval [keyBegin, keyEnd).
// Overwrite previous values in this interval.
// Conforming to the C++ Standard Library conventions, the interval
// includes keyBegin, but excludes keyEnd.
// If !( keyBegin < keyEnd ), this designates an empty interval,
// and assign must do nothing.
void assign( K const& keyBegin, K const& keyEnd, V const& val ) {
Can you expand on the comparison of data within two different objects? You mentioned a function. value_comp is exclusively for comparisons within the same object? I am not sure where you were going with that.
I had a doubt but my program clarified .what if the key is string and the key Value is "aBC" "ABC" . Are these same or different and insert into the map.It is inserted
They are different.
Can you please tell how to add comparison operator in case of a user defined class?
Hey your videos have been really helpful for understanding the stl topic...😄
Can you please suggest me a platform where I can practice its basics so I can get a better command on this topic.
Thanks..
You can find map related problems in competitive programming and practice there.
God You;
Thanks dude..
thanks for this great video
You are welcome
So can I say that a map is like an array of pointers? Each index is the value type and each pointer is a class?
can you please explain the for each loop with more detail or give some resources to understand it better??
@
Vighnesh Kadam
whenever you iterate through a map you should have a loop like that
if the map is called mp, you're not able to do mp.first or mp.second
for (auto& m : mp)
@@JustinK0 thanks man understood it !!
In the last example can't we use a vector of pairs??
I meant the scenario in which he stated that we can't use vectors and arrays.
Excellent, Thank you very much
Glad it was helpful!
can you tell me how to practice and implement these topics??
You can use online programming competitions website
@@CppNuts but i dont think any online judge has some specific questions on this stl section
Bro could you make a tutorial on map-filter-reduce in stl ?
in the for loop when i remove the & operator it is giving the same output. Then what is the use of & in for statement??
if you dont use reference (&), then it will create copy everytime, and you dont want to do that because of size complexity
Are maps implemented using hash tables or binary search tree, I have a confusion on this !!
Different languages use different things.
Like Java Script uses hash map, where as C++ uses red black tree.
sometime we use map['a']++ with out setting its initial value . Does map sets 0 at key 'a' automatically?
yes
May I know in which ide you are writing this code....
VS Code.
How to insert values in map through user input?
Are map dynamic ??????
loved it
Thanks
How do I do nested maps like this one:
{
String: {
String: String
}
}
Hi Nikas map if this is what you are asking.
But ultimately there are two values for one key. How?
Didn't get the question?
@@CppNutsCppNuts you said, in a map, one key can have maximum one value but when we passed a vector, Amit had two values.
@@vikku_19 this is what im confused
@@Schoolroom9 Its simple... ' Key' is unique and value can be anything, since he added vector now, so values are now stored in vector. So its like
[Amit ] : vector of values. Had it not been vector and int then 2nd value will replace first one.
he is correct in video, here Amit is pointing to a vector (although it is not name but let's say it is vector v1)
Amit(key) -> v1[ 234123413 2343413]
Chotu(key) ->v2[90909009]
at 2:01 you said, same same cannot have different values, but at 13:14 how , the key Amit has different values. :/
I think you did not get the point, my english is not well but i'll try to explain.
At the beginning of the video he explained the concept of map as a collection of entries key-value (string as Key and int as value).
If the map Is organized as a bucket at the generic key "k" you can store more values (as he did in the last part using Vector).
This seems great but leads to a problem called "collision"
he said that you're not able to have 2 of the same key, even if the values are different
but you are able to have 2 of the same value as long as the keys are different.
God 👏🏾👏🏾👏🏾👍🏿
Thanks..
MY PROGRAM IS NOT WORKING AND ITS SHOWING THIS ERROR, PLEASE HELP
C:\Users\best buy\Desktop\Coding C++\Example_Map\main.cpp|15|error: request for member 'first' in 'el1', which is of non-class type 'int'|
C:\Users\best buy\Desktop\Coding C++\Example_Map\main.cpp|15|error: request for member 'second' in 'el1', which is of non-class type 'int'|
||=== Build failed: 2 error(s), 2 warning(s) (0 minute(s), 0 second(s)) ===|
.first and . second should be applied on iterator, not on map object
I will graduate from TH-cam.
This is what i want.
👏
Letters are very small.. Pls zoom the screen and make videos
Now i shoot with bigger fonts thanks man..
Sir not good
UNtill here i was able to grab some part of the concept but now u speeded up almost 5X and I lost my control and not able to udnerstand
i hope there is an option to slow down the speed of video in youtube.
chotu... hehehe
Hi Rupesh,
Please help me, I am not able to understood the below program how to correct
----------------------------------------------------------------------------------------------------------------------------------
#include
#include
using namespace std;
typedef struct {
int id;
}Test;
typedef struct {
int x;
std::map infoOfTest;
}Resource;
// We compare Test objects by their ids.
bool operator
What part?
I can't see operator < for Resource structure.