Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please answer this question as fast as possible I will make sure to give thumbs up Each of the following examples gives a design in

please answer this question as fast as possible I will make sure to give thumbs up
image text in transcribed
image text in transcribed
Each of the following examples gives a design in a language of a data structure for binary trees and a function for counting the nodes in a binary tree: - Julia mutable struct BNode data::Int left::UnionfNothing, BNode right::Unionf(Nothing, BNode } end BTree = Unionf(Nothing, BNode } function count(r::BTree) if r= nothing return 0 else end - Haskell data BTree a =Nil I Branch a (BTree a) (BTree a) count Nil=0 count (Branch - left right) = (count left) + (count right) +1 Picat count (nil)=0 count ({, Left, Right })=count (Lef t)+count( Right )+1 Write each of the following functions on binary trees in one of these languages. 1. min_max (tree): This function returns a pair (min, max), where min is the minimum value, and max is the maximum value in tree. Note that the tree may not be a binary search tree. 2. inc1 (tree): This function returns a copy of tree, in which each node value is incre mented by 1. Each of the following examples gives a design in a language of a data structure for binary trees and a function for counting the nodes in a binary tree: - Julia mutable struct BNode data::Int left::UnionfNothing, BNode right::Unionf(Nothing, BNode } end BTree = Unionf(Nothing, BNode } function count(r::BTree) if r= nothing return 0 else end - Haskell data BTree a =Nil I Branch a (BTree a) (BTree a) count Nil=0 count (Branch - left right) = (count left) + (count right) +1 Picat count (nil)=0 count ({, Left, Right })=count (Lef t)+count( Right )+1 Write each of the following functions on binary trees in one of these languages. 1. min_max (tree): This function returns a pair (min, max), where min is the minimum value, and max is the maximum value in tree. Note that the tree may not be a binary search tree. 2. inc1 (tree): This function returns a copy of tree, in which each node value is incre mented by 1

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

Database Systems For Advanced Applications Dasfaa 2023 International Workshops Bdms 2023 Bdqm 2023 Gdma 2023 Bundlers 2023 Tianjin China April 17 20 2023 Proceedings Lncs 13922

Authors: Amr El Abbadi ,Gillian Dobbie ,Zhiyong Feng ,Lu Chen ,Xiaohui Tao ,Yingxia Shao ,Hongzhi Yin

1st Edition

3031354141, 978-3031354144

More Books

Students also viewed these Databases questions

Question

Solve by completing the square: x 2 + 10x - 3 = 0.

Answered: 1 week ago

Question

4. Describe the factors that influence self-disclosure

Answered: 1 week ago

Question

1. Explain key aspects of interpersonal relationships

Answered: 1 week ago