(a) Give a recursive definition of the set of Rooted Trees.
(b) For a rooted tree T recursive definitions for v(T) and e(T) the number of vertices and edges of T respectively. (c) For a rooted tree T, use structural induction to prove that v(T) − e(T) = 1
a. Base elements :- A null element belongs to set of
rooted tree which is an empty tree.
Inductive definition :- If tree T1 and T2 belongs to set S of rooted tree then tree T created by adding vertex u as root and left subtree being T1 and right subtree being T2 , then T will also belongs to S.
b. If T is null then v(T) = 0 and e(T)=0 else e(T) = e(T1) + e(T2) and v(T) = v(T1) + v(T2) where T1 and T2 are left and right subtrees of T.
c. Base case:- When T contains single node. In this case v(T) = 1 and e(T) = 0, hence v(T) - e(T) = 1 satisfies for base case.
Induction hypothesis :- Let v(T) - e(T) = 1 satisfies for every tree T with v(T) = n and hence e(T) = n-1
Inductive step:- Consider tree T with both left subtree T1 and right subtree T2 has less than equal to n vertices.
Then v(T) = v(T1) + v(T2) + 1 and e(T) = e(T1) + e(T2) + 2
Since T1 and T2 satisfies induction hypothesis. So
V(T) - e(T) = v(T1) - e(T1) + 1 +v(T2) - e(T2) -2 = 1 + 1 +1 -2 = 1
Hence induction hypothesis satisfies for tree T with v(T) >= n. Hence the statement is correct.
Please comment for any clarification.
(a) Give a recursive definition of the set of Rooted Trees. (b) For a rooted tree...
Let Σ = {0, 1). (a) Give a recursive definition of Σ., the set of strings from the alphabet Σ. (b) Prove that for every n E N there are 2" strings of length n in '. (c) Give a recursive definition of I(s), the length of a string s E Σ For a bitstring s, let O(s) and I(s) be number of zeroes and ones, respectively, that occur in s. So for example if s = 01001, then 0(s)...
Refer to the definition of Full Binary Tree from the notes. For a Full Binary Tree T, we use n(T), h(T), i(T) and l(T) to refer to number of nodes, height, number of internal nodes (non-leaf nodes) and number of leaves respectively. Note that the height of a tree with single node is 1 (not zero). Using structural induction, prove the following: (a) For every Full Binary Tree T, n(T) greaterthanorequalto h(T). (b) For every Full Binary Tree T, i(T)...
Please answer question 2. Introduction to Trees
Thank you
1. Graphs (11 points) (1) (3 points) How many strongly connected components are in the three graphs below? List the vertices associated with each one. 00 (2) (4 points) For the graph G5: (a) (0.5 points) Specify the set of vertices V. (b) (0.5 points) Specify the set of edges E. (c) (1 point) Give the degree for each vertex. (d) (1 point) Give the adjacency matrix representation for this graph....
discrete math. Structural Induction: Please write and
explain clearly. Thank you.
Let S be the set of binary strings defined recursively as follows: Basis step: 0ES Recursive step: If r ES then 1rl E S and 0x0ES (I#x and y are binary strings then ry is the concatenation of and y. For instance, if 011 and y 101, then ry 011101.) (a) List the elements of S produced by te first 2 applications of the recursive definition. Find So, Si...
1. Suppose the address of vertex v in the ordered rooted tree T is 4.5.4.6. At what level is v? What is the address of the parent of v? What is the least number of siblings v can have? What is the smallest possible number of vertices in T? If v has two children, what are their addresses? 2. Suppose the address of vertex v in the ordered rooted tree T is 4.3.5.3.4. At what level is v? What is...
(a) Consider the alphabet Σ = {a, b, c}. Give a recursive definition for the set of strings over Σ that contain exactly one c. (b) Give a recursive definition for the set S = {x | x ∈ Z≥0 and b x 4 c is even}
Consider unlabeled, rooted binary trees. We can compress such trees: whenever there are pointers to subtrees T and T? with T=T? (interpreting = as structural equality), we store (w.l.o.g.) T and replace all pointers to T? with pointers to T. See uli's answer for an example. Give an algorithm that takes a tree in the above sense as input and computes the (minimal) number of nodes that remain after compression. The algorithm should run in time O(nlogn) (in the uniform...
COMP Discrete Structures: Please answer completely and
clearly.
(3).
(5).
x) (4 points) If k is a positive integer, a k-coloring of a graph G is an assignment of one of k possible colors to each of the vertices/edges of G so that adjacent vertices/edges have different colors. Draw pictures of each of the following (a) A 4-coloring of the edges of the Petersen graph. (b) A 3-coloring of the vertices of the Petersen graph. (e) A 2-coloring (d) A...
(10 points) Recall that the set of full binary trees is defined as follows: Basis: A single vertex with no edges is a full binary tree. The root is the only vertex in the tree. Recursive rule: If T1 and T2 are full binary trees, then a new tree T' can be constructed by first placing T1 to the left of T2, adding a new vertex v at the top and then adding an edge between v and the root...
2. Write a recursive algorithm which computes the number of nodes in a general tree. 3. Show a tree achieving the worst-case running time for algorithm depth. 4. Let T be a tree whose nodes store strings. Give an efficient algorithm that computes and prints, for every node v of T, the string stored at v and the height of the subtree rooted at v. Hin Consider 'decorating' the tree, and add a height field to each node (initialized to...