sandro1999's blog

By sandro1999, history, 4 years ago, In English

Since I saw contests of Quantum Computing, I interested in that and I really wonder what should I know to write code and solve problems in Q#. As I saw some resources on the internet, there were many prerequisites needed for understanding quantum computing. I want to know from the contestants participated in Microsoft Q# Coding Contest, is it really necessary to know quantum physics to solve quantum computing problems and if not what should I know to understand how to write code using quantum computing? Is there any tutorial which will help me?(I saw some resources like books posted on Codeforces but explanations there weren't so good)

Full text and comments »

  • Vote: I like it
  • +4
  • Vote: I do not like it

By sandro1999, history, 4 years ago, In English

How about to add "Like" button to problem submissions. Wouldn't it be great to see "Most Liked" submission in the list of submissions?

Full text and comments »

  • Vote: I like it
  • +128
  • Vote: I do not like it

By sandro1999, history, 4 years ago, In English

I was reading about Treap data structure on cp-algorithms. I looked at split function and I found out that new node's left child becomes the element with highest possible priority in the left sub-tree and smaller key, and right child becomes the element with highest possible priority in the right sub-tree and greater key. According to the code:

void split (pitem t, int key, pitem & l, pitem & r) {
    if (!t)
        l = r = NULL;
    else if (key < t->key)
        split (t->l, key, l, t->l),  r = t;
    else
        split (t->r, key, t->r, r),  l = t;
}

void insert (pitem & t, pitem it) {
    if (!t)
        t = it;
    else if (it->prior > t->prior)
        split (t, it->key, it->l, it->r),  t = it;
    else
        insert (it->key < t->key ? t->l : t->r, it);
}

We are going to the leaf node and going back again. For example if I have the tree shown below and I want insert new element I will do following operations:

Isn't it better to just return back after we find out left and right child for the new node, without going to the leaf?

Full text and comments »

  • Vote: I like it
  • +8
  • Vote: I do not like it