This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Fall 2011 CMSC 420 Samet ASSIGNMENT NUMBER 1 1. In the lecture we showed how two stacks can be made to share one segment of memory when using sequential allocation. Can you do the same for two queues, or a queue and a stack? If not, explain why. 2. Give all the possible ways of topologically sorting the set of relations A<B , F<B , D<B , G<F , G<E , E<D , F<D , E<C , D<C , B<C . 3. The algorithm we described in class for implementing the topological sort makes use of a queue to keep track of the nodes whose PRED COUNT field has become zero and hence are ready to be output. Recall that these are the nodes whose direct successors have not yet been output. Can you use a stack instead of a queue? Give such an algorithm using pseudocode. 4. Suppose that ptr1 and ptr2 point to the last elements of disjoint circular lists l 1 and l 2 , respectively. The lists l 1 and l 2 are interpreted as having their elements to the left of ptr1 and ptr2 , respectively. In other words, NEXT(ptr1) and NEXT(ptr2)...
View Full Document
- Fall '08