SystemTutor
About
Sign in
Loading course documentation…
SystemTutor

COURSES

  • Data Structures & Algorithms
  • CSS MasterclassNew course
  • System DesignNew course

PRACTICE

  • Algorithm practice
  • CSS practice

LEGAL

  • Privacy Policy
  • Terms of Service
  • About

© 2026 SystemTutor. All rights reserved.

Built with 🫶 by Shatlyk

Course Overview
Arrays, Strings & Hash Maps OverviewArraysStringsHash Maps and SetsArrays, Strings & Hash Maps Quiz
Built-in Data Structures

Arrays, Strings & Hash Maps Overview

Learn how data structures organize data before working with arrays, strings, hash maps, and sets.

A data structure organizes values so you can do particular operations on them. Imagine looking for a receipt. A stack of receipts puts the most recent one within reach. If you usually search by order number instead, a collection indexed by order number can save you a full scan.

Drawer dividers group clothes, shelves order books alphabetically, and a stack keeps the newest receipt on top.

Start with the operation

Suppose a music app needs to store a playlist, its title, a play count for each track, and the tracks a listener has already heard. Four built-in structures answer four different questions:

QuestionStructureExample
Which track is third?Array or listRead the track at index 2.
Which letters occur in the title?StringScan the title from left to right.
How many times did a track play?Hash mapLook up a count by track ID.
Have we played this track?SetCheck whether its ID is present.

Organization and storage

An array has a linear order. A tree branches into parent and child positions. A map associates a key with a value. Those descriptions tell you how to use the structure. Its physical representation tells you what each operation costs.

Linear structures include arrays, stacks, and queues. A tree represents a hierarchy, and a hash map associates keys with values.

A traditional array puts fixed-size slots next to each other, so its starting address and an index locate a slot directly. In a linked sequence, a node stores a reference to the next node. Reaching the third node from the first requires following two links. A dynamic array may replace its underlying storage as the collection grows.

Compare the cost of a lookup

If a playlist contains n tracks, reading track number three takes O(1) time. Finding an unknown position by scanning for a title takes O(n) time in the worst case. A map keyed by track ID can retrieve a count in average O(1) time. Searching its values for a count of 100 can still require visiting every entry.

OperationDynamic arrayHash map keyed by track ID
Read a known position or keyO(1) by indexAverage O(1) by key
Search for an arbitrary valueO(n) worst caseO(n) worst case
Add an entryAmortized O(1) at the end, O(n) at the frontAverage O(1) by key
Remove an entryO(n) to preserve order at the frontAverage O(1) by key

The table assumes fixed-cost keys and ordinary dense arrays. A single append can take longer when the backing storage grows. An unusually crowded hash location can also make an individual lookup slower.

Chapter flow

  • Arrays: Work with indexed collections and their common operations.
  • Strings: Compare, traverse, and transform ordered text.
  • Hash Maps and Sets: Use key-value lookups and membership checks.

How is this lesson?

Previous lessonAlgorithm Efficiency and Problem SolvingNext lessonArrays
Edit on GitHubReport on GitHub
On this page
%

On this page

Start with the operationOrganization and storageCompare the cost of a lookupChapter flow