Download presentation
Presentation is loading. Please wait.
1
Data Structures 2018 Quiz Answers
Phil Tayco Slide version 1.0 May 17, 2018
2
Quiz 1 Which of the following is true about Big-O?
O(n) is considered better performance than O(n2) Given an ordered set of numbers from lowest to greatest in a data structure like an array. Which of the following is true? Since the smallest number will always be the first element, the algorithm for finding the smallest number in the array is O(1) The algorithm to find the sum of all the numbers in the sorted array is O(n) Which of the following statements is/are true? Big-O measures the performance of your algorithm as the size of the data set it is working with increases in size
3
Quiz 2 Which of the following is true about deleting elements in an unordered array? None of the above O(1) is achieved for which of the following functions in an unordered array? append Which of the following statements is true about linear search in an unordered array? It is impossible to get better performance than O(n) Technically, the performance is O(2n) when using comparison operations. The category of performance is characterized as O(n) The update function in an unordered array is O(n) - True
4
Quiz 3 Which of the following is true about search, insert, update and delete functions for a sorted array? When compared to an unordered array, search is significantly improved with sorted arrays, but adding new elements to a sorted array is worse Which of the following is true when comparing arrays and linked lists? With unsorted data, search, insert, update and delete all perform in the same O category One of the primary advantages with linked lists over arrays is dynamic memory usage If the data is sorted, arrays are significantly better than linked lists for search 3a) 6 -> 8 -> 10 -> 7 -> 4 -> null 3b) 6 -> 8 -> 7 -> 4 -> null 3c) 6 -> 8 -> 7 -> null
5
Quiz 4 1) Final linked list stack: 2 -> 6 -> 5 -> 10
2) Final array queue: 3) Final linked list priority queue (showing only priorities): 50 -> 25 -> 10 -> 5 Bubble sort:
6
Quiz 4 Selection sort: Insertion sort:
7
Quiz 5 1) Output on screen 2) Fix: Comparing L L Comparing L E False
Change “return isPalindrome(str, s, e-1);” to “return isPalindrome(str, s+1, e-1);”
8
Quiz 6 Bubble sort: (remaining iterations repeat with no swaps) Description is correct Selection sort: <- incorrect part on quiz
9
Quiz 6 Insertion sort: <- incorrect part on quiz Mergesort: All correct until… Merge [7] and [6] to make [7 6] should be Merge [7] and [6] to make [6 7] Quicksort is correct
10
Quiz 7 First tree: 2 (second 4 on list is a quiz error) Second tree: 1 4 6 10 8 11 9
11
Quiz 7 Third tree: 5 4 3 1 2
12
Quiz 7 Final tree: 30 10 55 20 75 5 45 12 55 11
13
Quiz 8 2-3-4 tree: 4 Multiple choice: D B
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.