Problem C8
Discussthe difference between merge and Insertion sort algorithms.
[4 Marks]
Problem C9
Consider an array data structure below and answer the questions that follow.
[8 marks]
I I I I I I I I I I I - I 2 4 11 110 111 78 112 1o 16 9 11s 119 7 3 23 133 114 113 -1 s 8 116 7
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
(a). How many elements must be checked to try to find the value 33 in the above array using linear
search?
(b). How many elements must be checked to try to find the value 2 in the above array using linear search?
(c). How many elements must be checked to try to find the value -7 in the above array using linear search?
(d). How many elements must be checked to try to find the value 22 in the above array using linear
search?
Problem ClO
Given that a list has n elements, what would be the best case that could occur when linear searching for
an element?
[2 marks]
Problem Cll
Given that a list has n elements, what would be the worst case that could occur when linear searching for
an element?
[2 marks]
Problem C12
What would be the complexity of the best case for linear search?
[2 marks]
Problem C13
What would be the complexity of the worst case for linear search?
[2 marks]
Problem C14
Given the following array: 12, 18, 10, 14, 17, 8, 5, 11, 7
Provide a logical representation of the Quick sort partition. Use first element as pivot.
[S marks]
Problem C15
Discussthe difference between the linear search and binary search algorithms.
[4 Marks]
Problem C16
Given the following operations of a stack which are performed in that order,
Push(5), push(3), push(l), pop(), pop(), push(7)
(a). Draw a logical representation of a static stack after all the above operations are performed. You must
include the top pointer.
[3 marks]
(b). What will be the output of the pseudocode when the display() function is called?
[2 Marks]
5