Singly linked list questions are written in C, c Linked list class template questions Don t use C, u

Updated on technology 2024-03-16
3 answers
  1. Anonymous users2024-02-06

    Heada and headb are both singly linked lists with leading nodes. In this algorithm, we delete the common elements from the ith element in the heada linked list, and then insert the single-linked list heada before the jth element of the headb.

    if ( i < 1 ||len < 1 ||j < 1)

    printf ( "The parameter is incorrect");

    exit ( 0);

    p = heada;p is the working pointer of the linked list a, which is initialized as the header pointer of a, and when the ith element is found, p points to the i-1 element.

    int k = 0;Count.

    while ( p != null &&&k < i-1).

    k++;p = p->next;

    If ( p == null) i is too large, exit the algorithm.

    printf ( "The %d given is too big", i);

    exit ( 0);

    q = p->next;q is the working pointer, which initially points to the first node of the A linked list.

    k = 0;

    while ( q != null &&k < len)

    k++;u = q;

    q = q->next;

    free ( u);Delete the node and move the pointer back.

    if ( k < len)

    printf ( "The %d given is too big", len);

    exit ( 0);

    p->next=q;A linked list removes len elements.

    if ( heada->next!=null) heada->next=null indicates that all nodes in the linked list have been deleted and do not need to be inserted into table b.

    while ( p->next != null) to find the tail node of a.

    p = p->next;

    q = headb;q is the working pointer of linked list B.

    k = 0;Count.

    while ( q != null &&k < j - 1) Find the jth node, and when the search is successful, q points to the j-1 node.

    k++;q = q->next;

    if ( q == null)

    printf ( "The %d given is too big", j);

    exit ( 0);

    p->next = q->next;Chaining the a-linked list in.

    q->next = heada->next;The first element node chain of A follows the J-1 node of B.

    free ( heada);Release the A header node.

    return headb;

  2. Anonymous users2024-02-05

    Because I don't know the specific problem, I can only write the algorithm idea to provide reference, assuming that the node type of the singly linked list is nodenode *p, *q, *a; p=;(the first element of a) int k; for(k=0;k

  3. Anonymous users2024-02-04

    Look at Yan Weimin's data structure.

Related questions
5 answers2024-03-16

What exactly is to be done?

7 answers2024-03-16

Look"Malloc", there is an article on the first page that is clearly written.

9 answers2024-03-16

Scope. You static char *chh;

static char *ch1;Although the address pointed to by the two pointers does not change, have you ever wondered whether the memory address they point to has been released, char chc[10]; It's local, the function is out, the lifecycle is over, and you're trying to access it with a pointer in void times(). >>>More

6 answers2024-03-16

Use the ITOA function.

Prototype: extern char *itoa(int i); >>>More

3 answers2024-03-16

I wrote it myself and solved it directly with a one-dimensional array. >>>More