Here are concise definitions (2 sentences or less) for each term:
Algorithm efficiency describes how well an algorithm performs in terms of time and space as the input size grows. It helps evaluate the scalability of the solution.
A growth function shows how the running time or space of a program increases with input size nn. It helps measure algorithm performance.
Asymptotic complexity focuses on how an algorithm behaves as the input size approaches infinity. It ignores constants and lower-order terms.
Big-O notation gives the worst-case upper bound on an algorithm's growth rate. It simplifies complexity expressions to their most significant term.
Big-O categories include O(1)O(1), O(logn)O(\log n), O(n)O(n), O(nlogn)O(n \log n), O(n2)O(n^2), etc. Each represents a class of algorithm efficiency based on input growth.
Growth functions are compared by analyzing which grows faster as nn becomes very large. For instance, O(n)O(n) is more efficient than O(n2)O(n^2) for large inputs.
Single loops typically contribute O(n)O(n) time, while nested loops multiply their complexities (e.g., two nested loops = O(n2)O(n^2)). Loop structure directly affects algorithm efficiency.
An ADT defines a logical data model and operations, independent of implementation. Examples include Stack, Queue, and List.
A stack is a Last-In-First-Out (LIFO) structure. Items are added and removed from the top only.
Linear collections (like arrays and lists) store data in sequence. Non-linear collections (like trees and graphs) organize data hierarchically or through connections.
Main stack operations include push()
to add, pop()
to remove, peek()
to view the top, and isEmpty()
to check if it's empty.
Stacks can be implemented using arrays or linked lists, each affecting performance and memory usage. The implementation hides underlying structure from the user.
Standard stack operations: push (add), pop (remove), peek/top (view top item), isEmpty (check if empty), isFull (check if full, for arrays).
Stacks are useful in undo features, parsing expressions, recursion support, and backtracking algorithms.
Linked structures store elements as nodes, each with data and references to other nodes. They enable dynamic memory allocation and flexible insertions/deletions.
A linked list is a linear data structure with nodes connected via pointers. Types include singly, doubly, and circular linked lists.
A queue is a First-In-First-Out (FIFO) structure. Items are added at the rear and removed from the front.
Basic queue operations are enqueue
(insert), dequeue
(remove), peek
(front view), isEmpty
, and isFull
.
Queues can be implemented using arrays, linked lists, or circular buffers to manage overflow efficiently.
A list is an ordered collection of elements where duplicates are allowed. Elements can be accessed by index.
Java provides: ArrayList
(resizable array), LinkedList
(doubly-linked), and Vector
(synchronized array).
Java's LinkedList
class implements List and Deque interfaces, supporting efficient insertions/deletions at both ends.
Recursion is when a method calls itself to solve a smaller instance of the same problem.
Recursive definitions specify rules to define an object in terms of itself (e.g., factorial: n!=n⋅(n−1)!n! = n \cdot (n-1)!).
Occurs when a recursive function lacks a base case, causing it to call itself indefinitely, often resulting in a stack overflow.
Mathematical recursion defines functions like factorial, Fibonacci, or powers using previous values.
In programming, recursion simplifies problems like tree traversal, but requires a base case to prevent infinite loops.
Recursion is elegant but may use more memory (stack frames), while iteration is usually more efficient in space.
A simple search that checks each element one by one. Time complexity: O(n)O(n).
Searches a sorted array by repeatedly dividing it in half. Time complexity: O(logn)O(\log n).
Binary search is faster than linear search for sorted data. Linear search is better for unsorted or small lists.
Sorting arranges elements in a defined order (e.g., ascending). It helps improve search and data organization.
Repeatedly finds the minimum and places it in the correct position. Time complexity: O(n2)O(n^2).
Builds the sorted array one item at a time by inserting elements into their correct position. Time complexity: O(n2)O(n^2).
Divide-and-conquer algorithm that splits, sorts, and merges. Time complexity: O(nlogn)O(n \log n).
Merge sort is faster for large data; selection/insertion sorts are easier but inefficient for large inputs.
Trees are hierarchical structures with a root and child nodes. Each node can have multiple children.
A tree is a connected acyclic graph. One node is the root, and all others are reachable from it.
Includes height, depth, level, degree, and number of nodes. A tree with nn nodes has n−1n-1 edges.
Important terms: root, parent, child, sibling, leaf, internal node, height, depth, subtree.
A binary tree is a tree where each node has at most two children (left and right).
Includes full, complete, perfect, balanced binary trees. Each has structural rules.
A balanced binary tree maintains minimal height to ensure O(logn)O(\log n) performance in operations.
In a Binary Search Tree, left child < parent < right child. Enables efficient searching and sorting.
This algorithm splits the sorted array in half at each step. Time complexity: O(logn)O(\log n).
Tree traversal visits each node: preorder (root-left-right), inorder (left-root-right), postorder (left-right-root).
Preorder: visit node → left → right
Inorder: left → visit node → right
Postorder: left → right → visit node
Use recursion to implement traversals. Each method processes the tree in a different node visitation order.
Insert numbers one by one using BST rules (left if smaller, right if greater).
A graph is a collection of nodes (vertices) and connections (edges). Can be directed/undirected and weighted/unweighted.
Terms: vertex, edge, path, cycle, degree, adjacency, connected, directed/undirected, weighted/unweighted.
Graphs are represented by adjacency lists, adjacency matrices, or edge lists.
DFS (Depth-First Search) explores as deep as possible before backtracking.
BFS (Breadth-First Search) explores neighbors level-by-level.
They generate different visit sequences depending on structure.
Would you like me to export this into Knowt or Quizlet format next?