Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Clojure Data Structures and Algorithms Cookbook

You're reading from   Clojure Data Structures and Algorithms Cookbook 25 recipes to deeply understand and implement advanced algorithms in Clojure

Arrow left icon
Product type Paperback
Published in Aug 2015
Publisher
ISBN-13 9781785281457
Length 216 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Rafik Naccache Rafik Naccache
Author Profile Icon Rafik Naccache
Rafik Naccache
Arrow right icon
View More author details
Toc

Table of Contents (9) Chapters Close

Preface 1. Revisiting Arrays FREE CHAPTER 2. Alternative Linked Lists 3. Walking Down Forests of Data 4. Making Decisions with the Help of Science 5. Programming with Logic 6. Sharing by Communicating 7. Transformations as First-class Citizens Index

Implementing a skew binary random access list

Linked lists are traversed sequentially. To access an element, we need to begin at the top of the list and keep looking for references to the next cell and accessing it until we reach the item of our interest. In big O notation speak, access to an element in plain linked lists is a worst-case O(N) operation, which is quite expensive.

If we want to implement efficient random access to the data that a linked list contains, that is, if we want to specify an index and get to it efficiently—just as in an array, we can consider arranging the same data in a binary search tree, providing for efficient lookup and insertion operations.

If you represent the subscripts of your nodes in a binary format, you'd have nodes connected to the subtrees that contain the elements that are next to them. Using such subscripts, you could navigate from a parent node to one of its children by simply adding a bit to its subscript at the least weight position...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image