Recursion/Iteration Flashcards
What is iteration and recursion an example of?
traversal
What is the difference between indirect and direct iterators?
Direct iterator traverses throw the actual data while the indirect iterator traverses through instances of the data structure
What is the purpose of recursion?
To make the code simpler
what happens after a recursive call?
The method clones itself: copied,
local variables
parameters
code
What does the base case prevent?
Infinite recursion
What is Iterable?
an interface in java.lang
What method must be implemented when using Iterable?
Iterator(), which returns an iterator object for traversing through a list: Iterator = list.iterator()
What is Iterator?
An interface in java.util
What method must be implemented when using Iterator?
- hasNext
- next
- remove(optional)
What are the fields for an indirect iterator class?
- ) A separate list data structure
2. ) Current position index
What are the fields for a direct iterator class?
- ) The fields that a list has
- an array
- numItems
2.)Current position index
Where is the reference of recursive method after a recursive call & base case detection?
after the recursive call, and before the condition, respectively
Where are the clones stored?
In the stack in the activation records
Once the method returns and breaks recursive chain what happens to the current method?
It disappears
What is the address of a method before the return address?
System