You are not logged in. Please login at www.codechef.com to post your questions!

×

Doubt in treap

First of all, isn't treap a self-balancing tree? If so, why isn't there any rotation operations in it?

https://s3.amazonaws.com/codechef_shared/download/Solutions/LTIME25/Tester/CHEFDTRE.cpp

But in another implementations, I saw the use of rotation

http://www.sanfoundry.com/cpp-program-implement-treap/

Which one is better for competitive programming?

Also, I have a doubt in the following 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; }

Shouldn't the split be
split (t-> l, key, l, r-> l), r = t;
split (t-> r, key, l-> r, r), l = t;

Also, is the assignment (r=t and l=t) taking place before split or after it?

asked 23 Aug '15, 19:19

dragonemperor's gravatar image

3★dragonemperor
89321135
accept rate: 10%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×57

question asked: 23 Aug '15, 19:19

question was seen: 1,209 times

last updated: 23 Aug '15, 19:19