Image

Intro to linked lists

16 Mar

Got working on linked lists this week for the first time since my Java class in high school. Much easier to follow in C++ versus Java, having pointers and literal arrows ‘->’ makes the concept much easier to grasp, although challenging nonetheless. As Fardad has stated several times, when mapping these things out, having a multi colored pen is beneficial. I did’nt have one, but I had 2 markers, a black pen, a pencil, and an imagination. here is the diagram I used when programming my doubly linked list:

 

TV-fTFEi0ZvaqsmiB8uxJLrKeAvVww62I22n8F6xyHc

 

I intend to optimize it over the weekend and I will post my code, here is my queue single linked list add function : (big up to Nick Kemp for help with this one)

 

 

void Queue::add(int data){

Node*t=_head;
if(_head==0){

_head=new Node(data);
}
else{
while (t->_next){
t=t->_next;
}
t->_next=new Node(data);

}

}