2

[EDITED!!!] Having read about different data structures and created many of them (in C++) I just wondering how could we make a data structure where each node would be a pair of keys (x,y), where x would refer to a value of a Max Heap and y to a key of a Binary Search Tree. I would like something like a BST and Max Heap at the same time (using tuples or pairs of keys as nodes each time). To make it more clear, technically I mean that in each node i of the tree a pair of keys (x,y) will be stored where x is the priority of the key and y will be the the value of the key.

It will be able to support all the functionalities of the above mentioned data structures, such as the insertion and deletion. For example, regarding deletion the tuple is going to go consecutively deeper by a sequence of simple consecutive rotations, until the tuple be a leaf. Then the deletion is easy as far as you know. If the tuple – the one we would like to delete - would be a leaf or an inner node, the deletion could be done in the same way as in BSTs.

Regarding insertion a tuple will be inserted into the tree only based on the key of the binary search tree. After that, the pair is going to be moved consecutively higher in the tree until the fundamental property of max heaps be violated.

Moreover, I have some extra functionalities into my mind. An additional function could be something like find_second_next(), taking as argument the x key, which is already on the tree, and this function will find the second smaller among all the y keys of the tree which are greater than x. Another function could be a print_between(k1,k2) as well. This function will print all y keys of the tree having value in the range [k1,k2]. Finally, I would like to have also a print_with_higher_priority(x) function which will print all the x keys of the tree which are greater than x.

If you have some additional functionalities write them! :D

I am looking forward to seeing your contribution to this question!

  • Will you please define the functionality of the desired data structure in more detail? – Leon Jul 05 '16 at 21:20
  • @Leon I just edited my question... – Taksiarxis Mitropoulos Jul 05 '16 at 21:58
  • Thanks for the effort, but I still can't understand how you intend to combine the functionality of BST with Max Heap for your `(x, y)` pairs. Do you mean that `y` must serve as a key for BST operations, and you also want to be able to quickly retrieve the node with the largest `x`? – Leon Jul 05 '16 at 22:10
  • @Leon Forgive me for being naive..I thought you were saying something different from that I got. However, I edited my question (again ! :) ) explaining about the tuple and the essence of x,y keys into my problem. I edit my question every time I find something is not as much clear as needed to be visible to all those who are thinking about this problem. That's why I am not directly answering to you through a comment. Thank you for your comments whatsoever! – Taksiarxis Mitropoulos Jul 06 '16 at 06:46
  • Nobody is interested in my question(again!) , isn't he/she? – Taksiarxis Mitropoulos Jul 07 '16 at 17:54
  • I guess that's because your question is still not clear enough. After my initial request for clarification you provided too much low-level detail. Try to simplify the question, by focusing on the most essential part of the functionality that you need from this data structure. Do not dive into implementation. – Leon Jul 07 '16 at 19:00

0 Answers0