


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A concise overview of key concepts related to recursion, trees, and algorithm efficiency, particularly within the context of computer science. It covers fundamental topics such as recursion strategies, tail and non-tail recursion, and the trade-offs between recursion and iteration. The document also delves into tree data structures, including various types of trees (binary tree, binary search tree) and traversal methods (depth-first, breadth-first). Furthermore, it touches on algorithm efficiency, asymptotic analysis, and big-o notation, offering a foundational understanding of these essential concepts. This material is suitable for students learning data structures and algorithms, providing a quick reference to important definitions and properties. It also includes examples of recursion and its applications, such as array searching and factorial calculation. Designed to aid in exam preparation and concept reinforcement.
Typology: Exams
1 / 4
This page cannot be seen from the preview
Don't miss anything!



Recursion - Correct Answer-A strategy for solving problems where a method calls itself Recursion relies on the runtime call stack 'every method invocation gets its own stack space Tail recursion - Correct Answer--Single recursive call thats the last thing performed in the method 'can easily be turned into a loop Non-tail recursion - Correct Answer--The recursive call are not performed last in the method Recursion vs. Iteration - Correct Answer--Iterative are more efficient 'b/c it avoids the overhead recursive method calls -Recursive algorithms 'have higher overhead 'sometimes simpler 'are natural for backtracking searches 'suited for recursive data structures Trees - Correct Answer--Recursive data structure that have a one-to-many relationship between elements Root - Correct Answer-No parent Leaf - Correct Answer-No children Interior Nodes - Correct Answer-A node with at least one child Siblings - Correct Answer-Have same parent Descendants - Correct Answer-Reachable by repeated proceeding from parent to child Subtree - Correct Answer-A tree whose root is a child Level - Correct Answer-a measure of a node's distance from the root Height (or Depth) - Correct Answer-the maximum level of any node in the tree Binary Tree - Correct Answer-a tree with at most two children per node
Depth-First Traversal (DFS) - Correct Answer-visits nodes as far ahead as possible before backing up Preorder Traversal - Correct Answer-visits a parents node before its left and right children Inorder Traversal - Correct Answer-visits nodes in the order left child, parent, right child Postorder Traversal - Correct Answer-visits a parents node's left and right children before the parents node itself Breadth-Frist Traversal (BFS) - Correct Answer-visits nodes according to how far away they are from the root Balanced Binary Tree - Correct Answer-has mostly two children per node Degenerate Binary Tree - Correct Answer-has mostly one child per node Binary Search Tree (BST) - Correct Answer-a binary tree with the property that the value in every node is larger than all the values in its left subtree, and smaller than all the values in its right subtree Polymorphic Binary Search Tree - Correct Answer-a tree could be an interface, or a superclass. Implement two subclasses, EmptyTree, NoneEmptyTree EmptyTree - Correct Answer-to represent an empty tree or subtree, rather than null Singleton Pattern - Correct Answer-This class provides a way to access its only object which can be accessed directly without need to instantiate the object of the class. Benchmarking - Correct Answer-A way to measure efficiency Algorithm efficiency - Correct Answer-Amount of resources used by an algorithm Asymptotic analysis - Correct Answer-Mathematically analyze an algorithm's efficiency, and express its running time as a function of the input size (n) Big-O notation - Correct Answer-Time is on the order of some function T(n) -O( T(n) ) Upper bound on the number of steps performed by an algorithm Benchmarking vs. Asymptotic analysis - Correct Answer-Benchmarking -precise information Asymptotic analysis
-big-Θ is when the f(n) is O(g(n)) and g(n) is O(f(n)) -BEST possible asymptotic solution Set data structures - Correct Answer-No relationship between the elements being stored Example of Recursion Factorial - Correct Answer-... Example of Recursion Array Search - Correct Answer-... Properties of Recursion - Correct Answer--Recursion relies on the runtime call stack -Any problem solvable with iteration can be solved with recursion, and vice versa Types of Recursion - Correct Answer--No-tail Recursion -Tail Recursion Example of Recursion Sum of Array - Correct Answer-... Auxiliary Method / Helper Method - Correct Answer-method that is actually recursive Wrapper Method - Correct Answer-the method only purpose is to call the recursive method and return its result