Search for notes by fellow students, in your own course and all over the country.
Browse our notes for titles which look like what you need, you can preview any of the notes via a sample of the contents. After you're happy these are the notes you're after simply pop them into your shopping cart.
Title: DSA-data structure
Description: This is high level course you should study
Description: This is high level course you should study
Document Preview
Extracts from the notes are below, to see the PDF you'll receive please use the links above
~_
DATA STRUCTURE AND
ALGORITHMS __________~
Introduction to Data Structures & Algorithms
should be able to use it in your work or in your projects or in your courses or in your projects
that you are doing in the future or in your work that you are doing right now so if you want to
use something then you should be able to use it in your work or in your projects or in your
courses or in your future work or in your projects that you are doing right now
...
I have been in the industry for a long time now
and I have seen a lot of people learning C , C++ and when they start to learn it they get very
lost & confused & they don't know what they are doing & they don't know how to use the
language properly & eventually they stop learning it & they end up becoming a beginner
again & that is not good for the industry & it is not good for the learners either so I would say
learn C , C++ & don't get lost in the language learning process
a break for a while I understand that you are very busy for the next few days and I
understand that you are very busy for the next few weeks and I understand that you have a
lot of questions so I 'll just stop now and I 'll come back to you in a few days and we will start
the next video where we will talk about algorithms and data structures and then we will talk
about interviews and then finally we will talk about the final exam and you can ask me any
questions that you have in your mind so that 's all for now I 'll come back to you in a few
days and we will start the next videowhat is the data structure of chrome so now we see that
the data structure is called RAM so the data structure of a database is called RAM because
when the program starts it will load into RAM the data structure of the database which is
called RAM
...
I want to keep the data in a different database so what I have to do
is I have to create a new database and I have to name it `` legacyData '' I have to create a
new table in that database and I have to add the following column in the table `` Birthday `` I
have to add the following column in the table `` Year `` Now I have to run the program and I
will get the following result in the console `` Facebook 2020 `` Facebook 2021 `` Facebook
2009 `` `` Facebook 2020 `` Facebook 2021 `` Facebook 2009 `` `` Facebook 2009 `` You
retrieve and read the data from hard disk drive and update it
...
memory
location where the C program stores the data that is to be processed next and the heap is a
memory location where the C program stores the data that is to be processed next but the
data that is to be processed next is not always stored in the same location as the data that is
to be processed next because the C program can keep data in different memory locations
depending on the situation and this is why it is important for you to understand the stack and
heap because you will be able to understand the C program better and be able to ask more
questions on the C program
...
I 'm talking about C program that 's why I say that you
get a good picture of memory with the help of C programming therefore , data structures and
algorithms is best learned from C and C++ Now here I am dividing it into segments so there
is thing called code segment let 's say this is my code let 's say there is a code with the
name `` harry
...
fun2 ( ) is calling inside fun1 ( ) now the variables that I had created inside it will be
created here let 's say I have created `` k '' & `` l '' let me write here : initialize k and l and
after that I 'm calling fun2 ( ) so as soon as fun2 ( ) will be called it will say to fun1 ( ) that you
wait for a while , I call fun2 ( ) and be back by fetching the value whatever it will return fun1 (
) replied that you go and get it call fun2 ( ) and get its value
...
it will say to fun1 ( ) that you 're
coming back and now you can start your execution again
...
So that thing is done here with the
help of dynamic memory because when does the stack of a function end it ends when the
function is returned
...
You go and get it and
then what will happen, fun function will be called
...
So the input size didn't increase and the runtime of the algorithms didn't increase either
...
When we ask questions like as the input will
increase, Then the runtime will change as per what? And after that Now you will go to
aunty's house You will be treated
...
is the algorithm that runs in constant time
...
The sentence is: Run time of it, there are some things that we will recite
...
Now, come here and listen to another story
...
If the game is of N kb then how much time will you need? The sentence is: Run
time of it, there are some things that we will recite
...
There are also algorithms that are
not linear in time
...
We 'll talk a little bit about asymptotic notation
...
We talked about
ordering
...
Big O is set to be O (
g ( n ) ) if and only if there exist a constant ( c ) and a constant n -node such that 0 ≤ f ( n) ≤
cg (n) is O (g (N) If you watch this video completely then I guarantee that you will understand
these three notations
...
When
we do analysis of algorithms comparing any 2 algorithms then f ( n ) will be time and what is
n , it 's input ok , size of input
...
O ( n²)
is Anything Can Be Algorithm it is g (n) that will be here and which is your algorithm
...
If you ca n't find it then its is not f (n ) is O
...
Best Case, Worst Case and Average Case Analysis of an Algorithm
To define an algorithm, To define the events in the life of an algorithm , We have , Best Case
Worst Case and Expected Case
...
If you watch this video till the end , Then you will find out what
this 'Log ' really is
...
5
...
9 and 24 are the numbers in it; They 're in ascending order
, You can see for yourself
...
Now what I say is that I 'll give a number : 'A' And I 'd like you to tell me If
this number exists within the array , or not
...
So what will be your
answer ? Yes
...
If A is
...
If
the value is 9, What will the answer be ? Your answer will Algo 1 is a simple person
...
It is comparing it with all the numbers
...
Because Algo
...
It will tell us in the first
comparison itself
...
If Algo 1 is in luck, The time needed is ' k ' - T=k
...
Take a 10-element array, take a single element array or take a 10,000 element array
...
Now, AlGo 1 's luck is bad
...
Average Case complexity is equal to
...
The O ( Sum of all possible run times divided by the number of possibility ) is O
( n ) The average case complexity is the sum
...
to
...
possible run
...
by the total
...
So for an array size of
5, We saw six cases
...
n+1 If 'n ' is the size of the array , Then
there is 'n+1 '' number of possibilities
...
If the element is here, How
many comparisons will it have to make ? It will have to do
...
2
...
I 've
taken ' k ' as common out of everything
...
And this I
have added separately
...
AP is used in 'O ' a lot
...
When there are questions on 'O' APs and GPs are
used in the answers to questions on O
...
The Average Case Time is not
generally asked for a unique algorithm
...
So what is the Average Case
...
Algo 1 was making 'n ' comparisons
...
Algo 2 is a cunning person
...
It made
one comparison For a size of 10 array , As well as for an array of size 100
...
The midpoint between 1 and 100 will be 50
...
If there are an even number of elements here, there are 2-2-4,2-6
elements
...
So I can take either of them as midpoint
...
You
can halve 8 once, and it will become 4
...
How many times can you divide 16
? You can divide 16 once, twice, twice and four times
...
So I told you a
very good definition of 'Log '
...
This definition that I have told you in this course , You would n't have got it very easily
...
You must appreciate the definition of Log
...
After that we will do some set of questions
...
due to the time complexity of any algorithm when you have to find it
so what is the first step that you do and at the same time how to approach this problem
...
We believe
that these operations are all (k ) time consuming This for loop , that is , how much time is
being taken for this fragment It seems ( kn ) , okay So before this ( int i ) would have been
written here, ( int k=0 ) would be written here
...
The first fragment turned out to be this one , with a
little bit of initialization
...
I will go for ( n = 100 ) to determine whether i will be going for n = 1000
...
There will be some code on it which will take ( k1 ) Now I have become so smart, by
doing questions , and you will be done too That (k1) it is will going to be non-dominant , if
constant is being added then we will remove it
...
Then ( j=1) will become Then ( 0,2) Then (i=0 , and j=0 ) will
then run for Okay
...
When ( n) is running
out, watch carefully , watch very closely
...
value of i will be ( 1) , ( n ), it will be n-1 because I am taking the index ( i=0 )
then (i=n-1) will be and here is ( n- 1 )
I told you guys If it 's not clear to you why it will work ( n² ) times So I 'd say let 's go look at it
for 3 and 3 and print here (i , j ) and make a count variable and count it , how many times it is
running You write ( c ) program , write in Python, write in Java, write in Python and write in
the Java
...
And if
another loop is given inside it , then it will run ( n³ ) times
...
And I have also given their programs to you
...
So it 's saying that Find the time complexity ( Func1 ) function in
the program shown in program1
...
Even if you come from another programming
language nothing is going to be change
...
The time is not depending on Array 's length so i 'll accept
it ( k1 ) and I can not accept ( F2 ) as ( k ) , i will accept it as k2 * n
...
The answer is O (length) The algorithm it is talking in terms of length over here
...
c as follows
...
If you look carefully above it is written ( n )
times, if you write 1 for ( n times as ( 1+1+1 +1 + n) So what will happen if I write (n²) so it is
done O ( n²) So anytime you see the double for loop , and it 's going to [ 0, n ] , [ 0 , n ] and [
0 n ] i
...
for 0 , ( n) times it will run OK , so this will run 0 for (n) times, then 1 for n times
then it will again 2 for n
...
And there is some constant work going on inside it so it
means The average processing time is T ( n ) so T ( 6 ) is a small number
...
only
...
Arrays and Abstract Data Type in Data Structure
So I have a friend that wanted to build a PC So he approached me and asked '' Harry , can
you give me a blueprint to build PC ? '' '' So that with that blueprint I can make someone
build PC? '' '' I want to do gaming and streaming
...
I told him all
the main components of a PC
...
We
will study array ADT
...
Arrays as an abstract data type
...
Not MRF tyres, nor the bat one ; I 'll give you minimal
...
And some operations , that you can define later on your own
...
Arrays can be found in a lot of programming
languages
...
In Python, they are called 'lists' and
in Java, they're called lists
...
For
example, Get is done , Set is done
...
An array is a collection of elements
...
The memory layout of the C
programme is a code section
...
Inside
a function is a stack
...
The kernel is the kernel of the kernels
...
But, you can search on the
internet There 's a paper by jee-stars
...
How calculations will become easy
...
When you requested a memory till 38, then it is possible
that some other application was given some memory by the compiler
...
Otherwise in the same programme It must have allocated a variable in
correspondence with that memory
...
You can increase it in the linked list, we 'll talk about that
ahead
...
An array can not be resized
...
It wo n't get this
block ; no
...
resized this way
...
Get
and Set is very easy in the C language
...
But we 'll implement this array ADT with the help of structure structure
...
We 'll build it however we want to
...
In my ADT I will provide the user with the ability to use my Add method
...
That why we use arrays
...
Where does the scam happen in the array ? At the time of deletion and insertion
...
Because I 'll have to move it
...
And you 'll get that by practising
...
In an abstract data type, abstraction means hiding the implementation details
...
Array ADT holds a
collection of elements It can float , it can be int
...
And it can also be
structure in C language
...
Because
only one calculation has to be done And it will take constant time
...
We 'll do this in a while ; I 've told you about memory representation sufficiently
...
But if you want to stick to data structures keep
following this course And you will definitely like it and it will benefit you a lot
...
We can directly link it with object-ended programming
...
And here, by the name of 'Algorithms
...
Like an integer, I can also make my own data
type , Assume that I want to make a data type called 'my array' The C language is a special
type of array
...
total_size
...
Base address is the pointer
...
I 'll do it like this
...
of operations
...
What can those operations be ?
Those operations can be anything
...
So we can
define a lot of these types of operations And we can make our custom data types
...
This is Stack And this is Heap
...
If I
want to make an array, I can either I make the array in the stack Like if this is the stack of the
main function , okay
...
I 'll write Main here
...
I request some memory , And make its previous address point , And
here with my array , I can request Its indices will be 0,1,2,3,4
...
It 's my choice ; whatever I choose to put
...
If we have to make an array of size 'n ' , So n multiplied by ;
meaning star Then the size of operator , and after that, int
...
Figure out once you see it When I give you the notebook
...
Operations
...
e the capacity to store 6 elements
...
The
advantage I 'll get is If I ever want to make insertions in this array Then I can move them a
little , all the elements
...
And I think moving things a bit is better
...
The capacity of arrays is
...
So in arrays , the biggest advantage is this : It is the fact that you can access the
element ; You can calculate from the base address
...
a milestone 3
...
5
...
This is our Delhi and assume there 's a route from here And
from here, how many kilometres away from here
...
So I 'll quickly tell a little bit of implementation in
this video We 're going to code anyway
...
And I do n't want to do it on the whiteboard
...
I just want you guys to like , and keep up the enthusiasm
...
I 've made these
notes for you All the details are there in here
...
Implementing Array as an Abstract Data Type in C Language
This is the C in 1 Video That is of 15 hours
...
And you should download and install this
...
The biggest advantage of this is that today I 'm writing C language Code in
Visual Studio
...
In Visual Studio, I 've made a snippet of boilerplate code for Array ADT
...
If you do n't know where to get this code
or If you don't know how to use it, Then you can refer to this video
...
For example, if Google is
taking up too Chrome much RAM You 'd wish for it to take up less RAM
...
A custom My Array abstract ADT uses a pointer that points toward the total size, the used
size and the first element
...
My
array can not go beyond this Because the compiler has reserved the remaining memory for
someone else
...
This is how I felt it should be implemented
...
There can be another implementation as well
...
And once I get the structure instance , Then I can
add a dot and access its total size or anything
...
= t size I 'll want that this t-size is
passed And along with that , I 'd want that used size should also be passed
...
We 've even set that we have to use 20
blocks only
...
But for now, we must use only 20 blocks
...
We put a star when we want the value of the address and call the ampersand the address of
the operator
...
And if you want to use 20 and want to make it 100
...
e this is where you 've given the structure address , It will
dereference that with a star
...
It
replied , okay
...
So for that I 'll
have to call for the createArray function
...
And it will update its pointer in this itself
...
It 's in my Python course but it 's very useful
...
And here I will write scanf % d & n & n
...
myArray is an abstract data type in which I have defined a total size integer , a used size
integer integer, and a pointer called ptr
...
The pointer of the pointer of ptr would be pointing at the first
element
...
I have made a function called createArray
...
After that, it is also taking how much total size
you want and how much you will use
...
That 's why I 've reserved 10
...
In that , I can
use all my methods
...
Operations on Arrays in Data Structures: Traversal, Insertion, Deletion and Searching
Today we 'll talk about some operations in array
...
It 's the easiest thing in array, it 's like 2x2=4
...
If you want to print all the array elements or you may want to set this
array
...
or similar doubts, then your situation is such that
you need to write C language
...
At about 11 at night, you 'll be done with it
...
I've included practice in it
...
I'll tell you
what I was going to say
...
So, you can
make two variables, one will be capacity
...
You can make size ,
it will be 5
...
Capacity shows that this is the
potential
...
That's why you take a higher capacity in array and the size is 5
...
The children are standing here and
suppose something is being given out like ice cream
...
Though in school you join the line first and shift later
...
This goes up to 99, 0, 1, 2, 3, 4
...
Now, if you 're a very lucky person , then you 'll get index number 5 for
insertion
...
I have provided everything , just
download the notes
...
I zip it so that
all codes, source codes, and pdfs are in one place
...
It 'll be O ( 1) in best case, you had to delete
the last one
...
In both best case and worst
case cases, the size does n' matter
...
There 's no other option , only prayers will work
...
You do n't want an overflow condition , it 's called overflow
...
You can search in this way, one by one
...
This is called linear search
...
You 'll take its greatest integer
and mid will be 2
...
You'll check if it 's greater or smaller than
mid , it ''s smaller
...
After this convergence, your search will be over
...
Otherwise, binary search is the way to go
...
In the coming videos, we 'll code these operations in C
language and C++ too
...
Python, Java etc
...
Majority of the people wanted data structure algorithm in those languages
...
We 'll understand whatever we did in theory and I
hope you like this course
...
If you remember , we had talked in
great detail About what ? We 'd talked about some array operations in detail
...
This is
a course for data structures I do n't want to teach you how to print the elements of an array
...
And that it has the
capacity to store 100 elements
...
If there is
no space in your array, then what can you do? If your whole array is full; when your size is >
or = to the capacity , Then I ca n't take any more in it
...
When there 's no space or capacity you 'll have to return -1
...
And ahead of this , there is a lot of space
...
So I 'm taking -1 as a representation because if you return
...
Okay ? Now I 'll do this
...
n't
...
Now if it does
n't get returned , what does it mean ? So I want that index 4 should go ahead
...
If there was n't space then it would return it
...
I
'm starting from i=size -1
...
'll have to do arr (i+1 ) =arr (i )
...
1 for success
...
I hope that this course must be helpful for you
...
And many of you
have downloaded the notes
...
If the insertion is successful, You will print the
new , modified array
...
You have both the notes and the video ; I 'm also making you do the practice questions I
have also uploaded the OneNote notebook
...
So I hope you 're finding this course very helpful and I will
see you next time !
Coding Deletion Operation in Array Using C Language
In our previous video we saw that how to do insertion in an array
...
do deletion
...
So
today we will see the code
...
So what will happen now, now 12 have got the signal
to leave the array
...
If anyone knows then tell me in the comment man
...
A [ i ] = a [ i + 1 ] = (i + 1
) I am writing very rough code I 'm writing a CO2 code here , Okay
...
That is , the void that is made is , as if ( ind = 2 ) (ind = )
ours , the index where we performed the deletion is 2
...
c, create a function named as ( int deletion ) who will do what Take
an array , take an array, take the size of the array and take an integer
...
So I am sure that all the checks that you are
carrying in the account If you want, give one ( if you want , give one) The index of the given
array is large : Array 's which ( capacity - 1) is
...
So
out of the deletion , the size : , the variable that I am storing , what is this size This size
means that I have capacity of 100 So how many out of 100 are being used , that size : Okay
...
I want you to write some program by yourself and then practice
...
Then you must be good in C language
...
But it comes in the data structure because here we are talking
about operations on the arrays like this
...
In
the coming videos we will continue the story of Data Structures and Algorithms
...
Linear Vs Binary Search + Code in C Language
In this course on Data Structures and Algorithms , we have seen a lot so far
...
What is Linear Search ?
And what is binary search ? What is linear search? And what's binary search? We're going
to code it here because it is asked a lot
...
I will give you a real life example of binary search that
when you will do binary search
...
Or if you reach the end of an array, then you have to say
that the
...
over
...
that's all
...
should be opened inside
a thousand pages in a book
...
If pages were stitched at random, then you would not be able to do this
...
Binary search works just like I took the example of the book
...
Sorted
array Array must be sorted , okay
...
You can
add any number of elements to a sorted array
...
One will keep the track of high , will keep track of mid
...
I calculate the mid (8+4 ) /2= 6 My mid turns 6 ,
so this will be my mid , so it will be the mid
...
When I upload the video , it takes me some time to put the notes on the
website
...
I did not talk about this , here it is a little important to tell it So look at this , which is our
Linear Search and Binary Search : What do we people have to do , if you are looking at
linear search , then its complexity is O ( n ) But if you look here binary search So I 'm halving
the array until it runs out , does not converge speak the same ( log n ) So here you people
will not face any issue , okay So this thing must have been cleared to you guys , I hope
...
Do return 1 means I have got this element here in the array or I
will do one thing that I will return only the index of the array where I have
...
As soon as the
element is found, while traversing this array Then you return the index where that element
was found
...
As this return i ; is written , the function terminates and returns The
function 's activation record in this stack gets lost
...
If you will do (5 + 6 ) /2 , Then it would
be 11/2 After that it will give you 5 automatically
...
So you do n't care about the greatest integer
Directly , even if you write like this , It will automatically take that greatest integer
...
So I 'm not going to
search inclusive from here I will search from 100 to 400 in consideration , and repeat the
same thing with him
...
If low and high are converged it means the
element which is not available to me
...
If return-1
needs to be executed it just means that the return did n't happen inside this while loop it has
not returned inside the while loop
...
So let 's run this man for an array
...
The
name of linked list is the name of a linked list , if you 're listening for the very first time and it
is possible that you 've read it before and did n't understand that i will start with and example
to explain this thing and the example will be of a hospital
...
The advantage we got here is that we
could n't get all the beds at the same place
...
In
linked list it has a node which has a space for data one is for pointer to next and another one
for pointer
...
To
extend this list is very easy to extend this is not easy and sometimes impossible too
...
Inserting and deletion in linked list is so
easy as much as is to interconnect two links
...
for no use array has its own
benefit and this is advantageous there this one is not and where this is not advantageous
there is not
...
The address is 280 so in this 280 is there and is
pointing that point does n't mean that it is done by a finger it means in this the address is
kept stored i will do and show you by coding it
...
In linked list the memory and capacity are the same in linked list you can join the nodes and
remove nodes from the mid does n't matter in array
...
In linked lists elements are there in non contiguous memory
location if it is 0 then it can be 2000 or 4000 and then the next node can be again 40
anywhere
...
Linked List Data Structure: Creation and Traversal in C Language
Friends, in this course of data structure , we had seen the linked list in the previous video
...
After that we will see that how the same linked list can be traversed
...
If its address is let 's say 788 ,
then 788 is stored inside it
...
Then I 'll declare the end of this list here , okay
...
To access the data of the struct pointer , you can use the arrow operators
...
Here as if this is your one node , after that it is linked as if with some other node
...
and so on until your null comes
...
A 14_LinkedListTraversal
...
The video number is going to be 14
...
I create a file with the
names of it, and put a boiler plate in it
...
How can we make a
function of linked list traversal ? What do I do to make function of traversal of linked lists?
What will happen that with the help of this pointer , I will print the elements inside the whole
list one by one
...
head node
...
So to linked list traversal , I have given a pointer which is of type struct Node * : I get one
...
And I 'll keep doing this until it
becomes null until it points to null
...
Head is a pointer, of struct
Node * type So over here this is , struct Node* ptr Okay So what will I do here , I save it and
run it
...
If it also had
a fourth node if it also has a fourth, i
...
I would put some data in the third node
...
So look , made the head made the
second, made the third and made the
...
This is the last element of the list because the
next one is pointing to NULL So here is the chain , it 's closed Sometimes I had to add an
element , can do it at any location
...
Relatively , very few people have access to this playlist I would say by bookmark it and save
it
...
It is Insert
after and we will also talk about their complexity
...
Head node is pointing to the first element of
my linked list
...
I have to fit it in the
starting
...
There are 5 lakh elements, so how much time is it taking , is it
increasing , if it is increasing , then because of what fear is increasing, that is time
complexity
...
It is not depending on ( n ) at all And but when it does n't depend on (n), we had
already seen in the lesson
...
If I want to have an insert here, here is an insert , then
I am calling it index 1
...
After that, point it to the next : from here
...
So this is very good news for you You will always work in constant time But good
things do n't always happen We are not always so lucky in life So we 're here therefore ,
looking for worst case
...
be inserted
...
and i will be able to insert element at
end of my linked list
...
I will show you
everything by doing , do n't worry at all you I 'll talk about now Insert After a Node
...
Equate the next to ( q ) to the letter so this linkage comes out
like this
...
These four
cases are very important : for insertion in linked list
...
Whether the insertion we have, is becoming successful or not
...
I have told you the four types of insertion in the last video
...
Get the link from description or can go directly on codewithharry
...
I am creating a
strategy here and will show you how our strategy looks if we wants to insert in the beginning
of the linked list so what thing should I have ? one thing I need is head and other one is data
that what you want to insert
...
I am showing you in the video what I did I wrote here PTR next
is equal to head
...
Many people
are beginners and weak in C
...
So , what will I do here forward the video on that part where i explain you on this
case two coming on insert in between how this will happen
...
No chain will break but this chain connect to this PTR next is equal to PTR
...
This is the simplest the work done so easily but what is head ?
This is head , the function is absolute right i hope it works let 's see it works
...
insert at end is so easy,
what to do in insert at the end ? I copied old function because lot of thing remains similar I
am changing it
...
7,11,41,66 and 56 comes at end why at end ? beacuse I run insert
at end which is code by me see I have only written code here nothing much is done and
code will run absolutely if you say something to computer then computer is very faithful
which I like about computer do whatever you tell it
...
In all the cases you have to
do this only that join links like I tell you in all the 4 cases which I break and join understand
linked list like chain that will do insertion in between deletion also have same trick that we
will see after
...
If you have not accessed my playlist of data structure
algorithm , do it now very few people have access this , I do n't know why ? but I like to
appreciate that many of you shared this on Instagram with tagging me
...
what
will happen to that ? where it 's memory go ? so this thing is such that which can be asked to
you in interviews
...
so If I want to
delete index number 2 means index is given in between and I have to delete it
...
There is p pointing now what you do ? keep moving this how much time ? what you will do ?
you run a while loop run a
...
What you do in while loop in P is equal to P 's next
and till when ? Till you reach index minus 1 way element that means if your index value is
two then how many time you have to run this ? you have
...
index value
...
I ask for the
pointer Q which is pointing that node which I want to delete once I reach till that point then
what I 'll do ? I tell that make P 's next to Q 's
...
next was pointing
there P
...
I hope that this will also be
straight forward I do n't want to make video lengthy unnecessarily for you I will do this same
...
I want to give
you some work case 1, case 2, case 3, case 4 prepare code for all this and if possible create
the code
...
Delete a Node from Linked List (C Code For Deletion From Beginning, End, Specified
Position & Key)
There are 4 cases to delete a node in a linked list - first you can delete the first node in the
linked list
...
So first let 's do this thing here First , i 'll see what
video number is this This is video number 18
...
The function is called delete First and it deletes the first element from the
list
...
a
element at any index
...
It to the next of the head i have selected these 2 pointers one p is here , one q is here and i
'll keep moving forward both p and q
...
Then q will come to 8 , I want to delete where q comes you guys can
understand So why am I doing this here , you will understand I 'll run a for loop
...
You guys understand how this is happening here free
what i have done here, free i have
...
As soon as your linked list reaches the last element, what you have to do is delete it
...
e
...
Link is a game of complete links, whose game is it ? Link 's game it is
...
Here we will
see how it will look like if I delete the last one
...
If you have reached the end of a linked list while searching for data,
what will you do now ? It may also happen that that data is not in the linked list
...
I think I have told for the fifth time , no I will probably tell this
for the tenth time i told it 5 times in previous videos
...
Not everyone has accessed the playlist and would like to say thank you to those
people who have shared the playlist on instagram
...
I want
to tell you this thing all things are same , this all are one concept do n't understand all this in
three different ways
...
If
anybody is saying about linked list and he showed you insertion
...
He said that we can do insertion here we
...
do search , can
do
...
n't get next null starting
from the head we do head 's next , that's next
...
I have not tell you practical use of linked list but I gave you example that how this
things can be useful so here this is circular linked list
...
in loop If I put while loop here and till where I will move ? I move
till P 's data does not equal to head , P ''s next is not equal
...
head
...
P's data where ever is P put one print here print that too which is missed
P
...
and what happens with do while loop is , what you do you should print one time
...
If P is
not equal to head then this data will print here I hope this is understood , I only want to say
this
...
If you want to tell this linked list empty then you point its
pointer to itself so this is one circular empty linked list will be created
...
I want you guys to tell me in the comment that should I add
this type of programs , you want that I make more 15 or 20 videos on linked list how to insert
in linked list
...
What i will do here is i ’ ll shift here to VS
code and here i will create a file and name it same as my video number 20
...
Okay i copied all my main function and i paste it here and now see here what
i have done i created head node 2nd , 3rd and 4th
...
, ptr = ptr - > next ; and repeat this steps untill your
...
ptr
forward till the ptr 's next is n't equal to the head but if i write a while loop here it will be clear
...
Do while loop is created for this purpose only what i will do here is i will move this while
below
...
The case which i 'm teaching you in
my opinion is the most difficult one and rest all is straight forward
...
i 'm saying that the data of ptr
...
We have seen this here in the linked list
...
In doing that , you will have to
use the same concepts that you people have in singly linked lists
...
At the same time, if you have a pointer to the last node then you can walk in
both this direction and in this direction
...
in it : you have extra information in this , what is the
node with your previous : you can also know this
...
I hope you guys must be easy to understand because you guys
have accessed : This playlist If you have n't done it then definitely you will have a little
problem if you're a beginner
...
If I have memory
constraints or memory constraints i will be happy with my singly link list
...
The best
thing is that a pointer who is traveling here : That can change his mood and start traveling
here
...
I want you guys to write a function that first
traverses it in this direction then once your pointer reaches here it comes back and traverses
again that is , once a straight linked list is being printed here
...
The person who is in realistic time can finish this course can
finish it
...
I am
putting it in all the codes nowadays I have taken the feedback very well : Thank you guys So
let 's what we will do now
...
We will talk about what is stacks ? And
the notes that I have made for you, I am going to give you as a PDF download
...
If you are from India, here I am
talking about Indian railway
...
And even if
someone tries to come forcefully Then the thing that happens is called stack overflow
...
Now,
you ca n't add elements inside it ok
...
It is not at all recommended
...
4
...
So break number 4
It will come
...
And break number 3 after it break number 2
...
come out last
...
Along with LIFO it is
...
that went inside last that will be out first so it will be last out
...
Our second application of stack is Infix in
postfix conversion
...
But here I will now want to talk about , our
3rd application Parenthesis matching
...
If one mathematical expression is written, In which parenthesis are used , So is
that mathematical expression valid or not ? Parenthesis in it are matched properly or not? In
order to create a stack we need a pointer to the topmost element along with other elements
...
We need a place to store those elements
...
But for
learning purpose Here we will use integer datatypes
...
So the operations that I have defined in stack ADT Whoever
will do implementation of my stack by watching this ADT He is very clear what he wants to
do
...
Which means I want to add a element to the stack
...
And if I have to remove any element out Then in this
way I will pop out the element
...
So I can easily remove it out
...
Stack can be implemented using an array or a linked list
...
If our stack is full Then it
means we ca n't add more elements to it
...
It has no element inside
...
Those who have read it, tell to others also
...
Sadly very less people in fact two people have shared playlist
...
So thank you from the bottom of my heart
...
Implementing Stack Using Array in Data Structures
Moving forward with our data structure algorithm discussion we will see how to implement
stack with the help of array
...
and why we would want to use this type of data structure
...
Top is the value of index
...
Top 's default value will be -1 if there are no elements
...
Means my stack is filled up till here
...
The top value will be 0 if my stack is filled till here, 1 if till here and 2 if there is no
element in this and with that I 'll write s
...
The default value is -1 but it will
store the index of topmost element
...
Can create
array then can set top and then my stack will be ready
...
But we can
create custom data types stack too
...
So I want to ask you one thing that how will you pop and push an item ?
Then what you will do ? So which method will be best for me ? Most of the operations are
performed in O (1 ) Operation can be complicated too
...
operations
here
...
operations are done in constant time
...
And I did my push
operation so we chose this and not this
...
To implement stack with the help of array what I did first ? First of
all I created a fixed size array you can see here
...
Then I created stack and kept its size 80 so that if I need to
do a big number of push operations then my stack can handle it without problem so this is
how we implemented stack here
...
See in code
...
And we
have choose this orientation because if I want to push any element in this Then I would have
difficulty to maintain all the indexes and that would not be ideal
...
I hope this is clear and we will write its code and
then we will understand it 's operation in more depth
C Code For Implementing Stack Using Array in Data Structures
In this course in our Data Structures course we took a closer look at Stacks and we are now
here to implement Stacks : In C language
...
e
...
There can be a custom datatype but for
learning purpose we read only Stack of Integers
...
Tell me in
the comment below by putting a timestamp will it be right and if it is not right then why will it
not be You guys tell me by commenting below
...
But before that,
before we push or pop , we ask you a question and my question is , you guys tell me one
thing
...
If the top value is ( -1 ) then the
stack will be empty
...
If I write that the top of the ptr is equal to that of the pointer
(size-1) then the stack full : What is Stack , Stack Full : So here we will validate these two
functions , once once
...
We have created our functions with the help of which we will
push into the stack
...
I would love to hear that you guys actually doing the implementation that I
am doing
...
At least once you open the playlist and see the topic
...
I
have written down all the topics : and after that making notes for all : , given the links : in all
the descriptions
...
So with that said , So I would say that you guys please lock this video if you guys like this
video If you guys want to make videos of Data Structure very quickly , many people are
asking : Make videos of data structure quickly
...
Then we talked about how we can
implement stack with the help of arrays
...
All code and everything I have provided you in description
so you should not worry about it
...
So let me draw a separator line so that it will be easy for you too
...
If your SP is full then what you will
do either do printf or do return negative value
...
You might have heard stackoverflow and now you know what it means
...
And I am not
writing pseudocode here I am writing only concept
...
Many of you will say I can not
do it but I will say just try for 5 minutes
...
First of all you do n't need any value to pop
...
We created it
step-by-step
...
We want to keep everything in
term of pointers because we want to to pass stack to functions
...
I 'll not pass one-one value to it
...
To perform pop what you have to do is to perform pop
...
Else move top a step forward and put the value there
...
Coding Push(), Pop(), isEmpty() and isFull() Operations in Stack Using an Array| C
Code For Stack
In the last video of data structure series, we saw that how we can push and pop if we are
implementing a stack with the help of array
...
We had only a variable sp
which only store address
...
Now I have an actual instance of struct stack type , a structure instance
...
arr with the help of dynamic allocation
...
and I 'll write multiply by sizeof ( int ) because this array will store only integers as it
was storing here
...
If the the the top of PTR
will be on the last index of stack array
...
So in this way I can
implement isfull and isempty
...
And if you are facing problem
with C language then watch C language video
...
But 10 sweets can come in this box I am
referring integer as sweet
...
So I can push 10
sweets in this one by one
...
PTR array is an array of our structure pointer
...
I will make it equal to val that it is
Call by Value not reference so it will update automatically and once it is updated so element
will be pushed in this
...
We will print isfull and
isempty before and after push
...
SP 's array top overall means I want the
topmost value in val
...
If it is isempty then stack underflow will print else we will return an integer
...
I will
share this and you will get it please look into description before commenting
...
Go to codewithharry
...
You can share this video then it will help me too
...
I will feel really
good and I will reshare your story
...
Whoever tagged me in last few days , I
have reshared the each story
...
Peek Operation in Stack Using Arrays (With C Code & Explanation)
In today 's video we will talk about Peek Operation that is , an operation that will tell you
about what value : at which position inside a stack
...
What is this peek? What are these peek operations ? This
operation peek , what is this thing I tell about it So what will it take It will take my position ( i )
When we are using stack, we can not start index from 0 We 'll start with 1 because it 's easy
to understand for them 1, 2, 3, 4 are difficult for them to understand
...
When it is 2 then the index of the array is 1, ok And this is 3 so this is 0
So now this is filled with : 3 elements this is our stack If it was out of 10 then what would be
the value of my top Right now our value of top is 2
...
But once you 're 2 steps down ,
you need 2 So ( +1 ) for adjustments , okay So (Top -i +1) you all must have understood :
where it came from So now i have ( Top -i -1 ) So it is very easy for me to complete the peek
function
...
So I would also like to re-use
the old code a bit And along with that, I will also tell you how you can peek the stack here
...
No this one I am not talking about another playlist
...
I pretty much did what I told you guys here
...
If you feel that all this is not happening to me I do not
understand
...
You
do them This playlist is for you If you say that I want to learn advanced things then you have
to go to this playlist
...
The value at index 0 is 46 after that , index 1 is 57
...
If you start filling each box, you will put 1, in it , you
will fill each box with 1, 23, 99 and then the top
...
So keep liking the video , Please and talk about the course in
the comments
...
This is my request : to you If you liked the video please do n't forget to like and at the same
time access this playlist if you guys have problems with logic building
...
is this website And what is this : what is
that and this
...
stackTop, stackBottom & Time Complexity of Operations in Stack Using Arrays
In today 's video we will talk about Stack top and stack bottom
...
It is nothing to worry about
...
So
I will stack top in this much words I do n't want to talk much
...
It
is not mistake that stack is so easy
...
O ( 1) I need to work
that much only Even if it size one array or size 12 array Maybe it is array of 110 120
120,50,60,80
...
And first element is stack
bottom
...
But the first element of stack That's stack bottom ok
...
No big work is been done over here
...
And if you are accessing one array The size of array does not
matter to me
...
It will go inside O ( 1
) Ok, so here we will do one thing We will come in one note and write it
...
If I doing pop from this then I do top On step below
...
So do this every time I am going to need same effort
...
Here I will write O ( 1 ) Because one array is being
accessed
...
Some of the work is getting done in O (1) And
what do you want please tell me the comment I want this because you are getting so much
...
This is the zeroth element of our
array
...
9/10 you know the count There is no issue
...
But only some
programs work
...
And in
...
I will
quickly tell you access playlist
...
And save the playlist
...
Now here we will see with
the help of linked list How you can implement it ? And we'll see what we need to do
...
At the end of our linked list is null
...
We have spent a lot of time on this
thing on linked list
...
And after this finally we need to add
adjustments over here That we have to remove last element
...
And we have done that in detail
...
And I
will make its structure too quickly
...
If we talk theoretically Then stack will never be full because every time we can make a
new node and fit inside it
...
When your top becomes When top is null This will be a stack empty condition
...
In writing both conditions will be helpful for us
...
We will know when we dynamically try to
manipulate Then the pointer in our heap Ptr will be null
...
So I hope after this video you will go with happy
faces
...
I hope you liked this video
...
Or else I will give you the notes
...
com So the code I write I immediately provide it in the description
...
If you want to add
more elements in this , then you can
...
We are
going to visual studio code and will code this
...
and watch isfull very carefully see if
you want , then you can add one limit in this of size for that you have to change a little
...
I will check here that whether
this stack is full ? if this is full, so what will happen ? so I wo n't be able to do it , I wo wo n'
be able
...
I would say the stack overflowed I will print stack
overflow , and I will write print stack
...
For doing push we simply inserted our node in the linked list
...
If you want to pop one element and I am trying to
pop it here what will I do? First of all, I will say that is our stack , this is not empty , so will do
isempty first if and write now isempty
...
Otherwise what you do otherwise return me the value of index zero
...
I created a file
stack using linked list in that , I have written full structure , which I am going to use so I
implement this simply so I directly pick structure from here
...
I
made index is equal to N data stored the value of first element in X
...
I 'll
implement isfull and isempty operations
...
this is structure that 's why here semi colon will
come , so , what will be the top ? top will be a pointer which pointer will be top ? Top will be
struct node type pointer
...
For isfull I have to make an element of struct node * type
...
For
isempty and isfull is done
...
So when I am pushing what will I see ? I will see isempty ? or isfull ? So I am making
some changes in implementation modifying it to make it better
...
This is the stack here which is shown
...
So see first 8 than 7 then 78 because I am
pushing the elements here
...
Pop of top
means the topmost pointer of my stack/linked list
...
When you are pushing this you are updating
top again and again
...
If I make top 8 or 9 or
10 will this change this top? If I want it to change then I will send it 's address
...
So it will get dereference first and then it's next
and this will definitely work
...
I have given all the source code to you
...
Now I have n't showed
you stacktop , stackottom and peek operation
...
And more stack topics which we will discuss
...
Thank you so much for watching this video
...
This is the weekly
Newsquiz
...
com every day at 10 a
...
ET
...
peek(), stackTop() and Other Operations on Stack Using Linked List (with C Code)
We discussed about stack with the help of linked list in last video
...
This number which I have inserted here is in which
way the 28 number is in the last here
...
So the top most element is this and hence we call it as top
as we discussed
...
Because
the topmost element of our stack is 7 so I am saying as top not head
...
If someone move it , if you want to
get till 5 then you will move 4 times your PTR will become null
...
I have uploaded 30 videos here and 31st video I am creating
...
c Op2ll
...
This was a
peek operation I hope you understood it
...
I will make stack
node * PTR and will equal it to top as I did in onenote
...
And here int I is equal to zero , I is less than pos -1 and with that I will
write and PTR is not equal to null
...
And here \n , after this lets
run it
...
And I am keep on peeking it
...
So here it
is showing 7 on 0 position
...
But at some point , I realised that it 's a very easy thing and in today 's
video , I 'm going to simplify the parenthesis match problem for you too
...
We use a stack
...
Compilers and all use it
...
So as soon as I put this, here I 'll put
the closing parenthesis ; And there 's also a \0 if you 're using the C language
...
If this is
...
And till when do you
have to do this ? Till the expression ends
...
When the end of expression comes, my stack should be empty
...
In case this happens, it becomes
unbalanced
...
I 'll talk about another
expression 1 x (8 -3 ) and here I will make it 7
...
So what is this ? This is
...
'' And this one will be unbalanced
...
I 'm scribbling here ; scribble means pop
...
and assume I'm doing something like this
...
If balanced then why ? And if
unbalanced then why? If unbalanced, why is it ? You 'll have to write these two conditions
Due to which condition this expression is unbalanced due to which conditions this
expression's unbalanced is also asked sometimes in exams
...
A safe size will be to take a size that is the size 'n ' of the character array of the stack
...
Nothing will be a worse case than this
...
In the expression you have to start here and go ahead from
there
...
If it returns true 'is empty ' ; then that's a good thing Your
expression is balanced
...
This expression is not balanced
...
If , at any
...
underflows , then game
...
I want that everyone should bookmark it
...
We had written a very simple procedure to find it out we said ,
if we get an opening parenthesis so put that in stack and get it out from the stack , where the
closing parenthesis encounter would have occurred that means pop it
...
go into a for loop, this is our main procedure here i will say ,
go into the for loop , write `` int 1 = 0 '' i can make some mistakes here in the syntax but
when i will write it on VS code , no mistakes will be there because here i am writing only the
snippet for c I will say here that our expression which we took , should not be an end of
expression I will write here , '' exp [ i ] ! = '\0 ' , which is a NULL character , Okay like this i
have used a for
...
In previous video i have
emphasised this very properly
...
So now what will i do here is keep my full focus, something like this that i am creating my
function here, int and i will write char * exp here
...
I think i am good and if i am not good i will look for errors if any
...
A opening parenthesis can be here or closing parenthesis
...
If it is empty then you will `` return 1 '' or else
you will return false and also you can make these 2 lines return isEmpty exp
...
There wo n't be more parenthesis than 100 in any
expression
...
C is a C video of a C program which uses a function to match parenthesis matching using
stack
...
This will only match the
parenthesis , i will show you the proof of this
...
If i do it like this , so this expression is valid this
expression is not valid
...
So you always keep
in mind that this parenthesis matching program will never tell you about validity of the
expression
...
Multiple Parenthesis Matching Using Stack with C Code
If any expression has more than 1 parenthesis, suppose I write an expression A= { 7- ( 3-2 )
+ [ 8+ ( 99-11 ) ] something like this
...
So when I am popping it
then I will matched with which one ? I will match it with closing parenthesis which was
encountered
...
When the full
expression finishes if yes then it is balanced , Else not balanced you might be thinking why
explain it so quickly
...
But while popping I am
adding one more step that whatever is popping is that matching the closing parenthesis or
not like I pop this when I am here the topmost element I popped
...
If yes then pop successful
...
If it is this then I will
push it
...
When I came here I pushed then when I popped is it matching ? Yes
then yes pop is successful and again because this is We need to do a balanced one too else
else else it will be wrong
...
I took a big expression but we will
practice it
...
We will code according to the said as
we made the logic
...
named popped_ch
and name it here inside the function
...
I will
push exp [ i ] = '' \0 '' means till end of expression
...
I will pop whenever my exp [ i ] will be closing
...
Else I am
ignoring the character of my expression
...
This program will tell you whether it is balanced
or not
...
There will be
no problem
...
If I do something
like [ 4-6 ] this then it will be balanced
...
So we do n't require the
stackTop function
...
Use it
...
I will see you next time
...
Share it with us on Twitter @dailymailonline
...
Infix means , I write A+B, I write P/Q
and I write X-4
...
Postfix is that only postfix means that only only that only applies to expressions
...
and AB-
...
If you say in prefix , it will be * AB and in
postfix AB *
...
and if not, it is a simple thing
...
In computer
programming, in C programming we evaluate left to right
...
This will not happen in postfix
...
Computer will run its train
near by A
...
It will continue till it get
operator , once it got then it will check which operand are there before this
...
So these type
of questions comes
...
Infix can be converted to prefix too , but prefix is not used as much as postfix
...
We are not talking about any stack or
computer program right now , We are just understanding what is infix , prefix
...
Always follow operator 's precedence and associativity
...
And you can even ask the precedence if you find any such
operator
...
But
again telling you never need it
...
I want to show you some more
but the postfix of this will be your homework
...
It 's just a way to write expressions , not worry about it
much
...
Now the challenge we have
is , listen carefully , challenge is we have to make this thing automate
...
Then write with timestamp and
l 'll write here that please, add timestamp to your comment
...
This much people have accessed which is good
...
Very few , people like I do n't know what you lose in liking but , if you like then
I will feel really happy nothing more than that
...
Let me tell you
beforehand that this video is going to be very important
...
The way we saw will be difficult to program so with the
help of stack , How will I do it just watch
...
So can I push it ? No
...
- has 1
...
so it can
...
on top
...
But as soon as it came on - then what happened - can not
...
because - is smaller than / so it is smaller so it cannot stay on
...
So - and
- have same precedence then too we will pop
...
We pop this
...
Let 's check that the procedure I have used with
the help of stack is giving right answer
...
My y/z will evaluate
first so I will put parenthesis there
...
This is operator this is precedence will write
p only due to space
...
Then can come so I pushed - and I
In last video we have converted some expression in postfix , do practice them
...
So if I do it with stack Will do it quickly so look
carefully and will take red color to make a stack
...
If you know data structures then it will help you in placements
...
Programs will start creating and
many things
...
If you like this video then do like
...
And I will
reshare your story
...
This is a program
that converts infix expressions into postfix expressions
...
So i will do this
using stack , how we will do it ? What 's the procedure ? i told you before and now i will
convert this into program
...
I made two counters because this counter i
made, i = 0 , this i created to scan my infix expression
...
This procedure which
i wrote before you is in infix to postfix using stack first of all there is an infix expression i have
a postfix expression
...
Add directly it into postfix , increment `` i '' and increment `` j '' together together
...
If this is an actual operator then i have to push it into stack but i will push it in
stack then only when it 's precedence
...
We will
show you how to code a program on VS code
...
It will take a simple expression and return infix to postfix
...
c
...
After i am done with it, i will write `` int i = 0 '' and this will
track my infix traversal
...
The last character of my postfix should be equal to NULL character so make it " \0 '' then i
will `` return postfix '' and i guess this will do my work , i hope i have n't made any mistakes
while writing this function
...
precedence will take a character, char ch and what i will do here is write a if here, i will write
here
...
What i
mean here is if your more operators comes then you have to update your function of
precedence
...
If you have
accessed this playlist of data structures and algorithm, so please access it guys
...
Queue Data Structure in Hindi
Queue Data Structure
...
So what
happens is that when we take the ticket counter of the general
...
If you break the line then the people who are there
...
So this is what we say : Our Queue It is said that come in the line , in India
the lines are called People say brother , come in
...
Insertion is happening
from one end
...
happening from different ends
...
No one can enter from the middle from here And the deletion will happen from this end
...
In any abstract data types there are
2 things we have One thing is data and the other thing that we have are methods
...
Enqueue enqueue means that a person has come to
Queue
...
We may need us, who is in the very last of last value
...
Queue is not
limited only for counters but it has many other uses - KOA : that 's why we take it right
...
If you guys are not liking
the video then please I want to request from you guys , like this video
...
And after that you like I do n't want to
be a person just saying that I should speak
...
As if you guys want it to be like Any one of yours comes in
Queue , You keep track of it ok So what will you do ? if I am implementing Queue with the
help of array? We saw in the previous video that what is Queue a counter : say , it is a
counter Let 's say an ice cream bar : OK, an ice Cream bar
...
I call it back ind , that is the
back index Index Index of the rare most element
...
This is the enqueue operation I told you people The
insert is called the en queue operation
...
This is happening in constant time since
there may be one element even if there are one thousand elements
...
If I improve this thing then what will I do over here I am here to back Ind as well as front Ind
...
So I will
say that you will be able to do this very comfortably in 0 (1) Well, then it will be your work in
constant time
...
The first element will be on the front Ind ( +1) The front Ind
will move in the same way that I will remove the elements
...
I will increments front Ind or Remove element at front Ind
...
The condition of Queue full will be : Empty will be here, ( p ) is not
written It does n't matter, understand it
...
The
back Ind was meant to be the index of the last element in the array
...
The ice cream cart was
standing like this A person came as soon as a person came
...
Pointer will not say this, because it is just
storing value
...
And I wo n't ( f ) be ( -1 ) , I 'll
make ( f) be 0 now
...
As soon as becomes 6, Queue will be full condition
...
As I will continue to remove , the front will move
...
Then I have to remove one more element
...
Array implementation of Queue and its Operations in Data Structure
In today 's video we will talk about That how we can Implement queue with the help of array
...
And very easily we
can make it possible So I have took one array over here
...
So I will call this F and this R
...
And then what
will I do ? In the same way I will keep on moving rare forward
...
to add one more element I will move rare
...
add 11
...
So dynamically I am not allocating the memory
...
But for this example I am making it struct queue
...
And along with that this
array Our array We would like to allocate it dynamically
...
One is enqueue operation And one is dequeue operation
...
I hope you understood How we can implement our queue
...
It's not a big thing
...
Is it isfull or not ? If not of isfull,
then you will do this thing
...
If I want to add an element in queue, I will make rare move forward
...
If queue is not full then for me it is a green signal
...
I will move forward I will add val to queue
...
Dequeue means simply remove one element from queue
...
And I will
remove this value
...
So we will do
dequeue from start
...
So here I will do one thing
...
The condition was small so I directly wrote the condition
...
If this does not happen than we can do dequeue
actually
...
We
are at the end by filling it
...
And we will understand queue properly
...
So must not be facing any problem in it
...
And until now if you have
n't accessed data structure playlist Then definitely do it
...
I 'll include the
stdlib
...
And our queue will be formed
...
So when I 'm doing int queue, is my queue full ? So if it happens that q is full, So
the queue will overflow
...
And after
increasing the rear, the value is at the value
...
like
assume I 'm doing 12 , And where will I do it ? I ''ll give the address of q & q ; why & & q ?
Because we have to take a pointer ; we must take an address and take the value
...
What will happen because of this ? The original q will change
...
So after enqueue, I wo n't see 'queue isEmpty'
The reason I 'm telling this faster is that things are repeating here
...
Instead of enqueue , it will be dequeue
...
I'll run it below and I 've enqueued two
elements and I put them in the queue
...
So it
's neither empty nor full
...
I hope you
found this video helpful
...
If you understand these
concepts then you will appreciate this speed
...
But again, some people think I teach fast
...
I try to teach at a moderate speed
...
If you think I'm teaching slowly You can
make it
...
teaching fast You can also use these values to make it easier
to play playback speed
...
You
will also say that it is fun , Okay So infact we should do the recap very fast We should not
spend much time So what did I tell you people? Rare pointer does not speak pointer that We
speak front and rare that
...
Space is
not used efficiently
...
But We ca n' use it and this is a very big problem how good would it be
if I was able to use all these spaces in some way ? The whole does not want to be in their
body because time will be waste
...
We will forward this man that is , we will forward the counter person
...
enqueue(), dequeue() & other Operations on Circular Queue
CodeWithHarry
In last video, It gave a good introduction of circular queue
...
But things will become so easy , That you
yourself will say it was never this easy
...
And here what will I do ? I
will tell you about circular queue How you can code ? We can use concept Of circular
increment What was the concept of circular increment ? (i+ 1 ) % size So we will do i=i+1 %
size
...
So in this way circularly use this queue
...
Our one element will be empty
...
If it is full then I ca n't add
...
I will then add a value in queue
...
I closed this else over here by opening curly brace
...
In this way you can do enqueue , You can do many insertion
...
There is no issue
...
Dequeue operation is also important
Title: DSA-data structure
Description: This is high level course you should study
Description: This is high level course you should study