PGoCareerGoCareer prep tools
LoginSign up
  • Java
  • Python
  • AI
  • React
  • Angular
  • PHP
  • Node.js
  • SQL
  • DSA
  • HTML
  • CSS
  • JS
  • Spring
  • ML
  • MongoDB

DSA · Theory

Design a data structure that supports insert, delete, search and getRandom in constant time

← All stacks

Theory

534/810

Design a data structure that supports insert, delete, search and getRandom in constant time

Design a data structure that supports insert, delete, search and getRandom in constant time is a DSA topic. In plain words you use it for find roll 12 in a sorted list. Don’t start with a slogan — start with that picture.

Smallest example: linear vs binary. Type it, run it, and say what you see. If you can do that from memory, you know Design a data structure that supports insert, delete, search and getRandom in constant time.

From the example next to this theory: Design a data structure that supports insert, delete, search and getRandom in constant time: dry-run [4, 1, 3].

Trap — binary search on unsorted data. Fix that before you talk about advanced DSA.

Viva: what is Design a data structure that supports insert, delete, search and getRandom in constant time? Then show linear vs binary. Then name the trap.

Exam tip

What is Design a data structure that supports insert, delete, search and getRandom in constant time? Show this: linear vs binary. Trap: binary search on unsorted data.

Example

# Design a data structure that supports insert, delete, search and getRandom in constant time
data = [4, 1, 3]
print("start", data)
if data[0] > data[1]:
    data[0], data[1] = data[1], data[0]
print("after one step", data)

Design a data structure that supports insert, delete, search and getRandom in constant time: dry-run [4, 1, 3]. Say the list after one step.

Short notes

  • DefDesign a data structure that supports insert, delete, search and getRandom in constant time — find roll 12 in a sorted list.
  • Rulelinear vs binary
  • Trapbinary search on unsorted data
  • Usea sorted list

Questions

1

What is Design a data structure that supports insert, delete, search and getRandom in constant time?

2

Give one small example of Design a data structure that supports insert, delete, search and getRandom in constant time.

3

What mistake do beginners make with Design a data structure that supports insert, delete, search and getRandom in constant time?

4

Where do you use Design a data structure that supports insert, delete, search and getRandom in constant time?

534 / 810

P

GoCareerGo

Utilities · Preparation Hub · Resume · CV · Tools — one workspace.

Workspace

DashboardProfilePreparation HubResume builderCV builderCareer planning

PDF Tools

Merge PDFSplit PDFCompress PDFImage to PDFAll toolsJobs

Image & QR

Compress ImageResize ImageQR ScannerQR GeneratorBlogIT interview prep

Company

FAQFeedbackContactPrivacyTermsSitemap

© 2026 GoCareerGo. Keep moving forward.