Assignment 7 (DS)

Assignment 7 (DS) - Chapter 12 2. Draw the adjacency list...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 270 Chapter 11 14. Suppose that you are given two sequences of elements corresponding to the inorder sequence and the preorder sequence. Prove that it is possible to reconstruct a unique binary tree. Assume the nodes in your tree have a field that identify themselves as a leaf, you can make a unique tree out of a postorder listing for this kind of trees: 1. Start from the beginning of the postorder list and find the first internal node. This node will have exactly two leaf children which precede this node in postorder listing. 2. In your tree structure add that internal node and make two preceding nodes in the listing its children. 3. Remove those two children from listing and make that internal node a leaf. 4. Go to step 1 and repeat until listing becomes empty.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Chapter 12 2. Draw the adjacency list of the graph. Answer: [0 ] 1 2 3 [1 ] 4 [2 ] 1 4 [3 ] [4 ] [5 ] 1 3 6. Consider the graph. Find the shortest distance from node 0 to every other node in graph. Answer: 1 w = 3 4 w = 10 2 w = 8 5 w = 15 3 w = 4 8. Find the spanning tree in graph. Answer : CS 270 11. Describe whether the graph has Euler circuit. If it does, find the circuit? Answer : The graph doesnt have Euler circuit because it has vertices with odd degrees. (vertex 2) Chapter 13 10. Suppose that the intList is a vector container and: intList = {2,4,6,8,10,12,14,16} What is the value of the result after this statement executes? Answer : 72...
View Full Document

This note was uploaded on 01/19/2011 for the course CS 270 taught by Professor None during the Spring '10 term at Grantham.

Page1 / 3

Assignment 7 (DS) - Chapter 12 2. Draw the adjacency list...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online