Help shape GoConqr. What should we add next?

Flashcards

CMPUT 175 final exam review

Chuck Hanson Computer Science English 23 cards

Cards in this deck (23)

  1. 1What are the best-case, worst-case, and average case running times of Bubble Sort?Best: O(n)
    Worst: O(n^2)
    Average: O(n^2)
  2. 2What is the time complexity of the number of comparisons that take place in selection sort?O(n^2)
  3. 3What is the time complexity of the number of swaps that take place in selection sort?O(n)
  4. 4What are the best-case, worst-case, and average case time complexities of the number of comparisons made by insertion sort?Best: O(n) comparisons
    Worst: O(n^2) comparisons
    Average: O(n^2) comparisons
  5. 5What are the best-case, worst-case, and average case time complexities of the number of swaps done by insertion sort?Best: O(1)
    Worst: O(n^2)
    Average: O(n^2)
  6. 6What is the time complexity of merge sort?O(n log n)
  7. 7What are the best-case, worst-case, and average time complexities of quick sort?Best: O(n log n)
    Worst: O(n^2)
    Average: O(n log n)
  8. 8What are the in-place sorting algorithms discussed in class?Merge sort, quick sort
  9. 9Consider the list [5, 8, 2, 3, 7, 6, 1] What would be the state of the list after the first pass of Quick Sort?[1, 2, 3, 5, 7, 6, 8]
  10. 10Consider the tree a / \ / \ b c d e / \ f g Give the preorder, inorder, and postorder traversal of the tree.Preorder: a b f g c d e
    Inorder: f b g c d a e
    Postorder: f g b c d e a
  11. 11What is a binary search tree?A BST is a binary tree in which, for every node, the element in the node is >= the elements in the left subtree and <= the elements in the right subtree.
  12. 12In what order is a preorder traversal carried out?Root -> left -> right
  13. 13In what order is an inorder traversal carried out?Left -> root -> right
  14. 14In what order is a postorder traversal carried out?Left -> right -> root
  15. 15What are the fields used to initialize a binary search tree node?key, value, leftChild, rightChild, parent
  16. 16What are the methods in a binary search tree?put(self, key, value)
    get(self, key)
    remove(self, key)
    getSize(self)
    getRoot(self)
  17. 17Say I want to delete a node that has two children. What do I need to do?1. Find a successor - largest key in left subtree or the smallest key in right subtree
    2. Copy (swap) the key/value of the chosen successor to the current node, then recursively remove it.
  18. 18Consider the list [2, 7, 5, 9, 3, 1, 4] What does the list look like after the first pass of selection sort?[1, 7, 5, 9, 3, 2, 4]
  19. 19Consider the list [3, 1, 6, 5, 2, 8, 7] What will the list look like after the first pass of bubble sort?[1, 3, 5, 4, 8, 2, 7]
  20. 20Consider the list [2, 7, 5, 7, 3, 1, 4] What will it look like after the first pass of insertion sort?[2, 5, 7, 3, 1, 4]
  21. 21Order these running times in ascending order in terms of their efficiency: n, log(n), 1, n^2, n log(n), n^3, 2^n1
    log(n)
    n
    n log(n)
    n^2
    n^3
    2^n
  22. 22If I want to add a new node to the head (front) of a doubly-linked list, I would write: new_node.setPrevious(_____)None
  23. 23When inserting a new node into a doubly-linked list, I may need to update as many as __ links.4

Information

Description
Computer Science Flashcards on CMPUT 175 final exam review, created by Chuck Hanson on 11/04/2018.
Created by
Chuck Hanson
Views
3
Rating

Feedback

What is it about?

What should we add next?