# minKPriorityQueue

> **minKPriorityQueue**<`K`, `V`>(`k`, `keyOrder`, `entries?`): [`KPriorityQueue`](/reference/knotkit/heap/interfaces/kpriorityqueue/)<`K`, `V`>

Defined in: [packages/heap/src/priority-queue.ts:696](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/heap/src/priority-queue.ts#L696)

Create a min priority queue over a k-ary heap: same contract as [minPriorityQueue](/reference/knotkit/heap/functions/minpriorityqueue/), with up to `k` children per node.

## Type Parameters

### K

`K`

### V

`V`

## Parameters

### k

`number`

Arity: children per node. Must be a safe integer >= 2.

### keyOrder

[`Order`](/reference/knotkit/heap/type-aliases/order/)<`K`>

Total ordering over the keys.

### entries?

`Iterable`\<readonly \[`K`, `V`], `any`, `any`>

Optional initial `[key, value]` pairs, in iteration order.

## Returns

[`KPriorityQueue`](/reference/knotkit/heap/interfaces/kpriorityqueue/)<`K`, `V`>

## Example

```ts
const pq = minKPriorityQueue(4, numberOrder, [[5, 'a'], [1, 'b'], [3, 'c']])
pq.peek() // 'b'
```

## Throws

With code `INVALID_ARITY` when `k` is not a safe integer of at least 2.

## Throws

With code `DUPLICATE_VALUE` when `entries` carries one value twice.
