• MohamedG's Log

    Passing C++ Arrays by Value

    • 5 Comments
    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...
  • MohamedG's Log

    Selection of Majority in O(n)

    • 4 Comments
    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...
Page 1 of 1 (2 items)