-whats a head?And what is its role?
The HEAD serves as the entry point for the linked list. It's value is a pointer to the physical memory location (address) of the first node in the linked list. A node contains the data the user is interested in as well as a pointer link to the next node (and, if it's a double linked list, it also contains a pointer link to the previous node).
-Whats a pointer link? And whats its role?
It's a data element in each node which points to the physical memory location of the node which follows in the list.
-Linked list principal and how it works?
A linked list is like a group of web pages. Each page contains data, but only one hyperlink (pointer link) to get to the next web page. So, in order to get to the fifth web page, you must go to page one, click on the hyperlink, which takes you to page two, click on the hyperlink, and so on, until you recognize that you are at the page you want, the fifth one.
Now imagine that the only web page address you ever learn is the first web page. Imagine you do not have a "back" button to get to the previous page, or a history list. This would mean that every time you wanted to find a web page, you would have to start at the first page, the HEAD, which serves as the entry point for the set of web pages (or linked list). You would then traverse through each page in a linear manner (you can't jump past pages), until you found the one you were looking for.
- you also wanted to know about double linked lists
They are like a web page that has a hyperlink to the previous page as well as the next page so that you can navigate in either direction, but in a linear way.
In the linked list, each node physically contains a data pointer to the previous node, a data pointer to the next node, as well as the actual data the user is interested in. In the head node, the pointer to the previous node would be NULL. In the tail node, the pointer to the next node would be NULL. That's how you would know as you were traversing the list if you had arrived at the end or at the beginning of the list.
A person designing the flow of the web pages pages could add another one at any time, simply by modifying the hyperlink on the last page to point to the new page. If they wanted to delete a page, they would modify the link on the previous page to skip the current page and point to the next page. Then, the current page could be removed. An inserted page would be handled in a similar way.
One advantage of linked lists is that linked elements can be added or removed dynamically, to allow the total number of elements in the linked list continue to grow or shrink as needed.
-Is a linked list similar to an array?
Let's illustrate an array using the web page example. Imagine you are using a frame (or boxed area on the left side of the web page) that contained an index of links which allowed you to go directly to any page that you wanted. This index would save you from having to traverse each and every page until you found the one you wanted. However, imagine that you were unable to add more indexes. You have to know in advance the maximum number of pages, so you could initially set up the index directory properly.
Historically, the main disadvantage of arrays was that you could not change the total number of elements dynamically. You had to allocate a specific number (i.e. int MyData[50] -- which allocates 50 elements... what if later, you decided that you really needed 75 as the program was running?)
-How do I insert, delete, locate, and print out the values?
I'm going to take a breather. X-) Please read what I've written so far. If and when I get enough time, I may take a crack at giving you an example, unless someone else beats me to it.
Hope the web page example helps. Let me know if something is still unclear.