PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Applied

Implement a fixed-capacity generic circular buffer

Last updated: Mar 29, 2026

Quick Overview

This question evaluates knowledge of data structure design, generic types, in-place memory allocation, and constant-time FIFO operations required for implementing a fixed-capacity circular buffer.

  • medium
  • Applied
  • Coding & Algorithms
  • Software Engineer

Implement a fixed-capacity generic circular buffer

Company: Applied

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

Design a data structure that stores generic elements `T` with the following properties: - **FIFO** semantics (queue): `pop()` returns the oldest element. - `push()` and `pop()` must be **O(1)**. - The buffer has a fixed **capacity** known at class instantiation time, and **memory must be allocated at instantiation** (no per-operation allocation). - When the buffer is full and you `push()` a new element, it **overwrites the oldest** element. ### Task Implement a circular buffer class, e.g. `CircularBuffer<T, N>` where: - `T` is the element type - `N` is the fixed capacity (example: `N = 5`) Implement at least: - `push(value)` - `pop()` - `print()` (prints elements from oldest to newest) ### Define edge behavior - What happens if `pop()` is called on an empty buffer? - After overwriting, ensure ordering is still FIFO over the retained elements.

Quick Answer: This question evaluates knowledge of data structure design, generic types, in-place memory allocation, and constant-time FIFO operations required for implementing a fixed-capacity circular buffer.

Related Interview Questions

  • Merge Overlapping Collinear Segments - Applied (hard)
  • Implement a Fixed-Capacity Deque - Applied (medium)
  • Implement Nested Transactional Key-Value Store - Applied (hard)
  • Merge overlapping 2D line segments - Applied (medium)
  • Find intersection of two line segments - Applied (easy)
Applied logo
Applied
Feb 11, 2026, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
0
0
Loading...

Design a data structure that stores generic elements T with the following properties:

  • FIFO semantics (queue): pop() returns the oldest element.
  • push() and pop() must be O(1) .
  • The buffer has a fixed capacity known at class instantiation time, and memory must be allocated at instantiation (no per-operation allocation).
  • When the buffer is full and you push() a new element, it overwrites the oldest element.

Task

Implement a circular buffer class, e.g. CircularBuffer<T, N> where:

  • T is the element type
  • N is the fixed capacity (example: N = 5 )

Implement at least:

  • push(value)
  • pop()
  • print() (prints elements from oldest to newest)

Define edge behavior

  • What happens if pop() is called on an empty buffer?
  • After overwriting, ensure ordering is still FIFO over the retained elements.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Applied•More Software Engineer•Applied Software Engineer•Applied Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.