{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Assignment 7 (DS)

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

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

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.

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

View Full Document
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 doesn’t 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

{[ snackBarMessage ]}