{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Data Str &amp; Algorithm HW Solutions 76

# Data Str &amp; Algorithm HW Solutions 76 - n nodes is 2...

This preview shows page 1. Sign up to view the full content.

12 Lists and Arrays Revisited 12.1 Here is the fi nal Skip List. head 2 5 20 25 26 30 31 +------> +--> +--> +--> +--> +--> +--> / +-----------> +-------> +--> / +-----------> +------------> / +--------------------------> / 12.2 For each even numbered node i , i can be written as j 2 k for the largest possi- ble integer k . For example, 8 is 1 2 3 and 12 is 3 2 2 . Each even numbered node j 2 k stores a pointer to ( j +1)2 k . This makes access time 2log n +1 in the worst case. Odd numbered nodes i can point to node i + 2 to speed the search somewhat. 12.3 The average number of pointers for a Skip List with
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: n nodes is 2 n (not count-ing the header). 12.4 template <class Key, class Elem, class KEComp, class EEComp> Elem SkipList::remove(Key K) { // Remove from Skip List SkipNode<Elem>* x = head; // Start at header node SkipNode<Elem>* update[level]; // Tracks level ends // Search for element prior to Value for(int i=level; i>=0; i--) { while((x->forward[i] != NULL) && (KEComp.gt(K, x->forward[i]->value))) x = x->forward[i]; 76...
View Full Document

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern