Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 of 2 CSc 2720 - Data Structures: Lab 6 1. 2. Import the java project BinaryTrees to your IDE(Eclipse) and create a new class

image text in transcribed
image text in transcribed
1 of 2 CSc 2720 - Data Structures: Lab 6 1. 2. Import the java project BinaryTrees to your IDE(Eclipse) and create a new class called TreeTraversal.java Create the binary tree tree2 (treel already exists in the template). treel tree2 Write a function called checkSkipped that takes a tree as an argument traverses it in an Inorder traversal and prints out the traversed nodes. The function should return true if there is a skipped alpha character in the sequence and false if the tree contains a perfect sequence of alphabets. For example: Input: tree1 Output: False Explanation: The inorder traversal is ABCDEFGHI and there is no skiped character Input: tree2 Output: True Explanation: The inorder traversal is BDEFGHXY and there are many skiped characters Between B and D there is no c and there are many missing characters between H and x. Class Template public class TreeTraversal treate a tree called teeneBinarH): public static void main(String[] args)( /I Create a tree called treel BinaryTreecCharacter> treel new BinaryTree("H BinaryTreeCharacter rightsubt reel rightsubtree1.attachRight (Y) BinaryTree leftsubtreel-new BinaryTreeD leftsubtree1.attachLeft(B) BinaryTree Character leftsubtree2 leftsubtree2.attachRight('G'); leftsubtree2.attachLeft(E new BinaryTree("F-1; leftsubtree1.attachRightSubtree(leftsubtree2); treel.attachLeftSubtree(leftsubtree1) treel.attachRightSubtree (rightsubtree1): BinaryTreecCharacter> tree2 new BinaryTree("F" BUILD tree2 HERE System.out.println(checkSkipped(tree1)) II Should return false System.out.println(checkSkipped(tree2)) II Should return true public static boolean checkSkipped (BinaryTree tree) II To Iterate a tree using Inorder Traversal Treelterator iter new TreeIteratorcCharacter>(tree); iter.setInorder): while (iter.hasNextO)( System.out.print (iter.next()); I INSERT CODE HERE return false

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Oracle Database Architecture

Authors: Thomas Kyte, Darl Kuhn

3rd Edition

1430262990, 9781430262992

More Books

Students also viewed these Databases questions

Question

What is the budget for this project?

Answered: 1 week ago