Hi everyone.
So in this video we're going to discuss this topic IQ test.
Now suppose you are provided with DNA.
You can easily mostly Eddie.
Now I suppose you have vectors then also you can easily traverse the area using VECTOR DOT size function.
You can go to each and every element and you can access the elements.
Now you have a map.
So how you will traverse the map.
So basically for I was saying the map before accessing every key way looping inside the map for accessing
every element inside the map we use I2 those so with the help of my duties we can traverse the maps.
Okay.
So many inbuilt glasses have ivory towers.
So vector also have I do toes.
We have a list glass.
So list Glass also has.
I treat those.
Similarly we have.
So this is map we have unordered map.
So unordered map also has.
I take those.
Similarly you have an ordered and ordered set and ordered set.
So they also have I do those.
So what is on our dead set and what is simple set.
So downloaded said map and our road map.
So they are very similar.
So what map stores map store key value PID but the store only keys central store only is it will not
store values rest everything the same everything will be same.
So this map will take log in time for a certain loop search.
So this set will take logging time for insert delete and such.
So this on road map it takes constant time for it to suddenly touch this set on our desert.
It will also take constant time for and certainly touch.
So I would think the same.
It is just that map will to give a loop here and certainly store only keys not values simple so all
of these map on that map I ordered said set.
So for our dating on all these glasses you need I do this for vector it is optional to use.
I do those two previously vector because we also have vector dot size function.
OK so whatever plate is optional to use I do those.
So if this map is this map is implemented using BSD.
So this set is also implemented using BSD.
Similarly and the map is implemented using hash table.
So in order to set is also implemented using hash table.
So everything is very same.
Everything is very similar between between map and said so.
Now let us write the code
so I have included we had the file.
Now let us create an unread map first let us take the body and ordered map and then we will also see
that both how we can use our data for vector.
So let's say the string.
Let's say the keys string and the value is in danger.
And the name of map is my map.
And now let us push some basis so my map off let's use stringers ABC
and let's say the value is 1.
So now let's copy this
so I have pushed six entries inside my map.
So the size of my map is basically six.
Now we want to access each and every element of my map.
So how can we access each and every element.
We will lose.
I those.
So how can we use our readers.
And now let us discuss what that I do this.
So basically we want to traverse our unordered map we want to access each and every element of our road
map.
So as the name suggests on our road map.
So that means when you traverse this road map.
So there is no ordering of the elements.
So there is no guarantee which element will come first and which element will come last.
So it is not guaranteed that ABC will come first and ABC too will come at last.
So there is no guarantee.
OK.
And that means there is no ordering of elements.
So now what will happen.
So basically you have this map.
So I don't know how it will.
I would give a little bit then we have our data.
So this idea that will point to an element and what is an element an element is basically a key value
pit.
So our data is basically pointing to a key way looping it.
And if I will do a deep plus plus 80 plus plus means move to the next element.
So next element can be anywhere.
So it will move to the next element
so when we'll do 80 plus plus.
So this is a pointer it will move to the next element and we do not know how the map is distorting our
elements.
So it can be anything.
So the next element can be anything we don't know that.
So there is no guarantee in which ordered the elements will appear.
Now how to create and I do the so the syntax for creating an idea is you will write an ordered map then
you will write Stringer and Deja then you will write column column and then you will write this index.
I do that and then you will give the name.
So the name is 80.
So this is due to type.
This is the data type and this is basically the name of the variable.
This is the name of the variable.
Okay.
So I have a function so I'd be if you will right I did close my map don't begin so I have a function
Begin So this began with the help of this begin function decided I will point to the first element of
the map.
So this idea that it will point towards the first element of the map.
Simple.
And then you will do 80 plus plus.
So we will move ahead.
So I have a size function so I know for example analogous.
So there was six element present.
Now what I will do with the help of Begin function I will get to the first element.
Then I will do 80 plus plus six times because the size of the map is six and I will print all the key
values be it.
No the second option of travelling the map is basically we have a function dart and so what I will do
then I.D. becomes equal to my map God and what will happen.
So and means so and does not mean this one.
So and means the element after last.
So basically this is and this is not and this is not and this is wrong.
This one is end.
So what can I do I will start from begin I will do 80 plus plus.
So I will move ahead and then I will reach my map God and I will start by iterating simple.
And the second option is basically you go to do begin you will do 80 plus plus six times because the
size of the map is six and you can print all the elements no let us write the code so let us use for
loop.
You can also use a loop so for now again.
First we have to give the data type.
So this is the data type
and the name of the variable is IP and we will go to the beginning.
So my map that I have begun to function then IP is not it goes through I have dropped I lost my map
Bill I'd be delighted it is not too close to my map Gordon and 80 plus plus symbol.
Now what is I do that.
So basically what is I data pointing to.
So you have this idea that idea so this idea is basically pointing to appear so this is a beard.
Give a beard.
I want to access key and I also want to access the value.
So if I have a beard how can I exist first and second element so I can write it out first.
But I have an address.
So this is a pointer.
So if you want to access the first element you have to write i.e. arrow first.
And similarly you want to access the value.
So value is basically IP at second
so idea first is basically key IP address second is basically value simple.
So no let us print.
So for printing the key idea row first ip is basically my idea that
so idea first.
And now let us also print the value
so we're printing our value I will use IP address second
analysis.
This is on a road map.
So there is no ordering of elements so there is no guarantee which element will come first and which
element will come at last
so see you can compare yourself.
ABC 5 is coming at first then ABC forward then simple ABC then one two entry.
Okay so there is no ordering.
So now if instead of using on a road map you will use map.
So in map this there is basically starting so let's copy this one
now instead of using on the map.
If I ever use simple map so simple map means order to map.
So I have to change the name so it's in my map to
and similarly this is my map to begin my map to dart end and ideas basically a local variable so there
is no need to change the name now this map is basically ordered map and ordered map basically means
if you will remember BSD BSD if you will do the order.
I was in.
So in order that I was in this basically sorted so basically I this map this to map it will start the
keys it will start our keys.
So this is how it will store the data so keys are sorted.
Okay so this map will sort the keys so I will traverse in Sadr to my head.
I will drive I was in sorted a.
According to keys.
Okay.
Now let's see.
Okay.
So this will be basically map only
so you can see
the values sorted.
So I am reversing this map.
According to keys
so what I want to say is.
So forget about values.
So basically maps are sorted according to keys.
So ABC is smaller than ABC even than ABC 2 ABC 3 ABC for an ABC 5.
It is not sorted according to values.
So let me demonstrate to so for example if this value is 10 and let me push this one first
so now what I did here first I am pushing ABC even then I am pushing ABC then ABC 2.
So what will happen.
The map will start.
I will give a little bit on the basis of these not on the basis of values.
So let's end our program
now see the output again first ABC then ABC 1 and then ABC 2.
So basically the order to map its site give a little bit on the basis of keys and not on the basis of
values.
OK so value then is coming at first so this is point to remembered so in map I have give a loop it so
map will start on the basis of this map will start on bases of keys and not on bases of values you should
remember this one certain on bases of keys and not on bases of values.
So similarly just like in map we also have I2 those four vectors so let's see.
So let us create a vector first
vector often Tejas V and now let us push some values so we don't push back.
Let's say 1
in order to push some elements
so this is two than three and four and then five.
So basically that does has ordering of elements so days in order for element.
So if you traverse the vector you will get that data in which you inserted the data
so that 80.
So this is the number the vector is V so readers begin
V is not equal to Saudi.
This is 80 so 80 is not equal to read out and similarly 80 plus plus.
So what is happening here.
So for Rick this idea is basically pointing to one element so if you want to access the element you
have to right start.
Ida B difference operator then start it because ideas containing address so that's why you have to write
spot 80 we accessed the element
start D
so we know it's best so C one two three four five four days basically ordering of elements.
If we make the first value then no let's test our program.
So basically you will get the values in the order you inserted the values.
Okay.
So first I am getting 10 okay.
So we all know how that works.
Now apart from everything I did also have many other use cases.
For example you can use I tweeted for finding an element whether an element exists or not.
So basically where we can do so I have a function find.
So I have a function find this find function will take key as input and this function will get done.
And I do that so this find function returns and I do that.
Now if this I day is basically it goes to my map gardened so that means the element does not exist in
the map.
Simple.
So let me show you.
So if my map got find function so this find function will take me as input and led to the Keys.
ABC equals equals my map dot and so I don't do this find function will are done when I do that and the
function is also the ending and I do that.
So I'm comparing those two I do this.
So if ABC is present in my map then this condition will become false so you can write
not pleasant.
As you can date present
okay.
So what I'm doing here is so I have inbuilt function find this fine function builder done me and I do
that.
And if the data is basically equal to the end I do it.
So this enemy is basically this and not the last element.
After the last element.
So basically if I'm not able to find ABC what will happen.
It will get done me the end point.
And if it isn't a dunning me and pointed at me as ABC is not present as it is present.
Okay so suppose ABC is busy.
So what will happen.
So this fine function will have done me and I tweeted to ABC so let's test our program.
So ABC is currently present in my map so the output will be present
so without parties present no apart from finding.
So what I do best can also do.
So let us create I do that.
So let's copy this one on road map
no let's try to find out traitor for ABC.
So what I will do I will call this function my map not find ABC
so this find.
This is my map.
So this find function well done me and I do that to ABC and then what you can do you can it is.
So you have a function my map got it is now its function takes two things as input.
Either you can give the key or you can also give I that.
So I want to give ITER that had 80 so what is happening here.
My map not find ABC so dysfunctional it done me and I traitor to ABC and then I am.
I'm using these function to delete ABC.
So if you will read this program this time the output will be not present output will be not present.
Okay so let's see
to the output is not present because we deleted that entry
so now we have two functions.
First function is find function.
The second function is called function to check whether a key is present or not.
So we have two functions now we can use find function but check whether a key is present or not.
Similarly we can use current function to check whether a key is present or not.
And similarly if what it is function for its function either you can pass the key it will it is or you
can also pass the idea that it is function and it will delete that entry.
Now one more thing what you can do you can use this function you can give the starting right data and
you can also give the ending I that.
So I want to delete.
So this is the starting AI data and this is the ending I created.
So what will happen if you will write this code.
So what then this will be deleted.
So it will delete I.T. it will delete a deep lesson it will delete IP plus 2 and it will delete 80 plus
three.
So 80 plus for this will not be deleted.
This is basically excluded okay.
So if you write something like this it is you will give the starting point that my map God begin and
if you will give the ending Boyton which is my map not end.
So what will happen if you will write like this it is my remembered begin comma my remember then.
So this is the starting I data.
This is the ending I drew.
Then what will happen.
Your map will become empty your map will become empty.
So let's test this one.
Okay.
So basically.
So basically using this thing using this thing does not make sense for an already map because for a
map we don't know which one is the next entry because there is no ordering.
So this thing only makes sense for basically ordering ordered glasses for example map for example vectors
because there is ordering of elements okay.
So this thing does not make any sense for that element because I don't know which element is the next
element how the elements are stored.
So now let's use it is function.
So now let us it is the complete map.
Let's make our map empty so what I will do my map what it is.
So let's come into doubt
I can give two pointers.
So do I do this.
So my map that begin start deleting from beginning data and gone delete my map Gordon.
So what will happen.
My map will become empty so if you will try to find out.
ABC now will be not present and this will not print anything the output will be empty.
Map so I am bending my map that begins with I would prefer to be empty map.
Okay.
So it will not bring anything because our map is empty.
You can also print my map God size so you can print the size also so my map God size will be zero
so I am deleting I am making my my map empty so the size will be zero.
And this court will not print anything and I would prefer to be not present.
Okay let's see.
So not present then this line of code is not printing anything.
Then my my not size is zero.
So that's how you can use it is function.
So all these function so fine function Begin function and function it is function.
So all these functions are also present in vector classes and inside class on the set.
Okay so all these functions at present data also.
Now one more thing.
So instead of using this vector and I do that word you can use I have a keyword or two.
So I told you what is this.
So this is actually a data type.
Now I have a keyword or two.
So what order keyword will do so it will take that type automatically.
It will define that your type automatically.
So instead of writing this and then I what can I do.
I can write or do 80 so auto will automatically make that it type this one.
So what do you are writing or writing or do ideas.
My map does begin and this my memory begin will return and I take that off.
This type and auto will judge this one or two will sense this and it will automatically take district
type
so instead of using this they can do you can simply write auto so auto is a keyword.
OK so this will work.
So now see
OK.
So our code is working similarly you can write auto x rayed also for example instead of vector integrator
where you can do you can simply write auto
okay.
Our code is working similarly you can also do something like this
instead of writing and A's 5 word again to see out a
word you can do you can write auto head
see the value of Phase 5.
So that is the working of auto.
Similarly what you can do.
You can also write like this.
Auto B is basically let's say a b c b you can do anything.
Okay let me show you
so instead of writing so instead of writing string C is ABC what you can do.
You can write auto head auto C ABC and then you can print the value of c
OK ABC so you can use auto instead of writing this big syntax.
You can write auto OK short when so if you have any doubt in this video you can ask me.
Okay I was shooting the next one but by.