• MohamedG's Log

    Selection of Majority in O(n)

    Selection algorithms are very useful in many instances, like finding the majority. Given an array of size n that contains a majority item (an item that's repeated more than n/2 times), we can find that item in O(n). Basically, we can consider it as a...
  • MohamedG's Log

    Passing C++ Arrays by Value

    Just in case you needed to, you can wrap an array into a struct/class and pass it by value to a function: template < typename T, int N> struct array { T value[N]; T & operator []( int i) { return value[i]; } }; template < typename T, int...
Page 1 of 1 (2 items)