C ++ merged linked list

Source: Internet
Author: User
Void mergelist (linklist la, linklist * LB, linklist * LC)/** // * algorithm 2.12 */
... {/** // * Elements of the known Single-Chain linear table la and lB are arranged in non-descending order by value. */
/** // * Merge La and lb to obtain the new single-chain linear table LC. The LC elements are also arranged in a non-descending order of values */
Linklist Pa = La-> next, Pb = (* lb)-> next, PC;
* Lc = pc = La;/** // * use the La header node as the LC header node */
While (PA & Pb)
If (Pa-> data <= Pb-> data)
...{
PC-> next = PA;
PC = PA;
Pa = pa-> next;
}
Else
...{
PC-> next = Pb;
PC = Pb;
PB = Pb-> next;
}
PC-> next = pa? PA: Pb;/** // * Insert the remaining segments */
Free (* lb);/** // * release the LB header node */
Lb = NULL;
}

 

I did not answer the last Microsoft Phone interview... Whow
Note: When linklist la, linklist * LB, linklist * LC is added with *, it indicates that changes will occur later.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.