Data Structure Questions and Answers-Pancake Sort

 

 Buy/Download all MCQ Ebook   >>>Click Here<<<

Data Structure Questions and Answers-Pancake Sort

Click on any option to know the CORRECT ANSWERS

Question 1
What is the time complexity for a given pancake sort given it undergoes "n" flip operations?
A
O(n)
B
O(n2)
C
O(n3)
D
O(2n)
Aptitude test Questions answers

Question 1 Explanation: 
Most sorting algorithms try to sort making the least number of comparisons but in pancake sort we try to sort using as few reversals as possible. Because the total number of flip operations performed in a pancake sort is O(n), the overall time complexity is O(n2).

Question 2
Which operation is most essential to the process of pancake sort?
A
Flip the given data
B
Find the largest of given data
C
Finding the least of given data
D
Inserting something into the given data
HRM Questions answers

Question 2 Explanation: 
When we use pancake sort, we sort the array to find the largest, and then flip the array at that point to bring that value to the bottom of the pancake stack. The size of the array that we are dealing with is then reduced and the process continues. Flip operation is the most important function in the pancake sort technique.

Question 3
There is one small error in the following flip routine. Find out which line it is on.

	1	void flip(int arr[], int i) 	2	{ 	3	 int t, init = 0; 	4	 while (init < i) 	5	 { 	6		 t = arr[init]; 	7		 arr[i] = arr[init] ; 	8		 arr[i] = t; 	9		 init++; 	10		 i--; 	11	 } 	12	}
A
Line 3
B
Line 5
C
Line 7
D
Line 9
Biology Questions answers

Question 3 Explanation: 
After initialization of the array titled arr; for each while loop iteration of increasing init, we should make arr[init]=arr[i]. This makes sure that the changes will be made in order to flip the order of the array that was to be flipped. Here in line 7 it has been written in reverse and is incorrect.

Question 4
How many flips does the simplest of pancake sorting techniques require?
A
3n-3 flips
B
2n-4 flips
C
2n-3 flips
D
3n-2 flips
UPSC test Questions answers

Question 4 Explanation: 
The minimum number of flips required to sort any stack of n pancakes has been shown to lie between 1.087n and 1.636n. using average of that 1.36n and extracting that for values of n>1. We have 1.36, 2.72, 4.08 etc. This matches best with 2n-3 which is equal to 1, 3, 5, 7, 9, etc. An upper bound of 2n-3 comes by iteratively using the next largest element in its correct place using two flips.

Question 5
Pancake Sorting appears in which of the following?
A
Frequency Scaling
B
Storage Virtualization
C
Parallel Processing
D
Neural Networking
Arab culture Questions answers

Question 5 Explanation: 
Pancake Sorting finds application in educational use not to mention parallel processing networks by providing optimal routing algorithms between networks.

There are 5 questions to complete.

 

 Buy/Download all MCQ Ebook >>>CLICK HERE<<<