Summary

This document reviews fundamental concepts in data structures and algorithms, covering topics such as loops, stacks, queues, binary trees, sorting algorithms, and recursion. It also includes examples of expressions, triangular numbers, factorials, and anagrams.

Full Transcript

 **Loop Purpose**: Loops are used to repeat a sequence of instructions.  **Stack**: A linear data structure where elements are added or removed from the top (LIFO).  **Deletion from the beginning**: In a queue, elements are removed from the front (FIFO).  **FIFO**: First In, First Out -- the...

 **Loop Purpose**: Loops are used to repeat a sequence of instructions.  **Stack**: A linear data structure where elements are added or removed from the top (LIFO).  **Deletion from the beginning**: In a queue, elements are removed from the front (FIFO).  **FIFO**: First In, First Out -- the first element added is the first one to be removed.  **Redo feature**: The redo operation in text editors works like a stack, but not all stack implementations have a redo operation.  **O(log n)**: Binary search divides the problem space in half with each step, making its time complexity logarithmic.  **Logical OR**: The operator checks if at least one operand is true.  **True**: OR operator between True and False results in True.  **Increment i by 1**: \"i++\" is a shorthand for increasing i by 1.  **Binary Tree**: A binary tree is often implemented using linked structures for efficient data organization.  **O(1)**: Inserting at the beginning of a linked list is a constant-time operation.  **Constant-time lookup**: Hash tables allow for near-constant-time access to elements using a hash function.  **Insert**: Stacks don\'t allow for arbitrary insertions; they follow a strict LIFO order.  **True**: XOR between True and False results in True.  **Stack**: A stack follows LIFO (Last In, First Out) order.  **O(n)**: In the worst case, a Binary Search Tree (BST) can be unbalanced, leading to linear time complexity for searches.  **Ascending Order**: An in-order traversal of a BST visits nodes in ascending order.  **MergeSort**: MergeSort has the best worst-case time complexity of O(n log n).  **O(n log n)**: QuickSort on average performs in O(n log n) time.  **Linear Probing**: A method to resolve hash collisions by checking the next available slot.  **Double the size**: When the load factor exceeds a threshold, hash tables are often resized to maintain performance.  **BFS**: Breadth-First Search is the algorithm that guarantees the shortest path in an unweighted graph.  **Dijkstra\'s Algorithm**: Used for finding the shortest path in a weighted graph.  **Explores all neighbors**: DFS explores nodes in depth before backtracking, but doesn\'t guarantee the shortest path.  **O(n)**: Inserting into a BST in the worst case is O(n), when the tree is unbalanced.  **Expressions**: Expressions consist of operands (values or variables) and operators (like +, -, \*, etc.) to form computations.  **Triangular Numbers**: The sum of numbers arranged in an equilateral triangle. The nth triangular number is the sum of the first n integers.  **Recursion**: A method where a function calls itself. It often involves solving smaller instances of the problem.  **Factorial**: The product of all positive integers from 1 to a given number (e.g., 5! = 5 \* 4 \* 3 \* 2 \* 1).  **Anagrams**: A word formed by rearranging the letters of another word (e.g., \"stop\" and \"pots\").  **Tower of Hanoi**: A classic puzzle involving three pegs and disks of different sizes, where you move the entire stack to the last peg.  **Linear Recursion**: Involves a single call to the function within each call.  **Binary Recursion**: The function calls itself twice in each run.  **Merge Sort**: A divide-and-conquer algorithm that requires extra memory for the temporary array during sorting.  **Nested Recursion**: A function where the recursive call itself contains a recursive function.  **Mutual Recursion**: Two or more functions calling each other recursively.  **Primitive and Non-primitive**: Data structures are categorized into primitive (like integers, floats) and non-primitive (like arrays, lists).  **Tree and Graph**: Non-linear data structures, where elements are stored in hierarchical or networked ways.  **Array**: A static data structure that stores elements of the same type in a fixed-size sequential block of memory.  **Integer and Float**: Primitive data types that represent numerical values.  **Postfix Notation**: A mathematical notation where operators come after operands (e.g., 3 4 +).  **Data Structure**: Refers to how data is organized and stored in memory.  **Abstract Data Type**: A model for data types where the implementation is abstracted from the user.  **Abstract Data Type**: It separates the logical view of data from its physical implementation.  **Data Type**: Defines a set of values and the operations that can be performed on them (e.g., int, float).  **If-else statement**: It is a control flow statement, not a basic data structure algorithm.  **O(n)**: Inserting into an array may require shifting elements in the worst-case scenario.  **Logical AND**: The operator checks if both operands are true.  **False**: AND operator between True and False results in False.  **Repeat-until loop**: Not a standard for loop structure.

Use Quizgecko on...
Browser
Browser