C949 Data Structures and Algorithms Study Guide, Exams of Nursing

A study guide for C949 Data Structures and Algorithms. It includes definitions and examples of data structures, algorithms, and sorting methods. It also covers topics such as ADT, function, polymorphism, and instantiation. the Big O notation and provides examples of sorting algorithms such as selection, insertion, shell, quick, merge, and bucket sort. It is a useful resource for students studying data structures and algorithms.

Typology: Exams

2023/2024

Available from 01/02/2024

StudyAceSmart
StudyAceSmart 🇺🇸

3

(6)

1.9K documents

1 / 15

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
C949 Data Structures and Algorithms
C949 Data Structures and Algorithms
Study Guide Exam Questions Review (56
terms) with Certified Solutions 2024.
Record - Answer: Data structure that stores subitems, w/ names associated w/
each subitem
Array - Answer: Data structure that stores an ordered list of items, w/ each item
directly accessible by a positional index.
Linked List - Answer: Data structure that stores an ordered list as nodes, each
node stores data and has a pointer to the next node.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download C949 Data Structures and Algorithms Study Guide and more Exams Nursing in PDF only on Docsity!

C949 Data Structures and Algorithms

Study Guide Exam Questions Review (

terms) with Certified Solutions 2024.

Record - Answer: Data structure that stores subitems, w/ names associated w/ each subitem Array - Answer: Data structure that stores an ordered list of items, w/ each item directly accessible by a positional index. Linked List - Answer: Data structure that stores an ordered list as nodes, each node stores data and has a pointer to the next node.

Binary Tree - Answer: Data structure where each node stores data and has up to two children, left child and right child. Hash Table - Answer: Data structure that stores unordered items by mapping each item to a location in an array. Max Heap - Answer: Tree that maintains the simple property that a node's key is greater than or equal to a node's children key. Min Heap - Answer: A tree that maintains simple property that node's key is less than or equal to the node's children key. Graph - Answer: Represents connections among items. Consists of vertices and edges. Vertex represents an item on a graph. Edges represent a connection between two vertices. ADT (Abstract Data Type) - Answer: Data type described by predefined user operations. Does not say anything about the implementation.

if expression:

Statements to execute when expression is true

else:

Statements to execute when expression is false

Statements here execute after the if-else.

Boolean Operators - Answer: Has 3 operators: and / or / not In Python, True/False are case sensitive Membership Operators - Answer: not , in Cannot check for values but can check for keys. ex. my_dict = {'A': 1, 'B': 2, 'C': 3} if 'B' in my_dict: print("Found 'B'") else: print("'B' not found")

operator does not check values

if 3 in my_dict: print('Found 3') else: print('3 not found') reversed() - Answer: Iterates over a for loop backwards. ex. print('\nPrinting in reverse:') for name in reversed(names): print(name, '|', end=' ') Function (invoking a function is called a function call, which causes a function to execute. ) - Answer: Named series of statements. e.g.: def compute_square(num_square): return num_square * num_square

  • A method is a function defined within a class. T
  • init method, commonly known as a constructor, is responsible for setting up the initial state of the new instance with attributes ex. class Time(object): def init(self): self.hours = 0 self.minutes = 0 time1 = Time() time1.hours = 7 time1.minutes = 15 Recursive Function - Answer: A function can call itself or other functions. Ex. def count_down(count): if count == 0:

print('Go!') else: print(count) count_down(count-1) count_down(2) Loop over dictionaries - Answer: for key in dictionary: # Loop expression

Statements to execute in the loop

#Statements to execute after the loop Conditional List - Answer: new_list = [expression for name in iterable if condition] Algorithm Efficiency - Answer: measures algorithm complexity Computational Complexity - Answer: amount of resources used by algorithm. ex runtime / memory usage.

Big O - Answer: notation for expressing the worst-case run-time of an algorithm, useful for comparing the speed of two algorithms. logN (log2N + 1) - Answer: binary search efficiency Selection Sort - Answer: A sort algorithm that repeatedly scans for the smallest item in the list and swaps it with the element at the current index. The index is then incremented, and the process repeats until the last two elements are sorted. Run time : O(N^2) Insertion Sort - Answer: A simple sorting algorithm that builds the final sorted array (or list) one item at time. It is much less efficient on large lists than more advanced algorithms such as quicksort, heapsort, or merge sort. Run time : O(N^2) selection, insertion - Answer: difference is in what the inner loop does: In _______ sort, the inner loop is over the unsorted elements. Each pass selects one element, and moves it to its final location (at the current end of the sorted region).

In _______ sort, each pass of the inner loop iterates over the sorted elements. Shell Sort - Answer: Starts by sorting pairs of elements far apart from each other, then progressively reducing the gap between elements to be compared. Starting with far apart elements can move some out-of-place elements into position faster than a simple nearest neighbor exchange. gap value: distance between elements in an interleaved list Worst Case: O(N^(3/2)) Quick Sort - Answer: Unstable, O(n log n) for a good pivot,O(n^2) for a bad pivot Ω(n log n) : Uses partitioning O(n), Pick a median of 1st, middle, and last element for pivot. Random selection is also good, but expensive. Algorithm can be slow because of many function calls. Midpoint: i + (k-i)/ def quicksort (numbers, start_index, end_index):

Radix Sort - Answer: an O(n*k) search algorithm where K = keylength. Stable. Sorts input into bins based on the lowest digit; then combines bins in order and sorts on the next highest digit & so forth. O(d(n+b)) Bubble Sort - Answer: Moving through a list repeatedly, swapping elements that are in the wrong order. O(N^2) Quickselect - Answer: A selection algorithm to find the kth smallest element in an unordered list.

  • uses the same overall approach as quicksort, choosing one element as a pivot and partitioning the data in two based on the pivot, accordingly as less than or greater than the pivot.
  • Instead of recursing into both sides, as in quicksort, this algorithm only recurses into one side - the side with the element it is searching for, which reduces the average complexity from O(n log n) to O(n). Worst case run time O(n^2) singly linked list - Answer: a data structure in which each list element contains a pointer to the next list element

Appending to a list - Answer: Inserts a new node after the lists tail. Prepending to a list - Answer: Inserts a new node before the list's head node. insertAfter() - Answer: Insert every element in the set of matched elements after the target. (list, curNode, newNode) RemoveAfter() - Answer: Removes node after specified list node. Hash Table - Answer: A data structure that stores unordered items by mapping each item to a location in an array (or vector) Mid square - Answer: hash function that extracts R digits middle number and returns middle number divided by hash table size remainder. For N buckets R must be greater than or equal to log N ex. 453*453 = 205209 middle number is 52 52 % 100 gives remainder 52.