Computer Science EngineeringHard
The number of inversions in the array [3, 1, 2, 5, 4] is
- A. 3
- B. 4
- C. 2
- D. 5
Correct answer: A. 3
The inversions are (3,1), (3,2) and (5,4).
Practise more Algorithms, Data Structures & Programming (ISRO CS) questionsAlgorithms, Data Structures & Programming (ISRO CS): notes and key points
More Algorithms, Data Structures & Programming (ISRO CS) questions
- A full binary tree (every node has 0 or 2 children) has 20 leaves. How many internal nodes does it have?
- A circular queue is stored in an array of size 8 and uses the convention (rear+1) mod 8 == front for 'full'. Maximum number of elements it…
- For the pattern ABABACA, the KMP longest-proper-prefix-which-is-also-suffix value at the last position is
- Radix sort of n numbers with d digits in base b using a stable counting sort per digit takes
- What does g(48, 18) return for int g(int a,int b){ return b==0 ? a : g(b, a%b); }
- What does this fragment print? int a[]={3,1,4,1,5}; int s=0; for(int i=0;i<5;i++) s ^= a[i]; printf("%d", s);