摘要: 3.1Describe how you could use a single array to implement three stacksfor stack 1, we will use [0, n/3)for stack 2, we will use [n/3, 2n/3)for stack 3, we will use [2n/3, n)const int stackSize = 300;int buffer = new int[stackSize * 3];int stackPointer[3] = {0,0,0}; //栈顶指针,指向下一可以放元素的位置bool isEmpty(in 阅读全文
posted @ 2013-08-19 20:04 冰点猎手 阅读(227) 评论(0) 推荐(0)
摘要: 2.1 Write code to remove duplicates from an unsorted linked list/* Link list node */struct node{ int data; struct node* next;};void rem_duplicate(node *head){ if(NULL == head) return ; set hash; set.insert(head->data); while(head->next){ if(hash.find(head->next->data) == has... 阅读全文
posted @ 2013-08-19 15:18 冰点猎手 阅读(294) 评论(0) 推荐(0)