Short programming question Can use any language. Need TONIGHT !!
Attached below is an image of an HTML DOM. This is basically a simple hierarchy of HTML nodes where there are children nodes and sibling nodes (see annotations in the image).
The programming question is to write the body of the function 'countDescendents' shown below. The example is shown in Java, but you can supply the solution in your programming language of choice.
The Node class is defined as:
public class Node { public Node firstChild; public Node nextSibling;}
The function signature is:
public int countDescendents(Node node) {....}
For example, using the HTML DOM example below, if we passed in the <div id="header_nav"> as the node to countDescendents, the return value would be 9. (div, img, a, ul, li, a, li, a, form). For the starting node, node.firstChild would be the <div class="avatar"> node, and node.nextSibling would be <div class="inner">. If a node does not have a firstChild or nextSibling, it'll return null. You aren't required to include all the logic in the 'countDescendents' function and can create other helper functions as desired.
The countDescendents function should traverse the descendents of the node using only the firstChild and nextSibling attributes of Node.
.
11 years ago
20
Purchase the answer to view it

- short_program.docx
Purchase the answer to view it

- parsermain.zip
- Corporate Regulations: A Legal Study
- Poltical Science paper need it asap
- how much gain or loss is recognized on the sale of a machine when sandy acquired business machinery (which qualified...
- a lamp operates with a current of 0.625A and a potenetial energy difference of 120V. What is the current flowing...
- Subnetting Paper
- Stats Project
- APA-formatted paper using no mo
- Find the domain and range of 3,-6
- TOP WRITER FOR 300-400 WORDS
- Raising Security Awareness- Phyllis Young