Posts

Showing posts with the label loop

Thank you, next! Linked List in C++; Lesson 5

Image
Hope you are following us from our first post about linked list, if so! lets continue with our linked list lesson, if not, don't worry, you can start form the beginning, here are links for you to review our previous lessons: Linked List; Lesson 1   Linked List; Lesson 2   Linked List; Lesson 3   Linked List; Lesson 4   Alright! lets begin our fifth lesson i.e deleting node.Now this is a feature of linked list which array doesn't provide. You can always overwrite any value in array but you cant delete it, but linked list gives you the opportunity to do so. Say, you have a linked list of 4 nodes and you are tasked to delete a node from that linked list asked by user at run time (This code will be quite similar to insert node code). For this, you'll be codding del() as follows: void del() {     node *temp = new node; //1     node *temp1 = new node; //2     node *temp2 = new node; //3    ...

Thank you, next! Linked List in C++; Lesson 4

Image
Hope you are following us from our first post about linked list, if so! lets continue with our linked list lesson, if not, don't worry, you can start form the beginning, here are links for you to review our previous lessons: Linked List; Lesson 1   Linked List; Lesson 2   Linked List; Lesson 3   Alright! lets begin our 4th lesson. As we previously learnt about creating nodes and printing by using concept of linked list, further we learnt about inserting new node at head position and a t some given/specified position. So today we'll try to insert nodes at: At position specified by user at run time.   At position specified by user at run time: If you understood lesson 3,this will be a piece of cake for you. So what we are trying to do here is just to replace a specific position in code with the position given at run time by user. For this you'll be codding insert() as follows: void insert() {     node *temp = new nod...

Thank you, next! Linked List in C++; Lesson 3

Image
Hope you are following us from our first post about linked list, if so! lets continue with our linked list lesson, if not, don't worry, you can start form the beginning, here is a link for you to review our previous lessons: Linked List; Lesson 1   Linked List; Lesson 2   Alright! lets begin our third lesson. As we previously learnt about creating nodes and printing by using concept of linked list, further we learnt about inserting new node at head position. So today we'll try to insert nodes at: At some given/specified position.   Insert node at some given/ specified position:   Suppose you have a linked list with (say) three nodes and you are required to insert new node such as, after second node i.e your new node will become third node,third node will become forth node and so on. For this, you'll be codding insert() as follows: void insert() {     node *temp = new node; //1     node *temp1 = new...