Searching and Sorting Homework
Searching and Sorting Homework
Figure 1
Perform a merge sort on the data shown in Figure 1 by filling in the table below. A row should show
each pair of lists that have been merged together.
The first stages of splitting each item into a list of its own has already been done, and the first row of
merges has been completed for you.
State the total number of merges that took place when executing a merge sort on the data shown in
Figure 1.
State the number of new lists that were created during the merge part of the algorithm.
Page 1
Task 2 . Crossword
Jennifer is developing a program that randomly generates a crossword based on a database of words.
She is currently writing a script to check all the four-letter words. A sample of data is shown in
Figure 2.
Figure 2
Perform a merge sort on the data shown in Figure 2 by filling in the table below. A row should either
show each list that has been split in half, or each pair of lists that has been merged together.
Page 2
Task 3 . Sort
Show the different passes when the bubble sort is applied to sort this simple array from:
22 4 13 9 17 1
to
1 4 9 13 17 22
Perform a merge sort using the data array [6, 3, 9, 2, 7], ensuring that you show all the stages in the
process.
Page 3
Task 4 . Search
Samira is writing a simple program to allow a user to enter a name to be searched in an array. Here is
the pseudocode for the algorithm she wants to use
Describe the algorithm, in terms of its inputs and outputs. What does it do?
The algorithm could be amended to be more efficient. State which line of the algorithm could be
changed and explain how the change will make the algorithm more efficient.
Page 4
Jack has been given homework to write an algorithm to search a variety of small arrays. Which search
method would be most suitable for use with this array, and why?
[2, 6, 9, 12, 23, 41, 76, 84, 92]
Page 5