text: Check for Majority Element in a sorted array |  ; Driver Code
code: using System ; class GFG { static bool isMajorityElement ( int [ ] arr , int n , int key ) { if ( arr [ n / 2 ] == key ) return true ; else return false ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 3 , 3 , 3 , 10 } ; int n = arr . Length ; int x = 3 ; if ( isMajorityElement ( arr , n , x ) ) Console . Write ( x + " ▁ appears ▁ more ▁ than ▁ " + n / 2 + " ▁ times ▁ in ▁ [ ] arr " ) ; else Console . Write ( x + " ▁ does ▁ not ▁ appear ▁ more ▁ " + " than ▁ " + n / 2 + " ▁ times ▁ in ▁ arr [ ] " ) ; } }