Feminism IR K GDI2010
5 stars based on
Label these transformations by whether they represent case 1, 2 or 3. If we insert a set of items into a binary search tree, the resulting tree may be horribly unbalanced, leading to long search times.
As we saw in class and in Section Therefore, one strategy that, on average, builds a balanced tree for a fixed set of items would be to randomly permute the items and then insert them in that order into the tree. What if we do not have all the items at once? If we receive the items one at a time, can we still randomly build a binary search tree out of them? We will examine a data structure that answers this question in the affirmative.
A treap is a binary search tree with a modified way of ordering the nodes. Leftrotate binary trading binary trading rubric is an example of a treap. As usual, each item x in the tree has a key, key[x]. In addition, we assign priority[x], which is a random number chosen independently for each x. We assume that all priorities are distinct and also that all keys are distinct.
The nodes of the treap are ordered so that 1 the keys obey the binary-search-tree property and 2 the priorities obey the min-heap order property. It helps to think leftrotate binary trading binary trading rubric treaps in the following way. Suppose that we insert nodeseach with an associated key, into a treap in arbitrary order.
Then the resulting treap leftrotate binary trading binary trading rubric the tree that would have been formed if the nodes had been inserted into a normal binary search tree in the order given by their randomly chosen priorities.
Let us see how to insert a leftrotate binary trading binary trading rubric node x into an existing treap. The first thing we do is assign x a random priority priority[x]. Leftrotate binary trading binary trading rubric the idea in English and give pseudocode. Execute the usual binary search tree insert and then perform rotations to restore the min-heap order property. All solutions must be written by yourself.
Plagiarized work will not receive any credit. Repeated occurrences will result in a report to the department. You have the option of handwriting your solutions on paper, scanning them, and converting them to PDF. Please do not send the images. If you use a phone or tablet to scan your handwritten solutions, here are some tips on how to this well. You also have the option of typing your solutions up in your favorite word processor. Export or print your document as a PDF file and submit that.
Please do not a submit. Finally, you have the option of preparing a professional-looking document using LaTeX. This is what authors use to write textbooks and research papers. If you choose this option, here are some pointers to get you started.