>RunTimeFix
BookStudyPracticeInterviewsYouTubeCoursesAbout
Log inGet Started
Topics/Segment Tree & Fenwick Tree
advanced level

Segment Tree & Fenwick Tree

Quick Answer

What is Segment Tree & Fenwick Tree?

Segment trees and Fenwick trees (Binary Indexed Trees) are the workhorses of range query problems. A Fenwick tree supports point updates and prefix queries in O(log n) with minimal code — ideal for counting inversions, frequency queries, and order statistics. A segment tree is more general: it handles arbitrary range queries (min, max, sum, GCD) with lazy propagation for range updates. RunTimeFix teaches both structures from scratch: how they work internally, when to choose one over the other, and the implementation patterns that avoid common bugs.

  • segment tree
  • Fenwick tree
  • binary indexed tree
  • BIT
  • range queries
  • lazy propagation
  • coordinate compression

Study Material for Segment Tree & Fenwick Tree

Ch 20: Coordinate Compression, Fenwick Tree & Segment Tree

Coordinate Compression · Fenwick Tree (Binary Indexed Tree) · Segment Tree · Sparse Table (D1 — Recognition)

Related Topics

Data StructuresCompetitive ProgrammingAlgorithms
Was this helpful?

Published by RunTimeFix · Comprehensive guides for competitive programming

>RunTimeFix

Practical programming education. Books, videos, courses, and hands-on learning for competitive programming, DSA, and software engineering.

RunTimeFix

  • About
  • YouTube
  • Book
  • Study Library
  • Courses

Learn

  • Competitive Programming
  • DSA
  • Development
  • Databases

Legal

  • Privacy
  • Terms
  • Refund Policy

RunTimeFix — debug → solve → run

© 2026 RunTimeFix. All rights reserved.