More Data Structures

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

1/20

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.

21 Terms

1
New cards

Value semantics and reference semantics

refer to how parameters are passed to a function

2
New cards

Value semantics

Behavior where variables store a value. When a
variable is passed as a parameter, the value of the actual parameter is
copied into the formal parameter.

3
New cards

Reference semantics

Behavior where variables store memory addresses
or locations of objects. When a reference is assigned or passed as a
parameter, the formal parameter refers to the same object as the actual
parameter.

4
New cards

variables of type… store values directly

ints, floats, booleans, strings, tuples

5
New cards

variables of object types store references to memory

lists, dictionaries, sets, panels

6
New cards

mutability

the ability to be changed or mutated

7
New cards

Immutable variables

ints, floats, strings, bools, tuples

8
New cards

Operations that try to change the value of an immutable object…

create a new object

9
New cards

Operations that change the value of a mutable object…

can change the object

10
New cards

Immutable

quicker to access, fundamentally expensive to “change” because doing so involves creating a new copy.

11
New cards

Mutable

relatively cheap to change because you are not creating a new copy

12
New cards

Lists and DrawingPanel

are mutable

13
New cards

Why are lists and objects mutable?

Efficiency and sharing

14
New cards

Efficiency

copying large objects slows down a program

15
New cards

Sharing

it’s useful to share an object’s data among functions

16
New cards

When a mutable object is passed as a parameter…

the function can change it

17
New cards

If the parameter is modified…

it will affect the original object

18
New cards

Lists are mutable

true

19
New cards

swap_all

accepts two lists of integers as parameters and swaps their entire contents. Assumes two lists are the same length.

20
New cards

Tuples are similar to a list but __ be altered

cannot (i.e., immutable)

21
New cards

Tuples

goods for storing related data.