74.5k views
2 votes
Assume you have an XML Tree variable called quiz initialized with the following valid XML document. You are not required to draw the tree, but you might find it helpful. <?xml version="1.0" encoding="UTF-8"?> 155 What is the size of this tree? What would be the value returned by quiz. child(0).child(1).child(0).label() What would be the value returned by quiz. child(1).attributeValue("number")

1 Answer

6 votes

Answer:

See explaination.

Step-by-step explanation:

question is the root element which have two children one is M-C and other is Coding.

Again M-C have two sub children Points and parts

Note: The tree will be as shown in the attachment. kindly refer to attachment.

Here if we see the child of quiz(questions) at 0 position is number of type M-C and another child at location 1 is number of type Coding.

Now quiz.child(0) is number of type M-C which has two child and child at 0 is Points and child at 1 is Parts

quiz.child(0).child(1) is Points and now further points doesn't have any children hence going further to quiz.child(0).child(1).child(0) is nothing hence it will not return anything.

Next quiz.child(1) is number of type coding and value is 5.

Size of the tree is (2^depth)-1

and here depth of tree is 3 hence size is (2^3)-1 i.e. 7

Assume you have an XML Tree variable called quiz initialized with the following valid-example-1
User Bola
by
7.1k points