How are DoS attacks prevented? Say the network is flooded with these output creating tx.
There wouldn't be any DOS attacks from spamming the network. Once one transaction is created to consolidate the UTXO's and that transaction was considered valid, any other transaction spending the same inputs to consolidate would be invalidated and treated as a double spend. These would then be removed from the network. Also, any node spamming the network with these transactions within a very short amount of time would receive a banscore from its peers and thus be disconnected from the network for some amount of time.