data structures : lists, sets & maps

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/41

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 6:11 PM on 3/25/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

42 Terms

1
New cards

strings are…

  • Ordered (you can look up an element using its index)

  • immutable (you can’t add, remove, or update characters)

2
New cards

what is a string

A string is an immutable sequence of characters.

3
New cards
<p><span style="background-color: transparent; font-family: &quot;Google Sans&quot;, sans-serif;">If the length of the string is n, what is the big-O time complexity of “adding” a single exclamation point to the end of a string?</span></p>

If the length of the string is n, what is the big-O time complexity of “adding” a single exclamation point to the end of a string?

O(n)

4
New cards
<p><span style="background-color: transparent; font-family: &quot;Google Sans&quot;, sans-serif;">If the number of times you want to repeat a letter is n, what is the big-O time complexity of building a string of length n using concatenation?</span></p>

If the number of times you want to repeat a letter is n, what is the big-O time complexity of building a string of length n using concatenation?

O(n²)

5
New cards

time complexity of the operation index?

fruit[0]

O(1)

6
New cards

time complexity for operation length?

len(fruit)

O(1)

7
New cards

time complexity for operation slice?

fruit[4: ]

O(k)

8
New cards

time complexity for operation concatenate ?

fruit = ‘pine’ + ‘apple’

O(m+n)

9
New cards

lists are…

  • Ordered (you can look up an element using its index)

  • Mutable (you can add, remove, or update elements)

10
New cards
<p>what is the worst case? </p>

what is the worst case?

O(n)

11
New cards
<p>what is the worst case?</p>

what is the worst case?

O(n)

12
New cards
<p>What is the worst time complexity case for these searches? </p>

What is the worst time complexity case for these searches?

O(n)

13
New cards
<p><span style="background-color: transparent; font-family: &quot;Google Sans&quot;, sans-serif;">What do you think the time complexity of TimSort is?</span></p>

What do you think the time complexity of TimSort is?

O(n)

14
New cards

What sorting algorithm do you think the built-in python sort functions use?

Timsort

15
New cards

What search algorithm do you think these functions use - linear search or binary search?

Linear search, since there’s no guarantee that the list is sorted.

16
New cards

What is a stack?

a data structure that uses the principle of “Last In First Out” - the last item to get added to the is the first item that will get removed.

17
New cards

What can you use in python if you ever need a stack?

append or pop

18
New cards

what is a queue?

is a data structure that uses the principle of “First In First Out” - the first item to get added to the is the first item that will get removed.

19
New cards

What can you use if you ever need a queue?

A python deque

append O(1)

popleft O(1)

20
New cards
<p>Which one is more optimal? </p>

Which one is more optimal?

the second one

21
New cards

What are sets

stores unique values in no particular order.

22
New cards

sets are……

  • Unordered: Elements are unordered, so they are not indexable.

  • Mutable: can be modified by adding or removing elements.

  • is unique  - there are no duplicates.

23
New cards

What are set operations time complexity avg case

O(1)

24
New cards

union

A | B

25
New cards

intersection

A & B

26
New cards

difference

A - B

27
New cards

symmetric difference

A ^ B

28
New cards

dictionaries in python are…

a collection of key-value pairs.

29
New cards

key points are

  • Unordered: The order of elements in a dictionary is not guaranteed.

  • Mutable: You can add, remove, or modify elements in a dictionary.

  • must be unique: can only appear once in a dictionary.

  • can be of any immutable data type: 

30
New cards

what are common key types

strings, numbers, and tuples.

31
New cards

what can values be?

strings, numbers, lists, dictionaries, or any other Python object.

32
New cards

dictionary operations average time case are?

O(1)

33
New cards

what is a hash function

takes as input any piece of data and returns as output an integer value in a given range.

34
New cards

Why do sets and dictionaries have O(1) operations?

Since accessing and overwriting an item at a particular index of a list is O(1), set and dictionary operations are also O(1). 

35
New cards

What are the key properties of a good hash function

  • The same input always produces the same output. This is crucial for lookups.  

  • should distribute inputs evenly across the output range to minimize collisions

  • Calculating the value should be fast.

36
New cards

what data types can be used as keys in a dictinoary?

immutable objects or user-defined objects such as strings, numbers, booleans, etc.

37
New cards

what data types can not be used as keys in a dictionary?

lists, dictionaries, sets

38
New cards
<p>is this a good key?</p>

is this a good key?

yes

39
New cards
<p>is this a good key?</p>

is this a good key?

no

40
New cards
<p>is this a good key?</p>

is this a good key?

yes

41
New cards
<p>is this a good key?</p>

is this a good key?

no

42
New cards

Explore top notes

note
GLOBAL REGENTS NOTES
Updated 645d ago
0.0(0)
note
rg4yrfgt
Updated 395d ago
0.0(0)
note
Chapter 3: Federalism
Updated 1028d ago
0.0(0)
note
The congregations in Latin
Updated 1173d ago
0.0(0)
note
Week 5 quiz
Updated 713d ago
0.0(0)
note
Enzymes
Updated 758d ago
0.0(0)
note
Japanese Term 4 Vocabulary
Updated 145d ago
0.0(0)
note
GLOBAL REGENTS NOTES
Updated 645d ago
0.0(0)
note
rg4yrfgt
Updated 395d ago
0.0(0)
note
Chapter 3: Federalism
Updated 1028d ago
0.0(0)
note
The congregations in Latin
Updated 1173d ago
0.0(0)
note
Week 5 quiz
Updated 713d ago
0.0(0)
note
Enzymes
Updated 758d ago
0.0(0)
note
Japanese Term 4 Vocabulary
Updated 145d ago
0.0(0)

Explore top flashcards

flashcards
ARKY 303 - Midterm 1
132
Updated 405d ago
0.0(0)
flashcards
German numbers 1-31
31
Updated 433d ago
0.0(0)
flashcards
HRM Prelims
196
Updated 746d ago
0.0(0)
flashcards
Unit 16: Industrial Revolution
35
Updated 1072d ago
0.0(0)
flashcards
AP Psychology Unit 0 Vocab
57
Updated 83d ago
0.0(0)
flashcards
Histology
57
Updated 1232d ago
0.0(0)
flashcards
ARKY 303 - Midterm 1
132
Updated 405d ago
0.0(0)
flashcards
German numbers 1-31
31
Updated 433d ago
0.0(0)
flashcards
HRM Prelims
196
Updated 746d ago
0.0(0)
flashcards
Unit 16: Industrial Revolution
35
Updated 1072d ago
0.0(0)
flashcards
AP Psychology Unit 0 Vocab
57
Updated 83d ago
0.0(0)
flashcards
Histology
57
Updated 1232d ago
0.0(0)