Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

DATA STRUCTURES Question 3 (10 marks) a) The INORDER traversal output of a binary tree is S,T,R,A,W,B,E,R,R,Y and the PREORDER traversal output of the same

image text in transcribed

DATA STRUCTURES

Question 3 (10 marks) a) The INORDER traversal output of a binary tree is S,T,R,A,W,B,E,R,R,Y and the PREORDER traversal output of the same tree is S,W,T,A,R,R,E,B,Y,R. Construct the tree and determine the output of the POSTORDER traversal output. (2.0 marks) b) One main difference between a binary search tree (BST) and an AVL (Adelson-Velski and Landis) tree is that an AVL tree has a balance condition, that is, for every node in the AVL tree, the height of the left and right subtrees differ by at most 1. Starting with an empty BST and AVL tree, insert the following keys into the two trees (BST as well as AVL trees): 19,62,23,57,18,12,36,82,11,74 If a key is already existed, insert the new key to the right sub-tree. (4.0 marks) c) Based on what you have done for Question 3b, what is the big-O (worst case) complexity of the total time required to build a binary search tree (BST) consisting of n nodes? Explain your answer. Answer without explanation gains no mark. (Hint. A tricky question. The question asks for worst case complexity. Think properly.) (2.0 marks) d) Similarly, from what you have done for Question 3c, what is the big-o (worst case) complexity of the total time required to build an AVL tree consisting of n nodes? Explain your answer. Answer without explanation gains no mark. (Hint. The question asks for worst case complexity.) (2.0 marks)

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

Hands-On Database

Authors: Steve Conger

2nd Edition

0133024415, 978-0133024418

More Books

Students also viewed these Databases questions

Question

Brief the importance of span of control and its concepts.

Answered: 1 week ago

Question

What is meant by decentralisation?

Answered: 1 week ago

Question

Write down the Limitation of Beer - Lamberts law?

Answered: 1 week ago