PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Amazon

Schedule vector ops on heterogeneous cores

Last updated: Mar 29, 2026

Quick Overview

This question evaluates understanding of scheduling and load-balancing heuristics for heterogeneous processors, algorithmic complexity reasoning, and efficient implementation of constrained assignment problems.

  • medium
  • Amazon
  • Coding & Algorithms
  • Software Engineer

Schedule vector ops on heterogeneous cores

Company: Amazon

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

You are optimizing a “vectored computation” on a **heterogeneous (non-SMP) CPU** with asymmetric cores. ## Hardware model There are two core types: - **D-cores**: can execute **division** operations only. - **MD-cores**: can execute **multiplication and division**, and may have different per-op costs. Each core runs one operation at a time; operations assigned to the same core run sequentially. ## Workload You are given a vector of independent operations (order doesn’t matter): - `ops[i] ∈ {'M', 'D'}` meaning multiply or divide. And performance parameters: - D-core: `time_D_on_Dcore` - MD-core: `time_D_on_MDcore`, `time_M_on_MDcore` ## Task Design and implement a function that produces a **near-optimal schedule** to minimize the total completion time (makespan): ```python def schedule_ops(ops: list[str], num_d: int, num_md: int, tD_d: int, tD_md: int, tM_md: int) -> tuple[int, list[int]]: """ Returns: - estimated minimal makespan (time units) - an assignment array where assignment[i] is the core index chosen for ops[i] (e.g., cores 0..num_d-1 are D-cores, num_d..num_d+num_md-1 are MD-cores) """ ``` ## Requirements - Must never assign an `M` op to a D-core. - Should handle large inputs (e.g., up to 1e5 operations). - The goal is *not* perfect optimality (the exact optimum may be expensive); aim for a good heuristic with clear reasoning. ## Edge cases - `num_d=0` or `num_md=0` - All ops are the same type - Very imbalanced costs (e.g., MD-core divides much slower than D-core)

Quick Answer: This question evaluates understanding of scheduling and load-balancing heuristics for heterogeneous processors, algorithmic complexity reasoning, and efficient implementation of constrained assignment problems.

Related Interview Questions

  • Implement Datacenter Router Commands - Amazon (hard)
  • Implement Event Filtering and Queue Routing - Amazon (medium)
  • Determine if all courses can be completed - Amazon (medium)
  • Replace Delimited Tokens in a String - Amazon (medium)
  • Minimize Circular Redistribution Cost - Amazon (medium)
Amazon logo
Amazon
Jan 2, 2026, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
5
0
Loading...

You are optimizing a “vectored computation” on a heterogeneous (non-SMP) CPU with asymmetric cores.

Hardware model

There are two core types:

  • D-cores : can execute division operations only.
  • MD-cores : can execute multiplication and division , and may have different per-op costs.

Each core runs one operation at a time; operations assigned to the same core run sequentially.

Workload

You are given a vector of independent operations (order doesn’t matter):

  • ops[i] ∈ {'M', 'D'} meaning multiply or divide.

And performance parameters:

  • D-core: time_D_on_Dcore
  • MD-core: time_D_on_MDcore , time_M_on_MDcore

Task

Design and implement a function that produces a near-optimal schedule to minimize the total completion time (makespan):

def schedule_ops(ops: list[str], num_d: int, num_md: int,
                 tD_d: int, tD_md: int, tM_md: int) -> tuple[int, list[int]]:
    """
    Returns:
      - estimated minimal makespan (time units)
      - an assignment array where assignment[i] is the core index chosen for ops[i]
        (e.g., cores 0..num_d-1 are D-cores, num_d..num_d+num_md-1 are MD-cores)
    """

Requirements

  • Must never assign an M op to a D-core.
  • Should handle large inputs (e.g., up to 1e5 operations).
  • The goal is not perfect optimality (the exact optimum may be expensive); aim for a good heuristic with clear reasoning.

Edge cases

  • num_d=0 or num_md=0
  • All ops are the same type
  • Very imbalanced costs (e.g., MD-core divides much slower than D-core)

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Amazon•More Software Engineer•Amazon Software Engineer•Amazon 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.