Recursive / Lists Flashcards
What is a base case?
The most simplest form of the recursive problem. The condition that causes the method to end.
What is the recursive case?
The steps that an algorithm takes to make the problem one step smaller and move towards the base case.
What is recursion?
When a code calls itself in its code.
What are data structures?
A combination of multiple values.
What are linked lists?
A data structure that stores a sequence of elements.
What are the parts of a linked list?
Each element is called a node.
The first node is called the head.
The last node is called the tail.
What does each node have?
A value
A reference to the next node in the list
first
Takes the first node of a list
rest
Results in a list of everything but the head.
How do you use build-list?
(build-list
number of elements in the list
function applied to each number)
length
counts the number of elements
list-ref
extract by position
(list-ref (list 1 2 3) 0) -> 1
append
combines lists together from left to right
reverse
puts a list in reverse order
member
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.