hello there today I'm here with my
colleague lee in order to do a small
introduction to link lists so now that
those are those are going to be
exercises are going to be a bit more of
a challenge but we believe now that you
have the tools to face a challenge in
order to put you on the rails to put you on
the road we decided to do that
small introduction or more precisely Lee is
going to do the small introduction is
going to explain what a link list is and
then is going to show us a small example
with the code right lee so what so what
sneaky link list is a linear data
structure in simple words a linked list
consists of nodes where each node
contains data that it can be an int a
string or even an interface and it
reference link a next node so a pointer
to the next node as we can see in the
example we have a node in this case
with the data that's three and a pointer
to the next node and so on okay so if we
want to insert one what happens yeah if
you want to insert one we basically
grab the pointer to the pointer of the
node and point to the data to
our and then the first element of the
note okay this is not a must you don't
have to do always at the first element
of the node there are other ways to
insert that data right it's not
mandatory yeah you can insert it in the
end of the list or in the middle of the
list the beginning of the list
there are several ways you can insert
a node
and okay but today you're gonna show us
that example yeah today we're going to
show the first insertion on the
first position of the list okay so let's switch back to
code I guess and shorts if you don't
mind so let's create a terminal okay
okay sorry my keyboard is the British
so we have to initialize the note and the
note is a structure okay so
first you define the links of the chain
first we define the note then we'll
define the links so we have data that's
int in this case and a pointer that's
next that points to the next node okay
so if you want to inserts let's create a
function to insert so we have
to have a pointer to the know and other
data we want to insert that's an int
we have to return our node so we have to
initialize a node let's say n equals
let's put node and our data inside
so if the first position of the
the list equals to nil or null
it will return I will not look at our
node else our node so
our node with the appointed to the next will
point to the head to the head of the list
and then does it return the yeah okay
so we want to see the link list that's
the function to print it so print
list it will have as parameter the
pointer to the note to the link list
and Iet's say we have to interact every
position of the list so we have to a
for the head is different from nil oh yeah
we have to print the list so print each
note in this case will be head dot our
let's to be more clear
let's add a link okay so
we have to update the head every time
so head will equal to head dot next and just
to be visualize the tail of
the list will print
but that's just for the last one
less yeah okay so that's really pretty
much so let's initialize the link
that's a pointer to the node and it's
such that that's insert let's insert
in the link link the data pretty much okay so
let's do like the image let's insert just
the one then the two and then the three
and let's print it so print list so if we
run this
should  run
okay so okay so this is a linked list
If we do it exactly like the
images actually on-screen I add another
one right the fourth one and this will
work
all right so that's that little program
does the job so what we have here is one
function for printing the list one
function for inserting the nodes and a
structure to define the type of nodes
okay okay well so thank you Lee as you can
see it's it gets a bit more complicated
than previous videos but we invite you
to watch it again and again and find
more resources online and good luck for
all the exercises thank you for watching
and thank you Lee again
