Order ID:89JHGSJE83839 | Style:APA/MLA/Harvard/Chicago | Pages:5-10 |
Instructions:
Study Questions for the JAVA tree Assignment
Question 1: Binary tree non-recursive in-order traversal
The obvious technique to traverse a tree without recursion is to use Stack. The following is a stack-based approach for traversing a binary tree. See this for the algorithm’s step-by-step execution.
1) Make a stack S that is empty.
2) Make the current node the root.
3) Set current = current->left until current is NULL, then push the current node to S.
4) If current is NULL but the stack isn’t empty,
a) Remove the item at the top of the stack.
Set current = popped item->right to print the popped item.
c) Continue to step 3.
5) We’re done if current is NULL and the stack is empty.
Consider the tree below as an example.
1
/
2 and 3
/
4/5
Step 1: Make an empty stack by typing S = NULL.
Step 2 makes current the root address: current -> 1.
Step 3: Until current is NULL, push the current node and set current = current->left.
1 -> current
Stack S -> 1 -> 1 -> 1 -> 1 -> 1 -> 1 -> 1
2 -> current
Stack S -> 2, 1 -> 2 -> 2 -> 2 -> 2 -> 2 -> 2 ->
presently -> 4
Stack S -> 4, 2, 1 -> push 4
NULL for current
Step 4 is triggered by the letter S.
a) Stack S -> 2, 1 a) Stack S -> 2 a) Stack S -> 2 a) Stack
b) write “4” on a piece of paper
c) set current = NULL /*right of 4 */, then proceed to step 3.
Step 3 has no effect because current is NULL.
Step 4 appears once more.
a) Stack S -> 1 in Pop 2
b) print the number “2”
c) current -> 5/*right of 2 */, then go to step 3
Step 3 adds 5 to the stack and renders the current value NULL.
S Stack -> 5 -> 1
NULL for current
Step 4 is triggered by the letter S.
a) Stack S -> 1 a) Pop 5 a) Pop 5 a) Pop 5 a) Pop 5 a
b) write “5” on a piece of paper
c) set current = NULL /*right of 5 */, then proceed to step 3.
Step 3 has no effect because current is NULL.
Step 4 appears once more.
a) Stack S -> NULL (Pop 1)
b) print the number “1”
c) current -> 3 /*top of the 5 */
Step 3 adds 3 to the stack and sets the current value to NULL.
S Stack -> 3
NULL for current
Step 4 is triggered by the letter S.
a) Stack S -> NULL (Pop 3)
b) print the number “3”
c) current = NULL /*3rd from right */
Because stack S is empty and current is NULL, traversal is complete.
Create a non-recursive application for traversing a binary tree in order.
Question 2: Binary tree traversal in level order (breadth first traversal)
The above tree is traversed in the following order: 1 2 3 4 5.
A FIFO queue can be used to implement a binary tree’s level order traversal.
Each node is visited first, and then its child nodes are placed in a FIFO queue.
Step 1: Make a new queue that is empty.
Step 2: Begin at the top and enqueue the root.
Step 3: If the queue isn’t empty, loop.
a) Print data by dequeuing a node from the front of the queue.
b) Add the node’s children to the queue (first the left, then the right).
Create a mechanism to implement binary tree level order traverse.
Notes: You can use the Binary Tree and Node classes defined in the book for both questions, or you can create your own Node and Binary Tree classes.
Requirements: Submit the two programs’ repl.it links.
It is important to note that you must submit two repl.it links. Copy and paste the two links into a.txt/.docx file before uploading it. You can also include the second link in the assignment submission as a remark.
RUBRIC |
||||||
Excellent Quality 95-100%
|
Introduction
45-41 points The background and significance of the problem and a clear statement of the research purpose is provided. The search history is mentioned. |
Literature Support 91-84 points The background and significance of the problem and a clear statement of the research purpose is provided. The search history is mentioned. |
Methodology 58-53 points Content is well-organized with headings for each slide and bulleted lists to group related material as needed. Use of font, color, graphics, effects, etc. to enhance readability and presentation content is excellent. Length requirements of 10 slides/pages or less is met. |
|||
Average Score 50-85% |
40-38 points More depth/detail for the background and significance is needed, or the research detail is not clear. No search history information is provided. |
83-76 points Review of relevant theoretical literature is evident, but there is little integration of studies into concepts related to problem. Review is partially focused and organized. Supporting and opposing research are included. Summary of information presented is included. Conclusion may not contain a biblical integration. |
52-49 points Content is somewhat organized, but no structure is apparent. The use of font, color, graphics, effects, etc. is occasionally detracting to the presentation content. Length requirements may not be met. |
|||
Poor Quality 0-45% |
37-1 points The background and/or significance are missing. No search history information is provided. |
75-1 points Review of relevant theoretical literature is evident, but there is no integration of studies into concepts related to problem. Review is partially focused and organized. Supporting and opposing research are not included in the summary of information presented. Conclusion does not contain a biblical integration. |
48-1 points There is no clear or logical organizational structure. No logical sequence is apparent. The use of font, color, graphics, effects etc. is often detracting to the presentation content. Length requirements may not be met |
|||
You Can Also Place the Order at www.collegepaper.us/orders/ordernow or www.crucialessay.com/orders/ordernow |
Study Questions for the JAVA tree Assignment