Arrays Flashcards

1
Q
space	\_\_\_
lookup	\_\_\_
append	\_\_\_
insert	\_\_\_
delete	\_\_\_
A
space	O(n)
lookup	O(1)
append	O(1)
insert	O(n)
delete	O(n)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Two strengths of an array

A
  1. Fast lookups

2. Fast appends

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

Two weaknesses of an array

A
  1. Fixed-size

2. Costly inserts and deletes

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

Function in Java to slice an array

A

Arrays.copyOfRang( arr, startIndex, endIndex)

where endIndex is exclusive

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

Arrays are passed by ____.

A

Reference

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