GamifiedGamified challengesPracticeRaceLeaderboardPricing

Learn data structures by watching them move, then doing it yourself. Press M anytime to toggle sound.

A product of Amypo Technologies, Coimbatore.

Learn

  • All topics
  • Learning path
  • How it works
  • About dotprep

Practice

  • Practice arena
  • Daily challenge
  • Gamified challenges
  • Race mode
  • Leaderboard

Interview prep

  • Java interview
  • Coding questions
  • Company questions
  • System design
  • Jobs & careers

You

  • Dashboard
  • Settings
  • Pricing
  • Create account

© 2026 dotprep

Content last updated 20 November 2026

GamifiedGamified challengesPracticeRaceLeaderboardPricing
Log inStart free
Gamified challengesLibrary Shelf

Gamified challenge · BST insertion

Library Shelf

Books arrive in the order of books (all numbers are different) and are shelved into an empty binary search tree: the first book is the top; each later book starts at the top and goes left if its number is smaller, right if bigger, until it finds an empty spot.

Then a reader asks for book find. The librarian starts at the top and walks down the same way. Write shelve(books, find) that returns the trail: the numbers of the books checked, in order. It ends at find if the book is there, or at the last book checked before running out of shelf.

For books = [50, 30, 70, 20, 40, 60, 80] and find = 60 the trail is [50, 70, 60]; for find = 65 it's [50, 70, 60] too (65 would go right of 60, but nothing is there). An empty shelf gives [].

Sign in to play Library Shelf

This game is part of the paid plans. Sign in, then pick a plan to write your answer, watch it play out, and step through the algorithm with its guide.

Sign in with Google

or log in with email · create an account