Interview highlights-linked list, interview highlights --

Source: Internet
Author: User

Interview highlights-linked list, interview highlights --

I have been busy looking for a job some time ago. I also encountered a lot of algorithm questions during the interview. Most of these questions are about Binary Trees and linked lists. Here, I posted the linked list interview questions I wrote some time ago. Of course, because there are many questions, I just posted its class structure here, instead of the implementation code, if you need a friend, you can download it here (without points ):

Http://download.csdn.net/detail/dlutbrucezhang/8062413

If you cannot download it for other reasons, leave your email address and I will send you a copy.

Okay, the following shows the linked list algorithm class:

Template <typename T> class dutNode {public: T data; dutNode <T> * next; dutNode (): data (T (), next (NULL) {} dutNode (const T & _ data): data (_ data) {} dutNode (const T & _ data, dutNode <T> * _ next ): data (_ data), next (_ next) {}}; template <typename T> class dutLinkList {private: int count; dutNode <T> * pHead; protected: /* Package function */dutNode <T> * dutRecursionReverseList (dutNode <T> *); voiddutReversePrintList (dutNode <T> *); voiddutQ UickSortByPointer (dutNode <T> * &, dutNode <T> * &); dutNode <T> * dutReverseOddAndEven (dutNode <T> *); dutNode <T> * dutRecursionMergeSortedList (dutNode <T> *, dutNode <T> *); dutNode <T> * worker (dutNode <T> *, dutNode <T> *); dutNode <T> * dutFindBackwardsK (dutNode <T> *, int); dutNode <T> * dutFindMiddleElement (dutNode <T> *); booldutHasCircle (dutLinkList <T> &, dutNode <T> * &); voiddutSwapData (T &, T &); publ Ic: dutLinkList ();~ DutLinkList ();/* normal operation */voiddutPrintList () const; booldutIsEmpty () const; intdutGetCount () const; intdutAddToListByArray (const T *, int ); intdutAddToHead (const T &); intdutAddToTail (const T &); compute (dutNode <T> *); intdutAddNodeAfterData (dutNode <T> *, t); voiddutRemoveFirst (); Forward (); voiddutRemoveAll (); voiddutRemoveData (const T &);/* algotithm */booldutFindNodeByData (const T &) const; /* Whether the given value exists in the linked list */voiddutNotRecursionReverseList ();/* Non-recursive flip single-chain table */voiddutRecursionReverseList ();/* recursive flip single-chain table */voiddutre (); /* print the single-chain table in reverse order */voiddutSelectSortByData ();/* sort the single-chain table by switching data */voiddutInsertSortByPointer (); /* insert and sort a single-chain table by switching pointers */voiddutQuickSortByPointer ();/* perform fast sorting on the single-chain table by switching pointers */voiddutMergeList (dutLinkList <T> &); /* merge Single-Chain tables */voiddutNotRecursionMergeSortedList (dutLinkList <T> &);/* Non-recursive merge ordered single-chain table */voiddutRecursionMergeSortedList (dutLinkList <T> &); /* recursively merge ordered Single-Chain tables */voiddutReverseOddAndEven ();/* flip the odd number and even number nodes in the linked list */voiddutSplitListMakeOddSeqBeforeEvenSeq (); /* split the single linked list so that the odd number is before the even number */voiddutSplitListMakeOddDataBeforeEvenData ();/* split the single linked list so that the odd number is before the even number */voiddutFindBackwardsK (int ); /* output the last K nodes */voiddutFindMiddleElement ();/* output intermediate node */booldutHasCircle (); /* existence of loops in the linked list */booldutListIntersect (dutLinkList <T> &);/* intersection of linked lists */booldutListHasCircleAndIntersect (dutLinkList <T> &); /* whether or not the linked list has a ring and intersection */voiddutFindLoopPort ();/* the entry of the output linked list ring */voiddutFindTheFirstIntersectNode (dutLinkList <T> &); /* output the first intersection node of the intersection linked list */};



Summary of digital test questions in Wuhan

1: The written examination is the position you choose. I am the direction of software development and maintenance (C ++. My written examination questions mainly explain some terms, for example: (GIS Geographic Information System, there are some differences in variable types, static, const, differences between arrays and linked lists, and some protocols such as TCP/IP, write an endless loop, there are write a single-chain table to reverse, how to set a single digit in the embedded system without affecting other digits .) These are the main points of the written examination.
2: During the interview, I mainly asked you what you learned, for example, you can ask why you choose their company, what are your most proud tasks, your views on overtime, some view differences of compilers, and UML. During the interview, be sure to prepare your own things. Do not exaggerate them. It's easy to say anything. This is some information about campus recruitment that I attended a while ago. I hope this will help you.

C program data structure Linear Linked List sorting sort (interview questions fill blank questions) made a part of their own, will not do the previous do not know whether or not

Struct node * create (int a [], int n)
{
Struct node * h, * q;
For (h = NULL; n --)
{
Q = (struct node *) malloc (sizeof (struct node ));
Q-> value = ________________________; // It should be n-1. You can see that the main function uses the array size instead of the upper limit of the array subscript.
________________________________; // It should be q-> next = h. Add the Node Method to the header to ensure that the end of the table is NULL.
________________________________; // H = q;
}
Return h;
}

While (q-next! = NULL)
{
If (q-> next-> value <______________) // It should be r-> next-> value, because r is a temporary variable, which is equivalent to tmp in array sorting, here, r is used to save the minimum number of header nodes. The function of this loop is to find the smallest node r-> next in the remaining linked list.
R = q;
Q = q-> next; // traverse nodes backward
}
If (r! = P) // If r! = P indicates r = p-> nex
{
S = _________________________; // s = r-> next; Save the minimum node to s
________________________ = S-> next; // r-> next = s-> next; the minimum node is separated from the remaining linked list.
S-> next = ____________________; // s-> next = p-> next; Connect the minimum node to p-> next
______________________________ = S; // p-> next = s;
}
 

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.