Forwarded from Syra's Techbinder
https://stackoverflow.com/questions/11227809/why-is-it-faster-to-process-a-sorted-array-than-an-unsorted-array
Tags: #programming #architecture
Tags: #programming #architecture
Stack Overflow
Why is processing a sorted array faster than processing an unsorted array?
In this C++ code, sorting the data (before the timed region) makes the primary loop ~6x faster:
#include <algorithm>
#include <ctime>
#include <iostream>
int main()
{
// Gene...
#include <algorithm>
#include <ctime>
#include <iostream>
int main()
{
// Gene...