1/17
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What is recursion?
Recursion is a technique where a function or entity is defined in terms of itself, often used to break down problems into smaller subproblems.
Why use recursion?
Recursion helps simplify complex problems by breaking them into smaller, more manageable parts and solving each one individually.
What is a tree data structure?
A tree is a data structure that consists of nodes, each containing a value and references to left and right subtrees, with methods to access those values.
What is tree searching in recursion?
Tree searching in recursion involves traversing through nodes and using recursive calls to search through left and right subtrees until the value is found or absent.
What is the Java stack in recursion?
The Java stack stores a new frame for each method call, including recursive calls, which leads to multiple stack frames being created and destroyed during recursion.
What is factorial in recursion?
Factorial is a recursive function that calculates the product of an integer and all integers below it, reaching a base case to terminate the recursion.
What is a perpetual loop in recursion?
A perpetual loop in recursion occurs when a method calls itself indefinitely without a termination condition, which leads to a stack overflow error.
What is tail recursion?
Tail recursion is when the recursive call is the last action before the method returns, making it possible for certain compilers to optimise it by reusing the existing stack frame.
What is recursion vs iteration?
Recursion provides elegant, concise solutions but may be inefficient without compiler optimisation, while iteration tends to be faster and more efficient.
What is Fibonacci in recursion?
Fibonacci in recursion is an elegant but inefficient method of calculating Fibonacci numbers, where the function calls itself repeatedly for each number until reaching the base case.
What is Fibonacci in iteration?
Fibonacci in iteration is a more efficient method that uses a loop to calculate Fibonacci numbers, storing previous values to avoid redundant calculations.
What is the Eight Queens problem?
The Eight Queens problem involves placing eight queens on a chessboard so that no two queens threaten each other, typically solved using backtracking recursion.
What is backtracking in recursion?
Backtracking in recursion involves exploring possible solutions step by step, discarding invalid ones, and continuing until a valid solution is found or all options are exhausted.
What is the backtracking solution for N-Queens?
The backtracking solution for N-Queens incrementally places queens on the board, checks for safety, and recursively continues to the next row until all queens are safely placed.
What is the generate method in the backtracking solution?
The generate method in the backtracking solution recursively places queens on the board, testing each placement for safety and backtracking if a valid placement is not found.
What is the purpose of displaying a solution in backtracking?
Displaying a solution in backtracking shows the valid arrangement of queens on the board after successfully placing them without conflict.
What is the importance of checking if a queen is safe in backtracking?
Checking if a queen is safe ensures that no other queens can threaten it based on column, row, or diagonal placements, preventing invalid solutions.
What is the final backtracking solution for N-Queens?
The final backtracking solution for N-Queens uses recursion to explore all possible valid placements of queens on the board, displaying the valid configurations.