The problem of linear structure explains "example" reversal chain list
Pack This system is a black-box test, no matter what your code looks like, as long as the results are right. Java
Are linked lists useful only in C and C + +? Because there is no pointer in Java. An array of structures is also possible.
What is an abstract linked list?
The list needs to have a block of local data, there is a block of places to save the pointer-the address of the next node.
Single-linked list reversal
Reverse reversal, starting from 1, 2 to reverse, but to remove 2 points to 3 points and 2 points to 1, 3 nodes will be lost, the back of the list is all lost, so, first to save 3.
Standard template pseudo-code for single-linked list reversal
PTR Reverse (PTR head,intK) { intCNT =1; New= head->Next; old=New-Next; while(CNT <K) {tmp= old->Next; old-Next =New; New=Old ; old=tmp; CNT++; } head->next->next =Old ; return New;}
This is the standard template for single-linked list reversal, but pack is a black-box test,
You can also use stacks,
Test data
There is no tail reversal
Address fetch upper and lower bounds
Just full reversal.
K=n full Inversion
K=1 No reversal
There are extra knots.
Max, Min
Boundary test.
Data Structure--tree (medium)--The problem of linear structure