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: Linked list
Description: Introduction of Linked List Creation and Traversal in Linked List Insertion of Nodes Deletion of Node Insertion in Linked List Circular List Doubly Linked List
Description: Introduction of Linked List Creation and Traversal in Linked List Insertion of Nodes Deletion of Node Insertion in Linked List Circular List Doubly Linked List
Document Preview
Extracts from the notes are below, to see the PDF you'll receive please use the links above
Introduction in Linked List
With a very good example i will show what is linked list and why would you like to use it
...
In every hospital each single bed
was utilized utilized utilized them so this is linked list
...
The size of our array can be so large that we do
n't know2 today these are 7 tomorrow these may be 7 lakhs even then if we want to allocate
memory if the array of 7 expands or if the capacity of array is low then it will be a problem
...
This too will run like this and point to the next node so here as you remember the
example of the hospital how did I gave the analogy that i just gave an example to explain
...
LinkedList is just like a chain it is a chain with hooks
...
If you would have created an array you do n't
get the luxury to remove this how will you remove this element this is contiguous memory
location you have to move it only or else they wont be there
...
Let's see where which to use and which one will give you advantage and when
assume that if you want to access the elements like this 4 element 8th or 9th element so you
can access in constant time do you have this pointer assume this pointer how much you
have to join to get the access the ptr
...
The drawbacks of array are the linklist shines
over here have written the thing completely short crisp and to the point are not lengthy notes
at all which means short crisp
...
In array and linked list we have seen
that the memory is the same
...
i hope you all have got the idea of linked list and in next video i will explain
implementation implementation
...
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
...
So far
maximum 2-3 people must have done so if you do then thank you so much
...
Insertion of Node in a Linked List
The Insertion and Deletion all this is going to come in linked list , it 's all very easy
...
What we are going to do is simple in a way
to understand the problems of C programming
...
I get access to linked list , with the help of head node
...
How do i have to do to do this , you think for yourself First of all, what will I do to link
it , something like this
...
No matter how many elements you are ahead of here , it has not even seen the
element
...
We can insert node at any one index
...
I 'll write a function named Insert at index and what do i do inside it
first i will create a node
...
Complexity of Insert in
between will have complexity O ( n ) O (n) : of our worst case complexity of insert in
between
...
The complexity of Insert at the end is O ( n ) - its complexity will
always be O (n) Insert after a Node is the worst case complexity
...
The last
element of a linked list will become the last element
...
O ( n) will explain the complexity of Insert after a Node in the comment below
...
After this
you have to insert an element
...
In the next video, I will tell you how we can code all these four cases
...
And after that we will print and see the
list also
...
So do n't miss the
next
...
And if you have n't accessed this course
of Data Structure then do it
...
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
...
so atleast watch
this last video first because I have explain this in the video
...
Deletion in Linked List
After this you 'll never ask how to do deletion of any node in linked list because I am going to
tell you in very clear way
...
When you delete node of linked list
will you leave this memory on hang ? no you have to free it , It is dynamic memory you
allocate this memory dynamically that is allocated dynamically that 's why
...
I have a given index of it what I have is head and where is it pointing ? with that I
have given index so suppose I assume I assume that it 's index is 0
...
If I write case 2 here
like this I write here deleting a node in between what to do for that ? deleting a nodes in
between , so see we have nodes in our linked list , I will erase this here I told you here how
you delete the first node
...
while loop
...
to run one time if your
...
is 3 then you have run one two times so you will see this after what to put
...
next that means where Q
...
s next will point why ? I want that 8 's node to be deleted
...
I will show you all this thing in code how can we do ? so there you will have more fun to
watch so do one thing we will go in VS code in next video till then what you do
...
If not then write it down with idea and I already tell about case 2 you have to do 3
and 4 I want that you write rough idea and we will meet in next
...
Delete a Node from Linked List
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
...
Circular Linked List
circular linked list is one concept that people get confused about circular linked lists
...
I am giving one practical example if you have seen my jango
...
He showed you search ,
traversal
...
can do deletion , can
...
search and can do traversal we moving forward till when we do
...
If you have watched my jango 's video so I
have made an E-commerce website and there I have shown you that how items can come
like this
...
When you do like this then item will
turn and keep turning suppose after 4 , 5 is hiding so suppose you clicked on this then this
you can watch 5 from here
...
to null when eventually P will
reach here while moving so P will be equal to
...
so I can do is write it after this while
loop that print the
...
s data
...
If you want to search an element see search is same like traversal , you return it when you
find it that this is the pointer of that and here is data search is done through traversal
...
There is another presentation of circular linked list what happens in that ? create a node
like this there is one pointer and your real linked list starts from here and this is only one
head node you can not store data in this In this you can point this only with another node
and point that with next node
...
I want to make this
course crisp and to the point and after that I 'll add programs even If I made another playlist
named data structure practice
...
Lets create a linked list so how i made my singly linked list , i 'll
show you how i have created a singly link list here and shown you so if i go at any one
program of singly list here we have one structure here
...
If i write something like this in while loop like , run while ( ptr ! = head ) Okay , After
some loops ptr will be equal to head move ptr forward
...
I 'll keep moving my
...
If i do this, the traversal of this will never start see if
i show you by calling and running this function
...
A semi colon is must in do while if you know by the way if you have n't watch C
videos , i had posted 15 hrs video with notes with notes
...
If you ever faced problem,
this is were you will face it that why i 'll show you how to do it rest all you can do it by your
own
...
you have to make that equal to the data that i have
to insert I 'm returning pointer of struct Node * i have done head properly at here at here ,
insertAtFirst ( head , 80 ) , and what i am doing here is explained by me in the previous
video of singly linked list
...
So i will connect a new link here as you can
see , what i am doing here is so like this i am making p ''s next here equal to ptr
...
Blue blue will
indicate new connections here
...
Doubly Linked List
We have a pointer pointing to the first node
...
In that
too there are operations like insertion , deletion , search too
...
There are many uses of
doubly linked list here and one of the uses of it you guys can reverse it easily by swapping
the pointers
...
There are other uses too I will also make you guys
get the practice sets of linked list etc
...
A lot of people have access but still the
number of people who picked up the course : not everyone has access from here I want all
to access , to bookmark
...
bookmark this playlist by clicking here Click here to save
I prefer to use singly linked list if I feel like it will be more feasible
...
You come in a
doubly linked linked list when you may have to go back and forth in both directions
...
I want to give a challenge to you guys here
...
Then you see people getting
the reverse linked list printed
...
We will wrap the topic of linked list and come later we will return to linked list And
after that we will see the people who : this , but you have to code the doubly linked list
...
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
...
Implementation Stack using Array
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
...
Now we will run in code , i
...
in Visual Studio
Code and we will write here how the stack is made
...
I am going to do a little variation here and
you guys see what variation is going to happen I made a very simple stack here
...
The most talked about ones are push
operations : one , and pop operations : to insert an element inside the stack
...
what is push and pop? Is there any condition for them what i mean to say here is can i
push if stack is full : Or can I pop if the stack is empty or not?
IsEmpty isEmpty checks if this stack is not empty or not
...
If my stack is empty, then I will write if ( ptr - > top == -1) ok, if i did like
this I will return (1) What does (1 ) mean, return ( 1 ) means true and i will do ( else ) return (
0) Now I always prefer to write my function in such a way that I am applying ( if ) also ( else)
because readability increases
...
Once
...
I want Interact, comment below and I want the comment to be filled with
these answers
...
Coding for PUSH POP empty or full operations
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
...
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
...
Title: Linked list
Description: Introduction of Linked List Creation and Traversal in Linked List Insertion of Nodes Deletion of Node Insertion in Linked List Circular List Doubly Linked List
Description: Introduction of Linked List Creation and Traversal in Linked List Insertion of Nodes Deletion of Node Insertion in Linked List Circular List Doubly Linked List