Font size
WorksheetsSearching and Sorting Algorithm
Total questions: 71
Worksheet time: 1hrs 15mins
Select the best description to explain what a binary search algorithm is.
Put the elements in order, check each item in turn.
Put the elements in order, compare with the middle value, split the list in order and repeat.
Elements do not need to be in order, check each item in turn.
Elements do not need to be in order, compare to the middle value, split the list in order and repeat
12 6 8 1 3
How many comparisons would it take to find number 1?
3 5 9 10 23
How many comparisons would it take to find number 9?
1 5 10 13 48 68 100 101
How many comparisons would it take to find number 101?
Which of these are search algorithms?
Bubble
Merge
Linear
Binary
Caesar
Which of these algorithms searches for something by first looking in the middle of a list?
Bubble sort
Merge sort
Linear search
Binary search
Which of these algorithms eliminates half of its possibilities each time it makes a check?
Binary search
Bubble sort
Merge sort
Linear search
What does the left subtree of a node in a Binary Search Tree contain?
Elements with duplicate keys
Elements equal to the node
Elements smaller than the node
Elements greater than the node
Which operation is used to find a key in a Binary Search Tree?
remove(x)
insert(x)
update(x)
search(x)
How is insertion into a Binary Search Tree done?
Recursively
Using a stack
Using a queue
Iteratively
What is the correct algorithm for deletion in a Binary Search Tree?
Find the successor and remove it
Find the predecessor and remove it
Delete the root node
Delete the leaf nodes
What is the property of Binary Search Tree that makes searching easy?
Elements are sorted in descending order
Elements are sorted in ascending order
Elements are randomly arranged
Elements are stored in a linked list
Which operation is used to insert a new key into a Binary Search Tree?
search(x)
remove(x)
insert(x)
find(x)
What does the right subtree of a node in a Binary Search Tree contain?
Elements greater than the node
Elements smaller than the node
Elements equal to the node
Elements with duplicate keys
Post order traversal :
1a+b*c+d*e+f*g
1abc*+de*f+g*+
++a*bc*+*defg
abc+*+defg*+*
In Order traversal
40 20 50 10 30
40 50 20 30 10
10 20 30 40 50
50 40 20 30 10
What is the MAXIMUM number of nodes in a binary search tree with height = 5 ?
26-1
25-1
25
26
6
What is the MINIMUM number of nodes in a binary search tree with height = 5?
6
5
26-1
25-1
25
What is the worst-case runtime of lookUp/get in a binary search tree?
O(n)
O(logn)
O(1)
O(n2)
What is the worst-case runtime of lookUp/get in a *perfectly balanced* binary search tree?
O(logn)
O(n)
O(1)
O(n2)
Which method checks that two objects are equivalent?
toString
equals
compareTo
binarySearch
Binary Search works best on
Equally effective on sorted and unsorted lists
Unsorted lists
Sorted lists
None of the above
If the specified value is present binary search will return
true
false
the value
the position of the value
Which sorting algorithm may make multiple swaps per pass?
Bubble Sort
Selection Sort
Insertion Sort
Merge Sort
What does a sorting algorithm do?
Puts numbers in order
Puts data in order
Finds a bit of data
How many passes are required to sort a list with 5 elements?
5
4
10
2
1 4 2 9 3 8 5
What does the list look like after one pass of the insertion sort algorithm.
4 8 6 2 5 7
4 8 6 2 5 7
4 6 8 2 5 7
