My Report (&Account)

Array Data Structure Test – 1


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)

1. Under what condition the number of inversions in an array are maximum?

2. How many inversions are there in the array arr = {1,5,4,2,3}?

3. What is the time complexity of the code that uses self balancing BST for determining the number of inversions in an array?

4. Under what condition the number of inversions in an array are minimum?

5. The time complexity of the code that determines the number of inversions in an array using merge sort is lesser than that of the code that uses loops for the same purpose.

6. How many inversions does a sorted array have?

7. What does the number of inversions in an array indicate?

8. What is the time complexity of the following code that determines the number of inversions in an array?

int InvCount(int arr[], int n) 
{ 
	int count = 0; 
	for (int i = 0; i < n - 1; i++) 
		for (int j = i + 1; j < n; j++) 
			if (arr[i] > arr[j]) 
				count++; 

	return count; 
} 

9. What is the space complexity of the code that uses merge sort for determining the number of inversions in an array?

10. What is the condition for two elements arr[i] and arr[j] to form an inversion?


 

Start practicing “1000 MCQs on Data Structure”, and once you are ready, you can take tests on all topics by attempting our “Data Structure Test Series”.

advertisement
advertisement
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.