Package Linklist;public class NodeGorgeous Split-line ********************************************************* ***************Package linklist;/** * **************** single-linked list with lead node and its implementation ********************* * * @author WL * */public class SINGLYLINKLISTL T t> {nodeJava data structure System--linked
A long time ago practice, it is not very difficult to see. Packageproject;classnode{Private intId//Private is only accessible to this class of objects and methods. PrivateString name; PublicNode Next;//point to next class node PublicNode (intId,string name)//a method for constructing a parameter{ This. id=ID; This. name=name; } Public voidDisplayLink ()//Display node content{System.out.println ("ID:" +id+ "" + "Name:" +name); }}classlinklist{PrivateNode first; Publiclinklist () { F
Given a linked list, return the node where the cycle begins. If There is no cycle, return null .Follow up:Can you solve it without using extra space?The first question asked whether there is a ring can be seen using a fast pointer as long as there is a ring will meet the other from the meeting point can be seen from the point of the distance between the distance ring and head to the starting point of the d
1#include"head.h"2 structStudent *del_same_age (structStudent*head,intAge )3 {4 structStudent *p, *pt;intFind =0;5p = pt =head;6 while(P! =NULL)//when looping to the last node7 {8 9 if(P->stu_age = =Age )//if equalTen { Onefind++;//description found A if(p = =Head )//If found to be the first node - { -Head = p->Next; thep = p->next;//loop node move back -PT =p; - } - Else//If not the head node + { -Pt->next
typedef struct LINKEDLIST
{
int data;
linkedlist* Pnext;
}linkedlist;
/**
* Test 6, write a function to check whether there are loop in a linked list
* @param plist [input] linked list
* @return BOOL, if there is loop inside, return true, otherwise false
*/
BOOL Checkloop (linkedlist* plist)
{
linkedlist* P1 = plist;
I wrote an article a few days ago about how to create a linked list. Now, how can I print out content for another operation on the linked list.Keep up with the previous Code and write the print function.Void print (struct student * head){Struct student * p;Printf ("\ n these % d records are: \ n", n );P = head;If (head! = NULL)Do{Printf ("% ld % f \ n", p-> num,
Method 1: implement with the stack, step backward from the first node, and then push the node pointer (Address) into the stack in sequence. After all traversal ends, extract the content from the top of the stack and print the data. Since the later Node Address is above the stack, the printing order is printed from the end.
Voidprint (node * List)
{Stack
Method 2: implement with recursionCodeConcise, but when the
Reverse a linked list from position m to n. Do it in-place and in one-pass.
For example:Given1->2->3->4->5->NULL, M = 2 and n = 4,
Return1->4->3->2->5->NULL.
Note:Given m, n satisfy the following condition:1 ≤ m ≤ n ≤ length of list.
It is still complicated to deal with this problem. Many boundary test cases need to be considered. My general idea is to mark the p
Solve the Joseph problem public class yuesefu{//define the nodes of the linked list public static class node{public int value;
Node Next;
public Node (int data) {this.value=data; }///Solve the Josephson problem/** head Ring List header node num reported number/public static node Yuesefu (node Head,int num) {if (head==null| | num
List Introduction
A list is a generalization container for a doubly linked list whose data elements can be strung into a logical linear table through a linked list pointer. Unlike vector and deque containers with linear table seq
one, the list and array have their own advantages, which is suitable for the use of arrays, what is the appropriate use of linked lists.
When we expect frequent inserts and deletions, the list is more advantageous than the array. However, arrays are more advantageous when we expect random access to be higher than the number of insert and delete operations. Rand
At the end of the previous section, we can already determine if the list has a ring, if there is no ring, then according to the first two sections of the method to determine whether the linked list intersect and get intersect nodes, if there is a ring it? How do you tell if you intersect?TopicGive the head pointers of two unidirectional lists, such as H1,H2, to d
Problems with pointers to resolving data stored on linked lists that cannot be exported
The construction of linked lists, and the implementation of linked list access
Use of pointers
Pointers, linked lists, storage of linked lists
Two-way linked list is also called double linked list, which is a kind of linked list, and it has two pointers in each data node, pointing to direct successor and direct precursor respectively. Therefore, starting from any node in
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.