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;
Title: Reverse list of nodes from m-n locationsFor example:Given1->2->3->4->5->null, m = 2 and n = 4,Return1->4->3->2->5->null.The nodes from the second to the fourth are reversed.where m and n satisfy the condition:1≤ m ≤ N ≤length of the list.Ideas:Still in reverse order, consider using a secondary space stack.The nodes of the m-n are sequentially placed into the stack and marked with the front and back two nodes adjacent to the stack node Pfirst an
Title DescriptionEnter a list that returns a ArrayList in the order of the list values from the end of the header.Title Addresshttps://www.nowcoder.com/practice/d0267f7f55b3412ba93bd35cfa8e8035?tpId=13tqId=11156tPage=1rp=2 ru=%2fta%2fcoding-interviewsqru=%2fta%2fcoding-interviews%2fquestion-rankingIdeasUsing the Python library function, create a new list, insert
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
Static linked list of adding and deleting, note the method of boundary check and parameter validity check. Test cases should be comprehensive!!!#include This article is from the "Small Stop" blog, please be sure to keep this source http://10541556.blog.51cto.com/10531556/1703847Linked list: static linked
"Idea": the direct addition of the test data is the line. But I still want to try the list, data structure after a year does write a little trouble. Alas.Note: The spelling of the node link. And p->p at the time of traversal, skimming the head node."AC Code":#include Blue Bridge Cup ALGO-107 9-7 linked list data summation operation (
Joseph's ring is an application of mathematics: n people (represented by numbers 1, 2, 3... n) are known to be sitting around a round table. The number of people numbered k starts to report, and the person counting to m is listed; his next person starts from 1
The number of people who count to m is displayed again. Repeat this rule until all the people around the Round Table are listed. Now we are writing a circular linked
The number of inserts is num. If it is smaller than the head, it is inserted in the chain table header. If it is larger than the elements in the chain table, it is inserted at the end; otherwise, it is inserted in the chain table;
The Code is as follows:
1 link * link: add (link * plink, int num) {2 link * P1, * P2; 3 p1 = plink; 4 link * p0 = new link; 5 P0-> id = num; 6 7 while (P0-> ID> P1-> ID) (P1-> next! = NULL) {8 P2 = p1; 9 p1 = p1-> next; 10} 11 // insert 12 if (P0-> id 28 return pli
Classic question, the Code is as follows:
1 # include
Given the head pointer of a linked list, it is required to traverse only once and reverse the element order in the single-linked list.
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
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.