D
D
Denis Bredun2020-07-03 00:08:50
Algorithms
Denis Bredun, 2020-07-03 00:08:50

What is the meaning and purpose of an ordinary binary tree? What is the error in measuring program time using Stopwatch'er?

Good afternoon, Khabrachan! I need your help in understanding some aspects. Here are the questions that I had while studying Stopwatch and binary trees:
1. What is the "error" of Stopwatch'er when measuring the execution time, for example, of some piece of code? After all, there are checks in Stopwatch'er.
2. I know what a binary search tree is, what it is for, when it is used, etc... But... what are ordinary binary trees for? What are their rules for adding a new element, if in a binary search tree, if this element is less than the element with which it is compared, then it goes to the left, and if more, then to the right?
3. Habrachans, can you please come up with questions for me to self-test on binary trees (both search and ordinary)? And then I have the feeling that I didn’t understand something or don’t know, although, it seems, when I was sorting out the binary search tree, I understood everything well. Emphasis in self-examination, I would like to theory. Or, as an option, tell me where I can test my theoretical knowledge of binary trees, please.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis Zagaevsky, 2020-07-03
@Luffy1

Binary trees are usually search trees. Just binary trees, in my opinion, are not used. The only thing that comes to mind is hash tree(Merkle tree) in cryptography. In general, the rules will be what you set in the implementation.
Questions, well, for example, what is the height of a tree? (Hereinafter, consider BST as a tree). What is the asymptotic behavior of basic tree operations? How to improve them? What is a balanced tree? What implementations of balanced search trees do you know? Which of them are used in the standard library of your main language?
You can come up with a bunch of questions about traversal: how to traverse a tree in layers (in width)? In depth? How to check if a binary tree is a search tree?
Well, then you can ask, what non-binary trees do you know?

W
Wataru, 2020-07-03
@wataru

Just a binary tree for the sake of a binary tree is not particularly used anywhere. It's just a form of data organization. You can add them linearly into a list or an array, you can organize them in the form of a tree. But on it you can do different cool things by hanging something from above. Usually it turns out to do all sorts of useful things with logarithmic complexity - because the tree, if it is well organized, has a logarithmic height.
You can keep it sorted and balanced - that's the standard search trees running in log n. You can support the heap property (ancestors are greater than children), and you get a heap on which you can do a priority queue. You can fix the height of the tree and put data only in sheets, and count the sum of children at intermediate vertices - this is how a segment tree is obtained, which allows you to calculate the sum or maximum on any segment in the array as a logarithm, change elements, add a value to all elements on the segment, and much more. something else.
I don’t know anything about stopwatch, what it even is.
And questions on binary trees - they are uninteresting and trivial (how many children? The minimum possible height of the tree? How many intermediate vertices for a given number of children and height?)
Questions should be asked about a specific data structure - what operations can be performed on it and how long they take. How much memory is needed for storage.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question