由买买提看人间百态

topics

全部话题 - 话题: ptmp
(共0页)
w****x
发帖数: 2483
1
来自主题: JobHunting版 - 做了一下merge BST
//Merge two BST
//O(n) solution
//1. Change BST into linked list
//2. Merge 2 linked lists
//3. Change linked list into a balanced BST
struct NODE
{
int nVal;
NODE* pLft;
NODE* pRgt;
NODE(int n) : nVal(n), pLft(NULL), pRgt(NULL) {}
};
////////////////////change BST to linked list///////////////////////////////
void _inner_chng_link(NODE* pNode, NODE*& ph, NODE*& pt)
{
if (NULL == pNode) return;
NODE* pLft1 = pNode;
NODE* pLft2 = pNode;
_inner_chng_link(pNode->pLft... 阅读全帖
w****x
发帖数: 2483
2
来自主题: JobHunting版 - 攒人品,Twitter 电面题目

写一个
//Merge two BST
//O(n) solution
//1. Change BST into linked list
//2. Merge 2 linked lists
//3. Change linked list into a balanced BST
struct NODE
{
int nVal;
NODE* pLft;
NODE* pRgt;
NODE(int n) : nVal(n), pLft(NULL), pRgt(NULL) {}
};
////////////////////change BST to linked list///////////////////////////////
void _inner_chng_link(NODE* pNode, NODE*& ph, NODE*& pt)
{
if (NULL == pNode) return;
NODE* pLft1 = pNode;
NODE* pLft2 = pNode;
_inner_chng_link(pNode-... 阅读全帖
w****x
发帖数: 2483
3
来自主题: JobHunting版 - ms面试题目
NODE* SwapNodes(NODE* pHead)
{
assert(NULL != pHead);
if (pHead->pNext == NULL)
return pHead;
NODE* pRet = pHead->pNext;
NODE* pIter = pHead;
NODE* pPrev = NULL;
while (pIter != NULL && pIter->pNext != NULL)
{
if (NULL != pPrev)
pPrev->pNext = pIter->pNext;
NODE* pTmp = pIter->pNext->pNext;
pIter->pNext->pNext = pIter;
pIter->pNext = pTmp;
pPrev = pIter;
pIter = pIter->pNext;
}
return pRet;
}
w****x
发帖数: 2483
4
来自主题: JobHunting版 - 问个reverse linked list

以后面试因该严格静止用脚本语言面试,太坯了
NODE* Reverse(NODE* pHead, int nStart, int n)
{
if (NULL == pHead || nStart < 1 || n < 1)
return pHead;
NODE* pX = NULL;
NODE* pIter = pHead;
for (int i = 1; i < nStart && pIter != NULL; i++)
{
pX = pIter;
pIter = pIter->pNext;
}
if (pIter == NULL) return pHead;
NODE* pEnd = pIter;
NODE* pPrev = NULL;
for (int i = 0; i < n && pIter != NULL; i++)
{
NODE* pTmp = pIter->pNext;
pIter->pNext = p... 阅读全帖
s*********e
发帖数: 17
5
来自主题: Programming版 - how to reverse a HUGE list?
How can you print singly linked list in reverse order? (it's a huge list and
you cant use recursion) ?
大家有没有更好的方法 print “HUGE” list in reverse order? 谢谢!
BOOL ReverseList(node** pphead)
{
if(*pphead == NULL)
return FALSE;
node* pNode = NULL;
node* pTmp;

while(*pphead != NULL)
{
// tmp storage of header pointer
pTmp = (*pphead)->pNext;

// reverse
(*pphead)->pNext = pNode;

// pNode pointer moves one
g****t
发帖数: 39
6
Thank you for your reply. For my Linux box, the physical memory is > 600M, the
swap is > 1 G.
I also did a simple test on IBM SP2 node, which has > 60 G memory. However, my
program stops after allocating about 250M memory.
Anything wrong? My program is a super simple one, with "new" in a loop. the
skeleton is as follows:
1. int *pArray[10000];
2. for(i; loop for 10000 or no more memory) pTmp = new int[1mega]; pArray[i] =
pTmp;
My motivation is to find out the upper bound of supportable memory us
d****y
发帖数: 472
7
Our company, Purewave Networks at Mountain View, CA
http://www.purewavenetworks.com/
has the following openings. If you are interested in the opportunities,
please feel free to contact me and I would like to recommend to our VP
Engineering.
Regards,
Allen Liu
Email: a**[email protected]
Sr. Software Engineer - Networking and Application
JOB DESCRIPTION:
The PureWave Networking Software Team is responsible for implementation of
our Element Management System and multi-protocol embedded agent for our
Wi... 阅读全帖
(共0页)