Docsity

CISC 121 Exam Study Guide: Data Structures and Algorithms, Exams of Social Sciences

Toggle sidebar
bg1
CISC 121 EXAM STUDY GUIDE
array - worst case time complexity - Answers -acces: O(1)
search: O(n)
insertion: O(n)
deletion: O(n)
stack - worst case time complexity - Answers -access: O(n)
search: O(n)
insertion: O(1)
deletion: O(1)
queue - worst case time complexity - Answers -access: O(n)
search: O(n)
insertion: O(1)
deletion: O(1)
singly-linked list - worst case time complexity - Answers -access: O(n)
search: O(n)
insertion: O(1)
deletion: O(1)
doubly-linked list - worst case time complexity - Answers -acces: O(n)
search: O(n)
insertion: O(1)
deletion: O(1)
binary search tree - worst case time complexity - Answers -acces: O(n)
search: O(n)
insertion: O(n)
deletion: O(n)
quick sort - worst case time complexity - Answers -O(n^2)
merge sort - worst case time complexity - Answers -O(nlogn)
bubble sort - worst case time complexity - Answers -O(n^2)
insertion sort - worst case time complexity - Answers -O(n^2)
selection sort - worst case time complexity - Answers -O(n^2)
linked list - Answers -- linear data structure
pf3

Partial preview of the text

Download CISC 121 Exam Study Guide: Data Structures and Algorithms and more Exams Social Sciences in PDF only on Docsity!

CISC 121 EXAM STUDY GUIDE

array - worst case time complexity - Answers - acces: O(1) search: O(n) insertion: O(n) deletion: O(n) stack - worst case time complexity - Answers - access: O(n) search: O(n) insertion: O(1) deletion: O(1) queue - worst case time complexity - Answers - access: O(n) search: O(n) insertion: O(1) deletion: O(1) singly-linked list - worst case time complexity - Answers - access: O(n) search: O(n) insertion: O(1) deletion: O(1) doubly-linked list - worst case time complexity - Answers - acces: O(n) search: O(n) insertion: O(1) deletion: O(1) binary search tree - worst case time complexity - Answers - acces: O(n) search: O(n) insertion: O(n) deletion: O(n) quick sort - worst case time complexity - Answers - O(n^2) merge sort - worst case time complexity - Answers - O(nlogn) bubble sort - worst case time complexity - Answers - O(n^2) insertion sort - worst case time complexity - Answers - O(n^2) selection sort - worst case time complexity - Answers - O(n^2) linked list - Answers -- linear data structure

  • each element is a separate object and is comprised of two items: the data, and a reference to the next node
  • last node references null
  • Python does not have linked lists in its standard library binary search tree - Answers -- node-based binary tree data structure which has the following properties:
  • left subtree of a node contains only nodes with key lesser than the node's key

  • right subtree of a node contains only nodes with keys greater than the node's key

  • left and right subtree each must also be a binary search tree bubble sort - what is it - Answers -- not a sorting algorithm we'd likely want to use in the real world

  • walks through array; every time we see elements out of order, it swaps them
  • after enough times, array is sorted
  • pretty SLOW
  • run time of O(n^2)
  • O(n) passes through array

  • O(n) time for each pass plus side don't need any extra memory for this algorithm insertion sort - what is it - Answers -- based on idea that one element from the input is consumed in each iteration to find its correct position (i.e. where it belongs in a sorted array)

  • all elements larger than the current element are shifted to one position ahead in the sorted array

  • pretty SLOW; time complexity is O(n^2)
  • useful when # elements is small or only a few elements are misplaced selection sort - what is it - Answers -- repeatedly finds the minimum element from the unsorted part and puts it at the beginning
  • pretty SLOW; time complexity is O(n^2)
  • two nested loops plus side makes no more than O(n) swaps, so it's useful when memory write is a costly operation merge sort - what is it - Answers -- divide & conquer algorithm

  • divides input array in two halves, calls itself for the two halves, then merges the two sorted halves
  • FAST; time complexity is O(nlogn) quick sort - what is it - Answers -- divide & conquer algorithm
  • finds element called Pivot, which divides the array into two halves in such a way that elements in left half are smaller than pivot & elements in right are greater
  • recursively performs 3 steps