Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Partition a randomized parent array

Hardware interview practice

Partition a randomized parent array

MediumConstraintsSystemVerilog

Randomize a unique five-element parent array, choose three non-empty child sizes that sum to five, then partition the parent elements among the children.

Try it in the question bankReason first. Then compare.

Keep this exact question selected while you check your answer and review the full solution.

Practice this question →
Reviewed example

Work through one case

Input
parent=[0,1,2,3,4]; randomized child sizes=[1,2,2]
Expected output
child1=[0], child2=[1,2], child3=[3,4]

A monotonically increasing source index slices contiguous segments and consumes every parent element exactly once.

What to cover

Requirements

  1. Each child size must be between 1 and 4.
  2. Every parent element must appear in exactly one child.
  3. Create and populate child arrays in post_randomize.
Continue practicing

Related questions

ConstraintsDo not repeat the previous five values→
asic.fyi · Learn silicon end to end.info@asic.fyi