csc data structures exam 2

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/7

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

8 Terms

1
New cards

Stack

super-unfair – new items go on top AND we process off the top – recursion works like this (the bottom is the oldest recursive call) which is big

you want to use linked lists unless a case can be made for an array

Array is an implementation you can use for both

2
New cards

Queue

new items go in the back, items to process come off the front – this is very fair and simulates waiting in line for your turn

you want to use linked lists unless a case can be made for an array

Array is an implementation you can use for both

3
New cards

Circular Arrays II

Very common one where we are cycling through some data and don’t want to have to detect the tail -Or representing something like an analog clock

When you want to increase a counter (say, the next open spot) in an array of length n, do %n at the end!

4
New cards

ArrayQueue

Uses a circular array that “unwinds” on making a bigger array (ensureCapacity)

5
New cards

Preorder Traversal

root, left, right

6
New cards

Post order traversal

left, right, root

7
New cards

In order traversal

left, root, right

8
New cards

Heaps

-Always O(logn)

-Always complete

-Min() – O(1) to find min at top of heap

-Insert() – O(logn) as you put it at the bottom then heapify up

-Remove() – O(logn) as you swap the root with the last note, heapify down