← Back

Problem 1.2 The Missing Machine

Introduction

This problem refers to the same network server as the previous problem. The server collects identifiers from various machines on the network and ensures the data is free of duplicates. However, if a machine has been offline throughout the communication period and doesn’t interact with the server, its identifier will be missing from the list. In such cases, the server needs to quickly detect which machine is missing to address the issue promptly.

Problem definition

We are given a vector identifiers of \( N = 2^d - 1 \) unique binary strings of length \( d \). Therefore one of the \(2^d\) possible identifiers is missing. The identifiers are not necessarily in the sorted order.

The goal is to find the identifier of the missing machine.

For example:

Input: identifiers = {"110", "101", "011", "111", "001", "000", "100"}
Output: The identifier of the missing machine = "010"

Some notes: solving this problem may not require sorting the strings first. Moreover, you might be able to do this without using any additional memory, except for a few variables.

Design and implement a solution in C++. The following code provides an empty function (to be implemented by you), and a main that tests it.


                

Missing Machine(s)

In another version of the problem, the server does not preprocess the data. All received identifiers, including duplicates, are kept in the identifiers list. Additionally, more than one machine might be offline and fail to communicate with the server, leading to multiple missing identifiers. The task is to report all the missing identifiers.

Problem definition

We are given a vector identifiers of \( N \) binary strings of length \( d \) each, possibly containing duplicates. The identifiers are not necessarily in the sorted order.

The goal is to report the identifiers of all missing machines.

The function to write: