Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 _00 01 02 .03 04 _05

image text in transcribedimage text in transcribed

82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 _00 01 02 .03 04 _05 _06 .07 _08 char * btree_find_breadthFirst(btree root,int val, char *buf) { /* --- TODO: Search the tree specified by "root" to find the first node that has a payload of "val", and return the string path from the root to that node, where an "L" in the path specifies take the left branch, and "R" specifies take the right branch, and a "*" says look here. The search should occur by first checking the payload at the root node, then checking all nodes that are one step away from the root, then all nodes that are two steps away, and so on. The "buf" parameter provides a pointer to memory where the path can be stored. You may assume buf starts out with a 0x00 null string terminator at position 0. If "val" is not a payload of any node in the tree, a NULL pointer should be returned. RECOMMENDED ALGORITHM - find at depth - - - Create an integer "found" variable that can have three values: 1=>the value has been found; 0=>still looking; -1=>Not in the tree at all. Initialize to loop through depth, starting at 0, as long as found is 0 - Check to see if the variable is found at this depth If found is -1, return NULL. - Return the result of finding at depth .09 10 11 In order to check for a value at a specific depth. I created

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_2

Step: 3

blur-text-image_3

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

Big Data Concepts, Theories, And Applications

Authors: Shui Yu, Song Guo

1st Edition

3319277634, 9783319277639

More Books

Students also viewed these Databases questions