CIS 1210 - Midterm 1 (GS - Heaps)

studied byStudied by 7 people
0.0(0)
learn
LearnA personalized and smart learning plan
exam
Practice TestTake a test on your terms and definitions
spaced repetition
Spaced RepetitionScientifically backed study method
heart puzzle
Matching GameHow quick can you match all your cards?
flashcards
FlashcardsStudy terms and definitions

1 / 190

encourage image

There's no tags or description

Looks like no one added any tags here yet for you.

191 Terms

1
<p></p>

knowt flashcard image
New cards
2

Euclid’s Algorithm

knowt flashcard image
New cards
3
<p>Prove correctness of Euclid’s</p>

Prove correctness of Euclid’s

knowt flashcard image
New cards
4

Runtime of Euclid’s

O(logb) where b is the the second inputed element gcd(a, b)

New cards
5
<p>Runtime Analysis of Euclid’s</p>

Runtime Analysis of Euclid’s

knowt flashcard image
New cards
6

Is sorting in decreasing or increasing order?

increasing

New cards
7

Runtime of Insertion Sort

O(n²)

New cards
8

Insertion Sort Algorithm

knowt flashcard image
New cards
9

Correctness of Insertion Sort

knowt flashcard image
New cards
10
<p>Proof of Runtime of Insertion Sort</p>

Proof of Runtime of Insertion Sort

knowt flashcard image
New cards
11

Big O def

knowt flashcard image
New cards
12

Big Omega def

knowt flashcard image
New cards
13

Theta def

knowt flashcard image
New cards
14

little o

knowt flashcard image
New cards
15

little omega

knowt flashcard image
New cards
16
term image
knowt flashcard image
New cards
17
term image
knowt flashcard image
New cards
18
term image
knowt flashcard image
New cards
19
term image
knowt flashcard image
New cards
20
term image
knowt flashcard image
New cards
21
term image
knowt flashcard image
New cards
22
term image
knowt flashcard image
New cards
23
term image
knowt flashcard image
New cards
24
term image
knowt flashcard image
New cards
25

just read

knowt flashcard image
New cards
26
term image
knowt flashcard image
New cards
27
term image
knowt flashcard image
New cards
28
term image
knowt flashcard image
New cards
29
term image
knowt flashcard image
New cards
30
term image
knowt flashcard image
New cards
31
term image
knowt flashcard image
New cards
32
<p>what’s wrong?</p>

what’s wrong?

knowt flashcard image
New cards
33

equals

New cards
34

New cards
35

New cards
36

New cards
37
<p>give runtime recurrence for each</p>

give runtime recurrence for each

New cards
38
<p>solve recurrences</p>

solve recurrences

knowt flashcard image
New cards
39

Linear Search Algorithm

knowt flashcard image
New cards
40
<p>Find &amp; solve out runtime recurrence of linear search</p>

Find & solve out runtime recurrence of linear search

knowt flashcard image
New cards
41

binary search algo

knowt flashcard image
New cards
42
<p>Find &amp; solve out runtime recurrence of binary search</p>

Find & solve out runtime recurrence of binary search

knowt flashcard image
New cards
43

Merge & MergeSort Algorithm

New cards
44

Find & solve out runtime recurrence of merge sort

knowt flashcard image
New cards
45

Prove using induction that Merge Sort is upperbounded by O(nlgn)

knowt flashcard image
New cards
46
term image
knowt flashcard image
New cards
47
term image
knowt flashcard image
New cards
48
term image
knowt flashcard image
New cards
49

Write out Simplified Master’s Theorem

knowt flashcard image
New cards
50
New cards
51
term image
knowt flashcard image
New cards
52

Runtime of Deterministic QuickSort Algo

O(n²)

New cards
53

Deterministic QuickSort Algorithm

knowt flashcard image
New cards
54

Prove Running Time & Recurrence of Deterministic QuickSort

knowt flashcard image
New cards
55
term image
knowt flashcard image
New cards
56
<p>Design an Algo</p>

Design an Algo

<p></p>
New cards
57
<p>Prove runtime analysis for Counting Inversions</p>

Prove runtime analysis for Counting Inversions

knowt flashcard image
New cards
58

Running time of Closest Pair Algorithm

O(nlgn)

New cards
59
60
term image
knowt flashcard image
New cards
61
term image
knowt flashcard image
New cards
62
term image
knowt flashcard image
New cards
63
term image
knowt flashcard image
New cards
64

runtime of quicksort using select as pivot

worst case O(nlgn)

New cards
65

partition runtime

O(n)

New cards
66

Select runtime

O(n)

New cards
67

select algorithm

knowt flashcard image
New cards
68

Proof of runtime of select

New cards
69

Integer Multiplication Algorithm

knowt flashcard image
New cards
70

Integer Multiplication Runtime

O(n^1.59)

New cards
71

Integer Mutlipication Runtime Proof

knowt flashcard image
New cards
72

amortized analysis & class example

amortized analysis, which means that we will be finding the time-averaged cost for a sequence of operations. In other words, the amortized runtime of an operation is the time required to perform a sequence of operations averaged over all the operations performed. Let T(n) be the total time needed to perform a series of n push operations. Then the amortized time of a single push operation is T(n)/n. e.g. stacks *2

New cards
73

amortized runtime analysis of push

O(1)

New cards
74

worst case analysis of push

O(nlgn)

New cards
75
<p>Do the runtime analysis </p>

Do the runtime analysis

knowt flashcard image
New cards
76
<p>Do the runtime analysis</p>

Do the runtime analysis

knowt flashcard image
New cards
77

Stacks are

LIFO

New cards
78

Queues are

FIFO

New cards
79

New cards
80
term image
knowt flashcard image
New cards
81
term image
knowt flashcard image
New cards
82

How does the binary heap data structure work?

  • its an array where each node corresponds to an element in the array

  • we can view it as an almost complete binary tree (completely filled on all levels except the lowest which is filled from the left up to a point)

New cards
83

Max heap properties

every node i other than the root, A[Parent] >= A[i], that is, the value of a node is at most the value of its parent. Thus, the largest element in a max-heap is stored at the root, and the subtree rooted at a node contains values no larger than that contained at the node itself.

New cards
84

what is height and what is the height of a complete binary tree?

we define the height of a node in a heap to be the number of edges on the longest simple downward path from the node to a leaf, and we define the height of the heap to be the height of its root. Since a heap of n elements is based on a complete binary tree, its height is floor(lgn)

New cards
85

What is the index of the parent, left child, and right child of a binary tree?

knowt flashcard image
New cards
86

What’s the difference between A.length and A.heapsize?

for the heap array A, we store two properties: A.length, which is the number of elements in the array, and A.heapsize, which is the number of array elements that are actually part of the heap. Even though A is potentially filled with numbers, only the elements in A[1..A.heapsize] are actually part of the heap.

New cards
87

What are the indices of the leaves in a binary heap? How many leaves?

The leaves of the heap are the nodes indexed by bn/2c + 1, bn/2c + 2, ..., n, so there are ∼ n/2 = O(n) elements which are at the leaves.

New cards
88

What is Max-Heapify and its running time?

It maintains the Max-Heap Property, O(lgn)

New cards
89

What is Build-Max-Heap and its running time?

Build-Max-Heap produces a max-heap from an unordered input array, O(n)

New cards
90

What is Heapsort and its running time?

A sorting algorithm, O(nlgn)

New cards
91

What is the running time of Max-Heap Insert, Heap-Extract-Max, Heap-Increase-Key, Heap_Maximum?

O(lgn)

New cards
92

What is the Max-Heapify Algo?

knowt flashcard image
New cards
93
<p>What is the running time of max-heapify?</p>

What is the running time of max-heapify?

knowt flashcard image
New cards
94

Build Heap Algorithm

knowt flashcard image
New cards
95
<p>Correctness of Build Max Heap</p>

Correctness of Build Max Heap

New cards
96

Runtime of Build-Max-Heap

New cards
97

How does HeapSort work?

New cards
98

What is Heap-Maximum in Priority Queues and its running time?

New cards
99

What is Heap-Extract-Max and its running time?

knowt flashcard image
New cards
100

What is Heap-Increase-Key and its running time?

New cards

Explore top notes

note Note
studied byStudied by 344 people
752 days ago
5.0(2)
note Note
studied byStudied by 5 people
815 days ago
5.0(1)
note Note
studied byStudied by 138 people
970 days ago
5.0(1)
note Note
studied byStudied by 16 people
691 days ago
5.0(2)
note Note
studied byStudied by 35 people
861 days ago
5.0(1)
note Note
studied byStudied by 16 people
720 days ago
5.0(1)
note Note
studied byStudied by 31 people
521 days ago
5.0(1)
note Note
studied byStudied by 15 people
741 days ago
5.0(2)

Explore top flashcards

flashcards Flashcard (33)
studied byStudied by 9 people
757 days ago
5.0(1)
flashcards Flashcard (20)
studied byStudied by 4 people
543 days ago
5.0(3)
flashcards Flashcard (22)
studied byStudied by 57 people
708 days ago
4.5(2)
flashcards Flashcard (50)
studied byStudied by 5 people
554 days ago
5.0(1)
flashcards Flashcard (42)
studied byStudied by 12 people
485 days ago
5.0(1)
flashcards Flashcard (33)
studied byStudied by 1 person
694 days ago
5.0(1)
flashcards Flashcard (31)
studied byStudied by 23 people
780 days ago
5.0(1)
flashcards Flashcard (54)
studied byStudied by 18568 people
709 days ago
4.5(362)
robot