mirror of
https://hub.njuu.cf/TheAlgorithms/C-Plus-Plus.git
synced 2023-10-11 13:05:55 +08:00
Update the description in data_structures/reverse_a_linked_list.cpp
Co-authored-by: David Leal <halfpacho@gmail.com>
This commit is contained in:
parent
650a2fdc46
commit
19b4a93702
@ -9,13 +9,13 @@
|
|||||||
* the pointers) starting from the first link. Whichever link points to null
|
* the pointers) starting from the first link. Whichever link points to null
|
||||||
* is considered the last link and is pointed to the new value.
|
* is considered the last link and is pointed to the new value.
|
||||||
*
|
*
|
||||||
* Linked List can be reversed by using 3 pointers ,current ,prev and next_node
|
* Linked List can be reversed by using 3 pointers: current, previous, and next_node;
|
||||||
* ; We keep iterating till the last node,meanwhile before changing to the next
|
* we keep iterating until the last node. Meanwhile, before changing to the next
|
||||||
* of current ,we store it in the next_node pointer; now we store the prev
|
* of current, we store it in the next_node pointer, now we store the prev
|
||||||
* pointer in the current of next ,this is where the actual reversal happens,
|
* pointer in the current of next, this is where the actual reversal happens.
|
||||||
* And then we move the prev and current pointers one step forward.
|
* And then we move the prev and current pointers one step forward.
|
||||||
* Then the head node is made to point to the last node (prev pointer) after
|
* Then the head node is made to point to the last node (prev pointer) after
|
||||||
* completion of iteration .
|
* completion of an iteration.
|
||||||
*/
|
*/
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user