Tutorial 4 Set 1
Tutorial 4 Set 1
CO1: Articulate the design, use and associated algorithms of fundamental and abstract data structures
CO2: Examine various searching and sorting techniques based on complexity analysis for applicative
solutions.
CO4: Build optimized solutions for real-word programming problems using efficient data structures.
a) m-n
b) m+n-1
c) max (m, n)
d) min (m, n)
Question 3: Which one of the following in-place sorting algorithms needs the minimum
number of swaps? (4 Mins)
a) Bubble Sort
b) Selection Sort
c) Insertion Sort
d) Merge Sort
Question 2: Suppose you have the following list of numbers to sort: [15, 5, 4, 18, 12, 19, 14,
10, 8, 20] which list represents the partially sorted list after three complete passes of
insertion sort? (10 Mins)
a) [4, 5, 12, 15, 14, 10, 8, 18, 19, 20]
b) [15, 5, 4, 10, 12, 8, 14, 18, 19, 20]
c) [4, 5, 15, 18, 12, 19, 14, 10, 8, 20]
d) [15, 5, 4, 18, 12, 19, 14, 8, 10, 20]
Question 3: Suppose you have the following list of numbers to sort: [11, 7, 12, 14, 19, 1, 6,
18, 8, 20] which list represents the partially sorted list after three complete passes of
selection sort? (10 Mins)
a) [7, 11, 12, 1, 6, 14, 8, 18, 19, 20]
b) [7, 11, 12, 14, 19, 1, 6, 18, 8, 20]
c) [11, 7, 12, 14, 1, 6, 8, 18, 19, 20]
d) [11, 7, 12, 14, 8, 1, 6, 18, 19, 20]
Section 3 Hard (2 Questions)
Question 1: If one uses straight two-way merge sort algorithm to sort the following
elements in ascending order: [20, 47, 15, 8, 9, 4, 40, 30, 12, 17] then the order of these
elements after second pass of the algorithm is: [15 mins]
Question 2: Suppose we want to arrange the n numbers stored in an array such that all
negative values occur before all positive ones. The minimum number of exchanges required
in the worst case is [15 mins]
a) n–1
b) n
c) n+1
d) None of the above
Question 3: Find the big-O time complexity of each of the following code fragments: