Data Struct operations Flashcards

1
Q

Avg. Access Array

A

O(1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Avg. Search Array

A

0(n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Avg. Insertion Array

A

O(n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Avg. Deletion Array

A

O(n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Avg. Access Singly Linked List

A

O(n) - have to loop to n

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Avg. Search Singly Linked List

A

O(n) - have to loop to n

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Avg. Insertion Singly Linked List (insert @ end)

A

O(1) - add a new node/ append to end

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Avg. Insertion Singly Linked List (insert @ index)

A

O(n) - have to loop to index, then insert value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Avg. Delete Singly Linked List (delete @ end)

A

O(1) - delete the end node

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Avg. Delete Singly Linked List (delete @ index)

A

O(n) - have to loop to index, then delete value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Hash Table Access

A

O(1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Hash Table Search

A

O(1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Hash Tabe Insert

A

O(1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Hash Table Delete

A

O(1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Adavantages of Linked List

A
  • have a constant insert and delete (only at ends)
  • good if you don’t know how many items are in list
  • if you don’t need random access
  • you need to insert in the middle of a list.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Dis advantages of Linked List

A
  • no random access
  • if you know the number of elements in the list ahead
    of time
  • memory is a concern (Linked lists require pointers to next data value. While arrays just store the value itself
  • need speed to iterate through a list
17
Q

Find in Binary Search Tree (best)

A

O(1) - item is located at the root

18
Q

Find in Binary Search Tree (avg)

A

O(log n) - divides amount of work each time by 2

19
Q

Find in Binary Search Tree (worst)

A

O(n) - this is in the case that tree isn’t balanced, or the shape is irregular. So the tree could go through many uncessary steps

20
Q

Find in Balanced Binary Search (best)

A

O(1) - item is located at the root

21
Q

Find in Balanced Binary Search (avg)

A

O(log n)

22
Q

Find in Balanced Binary Search (worst)

A

O(log n)

23
Q

Equation to determine if BST is balanced

A

heightOfLeftSideOfTree - heightOfRightSideOfTree = 1