Recursive / Lists Flashcards

1
Q

What is a base case?

A

The most simplest form of the recursive problem. The condition that causes the method to end.

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

What is the recursive case?

A

The steps that an algorithm takes to make the problem one step smaller and move towards the base case.

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

What is recursion?

A

When a code calls itself in its code.

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

What are data structures?

A

A combination of multiple values.

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

What are linked lists?

A

A data structure that stores a sequence of elements.

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

What are the parts of a linked list?

A

Each element is called a node.
The first node is called the head.
The last node is called the tail.

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

What does each node have?

A

A value
A reference to the next node in the list

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

first

A

Takes the first node of a list

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

rest

A

Results in a list of everything but the head.

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

How do you use build-list?

A

(build-list
number of elements in the list
function applied to each number)

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

length

A

counts the number of elements

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

list-ref

A

extract by position
(list-ref (list 1 2 3) 0) -> 1

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

append

A

combines lists together from left to right

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

reverse

A

puts a list in reverse order

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

member

A

Checks a list for an element. Comes out #f if not found. If found, a list is created with every node after it in the list.

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

How do you use filter?

A

(filter
function
list)

17
Q

What is foldl?

A

Applies a function to nodes from left to right

18
Q

How do you use foldl?

A

(foldl function start-value list)

19
Q

What is foldr?

A

Foldl but lists lists from right to left.

20
Q

How do you use map?

A

(map function list)

21
Q

map

A

A function used to apply a function to each element of one or more lists
Results in a list

22
Q

What does car do?

A

Returns the first item in a list
Error if the list is empty

23
Q

What does cdr do?

A

Returns a LIST of everything but the first node
Returns an error if the list is empty

24
Q

Do you do car or cdr first if you see them combined?

A

cdr

25
Q

How many cdr’s can you abbreviate together?

A

5

26
Q

What is a constructor?

A

Creates a new object, like a list object

27
Q

cons

A

means “construct”
returns a list of two arguments combined
puts the first argument as the head

28
Q

Difference between cons and built-list

A

built-list relies on a function.