text
stringlengths
2
2.33k
source
stringclasses
826 values
matching : problem of searching for a text pattern within a document
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
merge sort : canonical divide and conquer algorithm for comparison sorting
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
minimum spanning tree : problem of finding a lowest-cost way to connect all the vertices to each other
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
model of computation : rules of the underlying computer that is ultimately responsible for executing the algorithm
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
node : represents an element in a tree or graph
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
nondeterministic algorithm : special kind of Turing machine, which at each step can non-deterministically choose which instruction to execute and is considered to successfully find a solution if any combination of these nondeterministic choices leads to a correct solution
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
nondeterministic polynomial (NP) time complexity class : all problems that can be solved in polynomial time by a nondeterministic algorithm
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
NP-complete : all the hardest NP problems—the combinatorial problems for which wedo nothave deterministic polynomial-time algorithms
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
order of growth : geometric prediction of an algorithm’s time or space complexity as a function of the size of the problem
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
perfectly balanced : for every node in the binary search tree, its left and right subtrees contain the same number of elements
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
polynomial (P) time complexity class : all problems that have runtimes described with a polynomial expression such as O(1), O(logN), O(N), O(NlogN), O(N2), O(N3)
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
Prim’s algorithm : greedy algorithm that maintains a priority queue of vertices in the graph ordered by connecting edge weight
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
priority queue : represents a collection of elements where each element has an associated priority value
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
problem : task with specific input data and output data corresponding to each input
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
problem model : simplified, abstract representation of a more complex real-world problem
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
program : realization or implementation of an algorithm written in a formal programming language
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
quicksort algorithm : recursively sorts data by applying the binary search tree algorithm design pattern to partition data around pivot elements
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
reachable vertex : vertex that can be reached if a path or sequence of edges from the start vertex exists
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
reduction algorithm : solves problems by transforming them into other problems
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
representation : particular way of organizing a collection of elements
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
root node : node at the top of the tree
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
runtime analysis : study of how much time it takes to run an algorithm
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
search tree property : requires that elements in the tree are organized least-to-greatest from left-to-right
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
searching : problem of retrieving a target element from a collection of elements
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
sequential search algorithm : searching algorithm that sequentially checks the collection element-by-element for the target
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
set : represents an unordered collection of unique elements and allows adding, retrieving, and removing elements from the set
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
shortest path : problem of finding a lowest-cost way to get from one vertex to another
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
shortest paths tree : output of the shortest paths problem, the lowest-cost way to get from one vertex to every other reachable vertex in a graph
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
sorting : problem of rearranging elements into a logical order
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
space complexity : formal measure of how much memory an algorithm requires during its execution as it relates to the size of the problem
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
step : basic operation in the computer, such as looking up a single value, adding two values, or comparing two values
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
string problem : computational problem involving text or information represented as a sequence of characters
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
subproblem : smaller instance of a problem that can be solved independently
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
time complexity : formal measure of how much time an algorithm requires during execution as it relates to the size of the problem
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
tractable : problems that computers can solve in a reasonable amount of time
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
traveling salesperson problem (TSP) : problem of, given the path cost of every pair of vertices, finding the lowest-cost tour, or path from a start vertex visiting every vertex in the graph once including a return to the start vertex
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
traversal : problem of exploring all the vertices in a graph
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
tree : hierarchical data structure
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
Turing machine : abstract model of computation for executing any computer algorithm
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
unweighted shortest path : problem of finding the shortest paths in terms of the number of edges
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
vertex : represents an element in a graph or special type of it such as a tree
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
weighted shortest path : problem of finding the shortest paths in terms of the sum of the edge weights
https://openstax.org/books/introduction-computer-science/pages/3-key-terms
Data structures represent complex data types for solving real-world problems. Data structures combine specific data representations with specific functionality.
https://openstax.org/books/introduction-computer-science/pages/3-summary
Abstract data types categorize data structures according to their functionality and ignore differences in data representation. Abstract data types include lists, sets, maps, priority queues, and graphs.
https://openstax.org/books/introduction-computer-science/pages/3-summary
To select an appropriate data structure, first select an abstract data type according to the problem requirements. Then, select an appropriate data structure implementation for the abstract data type.
https://openstax.org/books/introduction-computer-science/pages/3-summary
Linear data structures organize elements in a line, ideal for implementing the list abstract data type. Linear data structures include array lists and linked lists.
https://openstax.org/books/introduction-computer-science/pages/3-summary
Linear data structures can implement any abstract data type. The study of data structures in general focuses on opportunities to improve efficiency (in terms of execution time or memory usage) over linear data structures.
https://openstax.org/books/introduction-computer-science/pages/3-summary
Tree data structures organize elements in a hierarchy of levels defined by parent-child relationships. Trees are defined with a root node at the top of the tree, parent-child relationships between each level, and leaf nodes at the bottom of the tree.
https://openstax.org/books/introduction-computer-science/pages/3-summary
Binary search trees require that elements in the tree are organized least-to-greatest from left-to-right. Binary search trees are often used to implement the set and map abstract data types.
https://openstax.org/books/introduction-computer-science/pages/3-summary
Balanced binary search trees and binary heaps represent two approaches for avoiding the worst-case situation with binary search trees. Binary heaps are often used to implement the priority queue abstract data type.
https://openstax.org/books/introduction-computer-science/pages/3-summary
Graph data structures focus on explicitly modeling the relationships between elements. Graphs afford access not only to elements, but also to the relationships between elements.
https://openstax.org/books/introduction-computer-science/pages/3-summary
Just like how many data structures can represent the same abstract data type, many algorithms exist to solve the same problem. In algorithmic problem-solving, computer scientists solve formal problems with specific input data and output data that correspond to each input.
https://openstax.org/books/introduction-computer-science/pages/3-summary
Modeling is the process of representing a complex phenomenon such as a real-world problem as a formal problem. Modeling is about abstraction: the simplification or erasure of details so that the problem can be solved by a computer.
https://openstax.org/books/introduction-computer-science/pages/3-summary
Historically, the model of computation emphasized specialized algorithms operating on a modest model of the underlying phenomenon. Modeling is a violent but also necessary act in order to simplify the problem so that it can be solved by a computer.
https://openstax.org/books/introduction-computer-science/pages/3-summary
Searching is the problem of retrieving a target element from a collection of many elements. Sequential search and binary search are two algorithms for solving the search problem.
https://openstax.org/books/introduction-computer-science/pages/3-summary
To solve real-world problems, computer scientists compose, modify, and apply algorithm design patterns, such as search algorithms.
https://openstax.org/books/introduction-computer-science/pages/3-summary
Algorithm analysis is the study of the outputs produced by an algorithm as well as how the algorithm produces those outputs.
https://openstax.org/books/introduction-computer-science/pages/3-summary
Correctness considers whether the outputs produced by an algorithm match the expected or desired results across the range of possible inputs. Correctness is defined as a match between the algorithm and the model of the problem, not between the algorithm and the real-world.
https://openstax.org/books/introduction-computer-science/pages/3-summary
Correctness is complicated by the complexity of social relationships, power, and inequity in the real-world. Since algorithms automate processes and operate in existing power structures, they are likely to reproduce and amplify social injustice.
https://openstax.org/books/introduction-computer-science/pages/3-summary
In addition to correctness, computer scientists are also interested in complexity, or measuring the computational resources that an algorithm consumes during its execution in relation to the size of the input.
https://openstax.org/books/introduction-computer-science/pages/3-summary
Runtime analysis is a study of how much time it takes to run an algorithm. Experimental analysis is a runtime analysis technique that involves evaluating an algorithm’s runtime by recording how long it takes to run a program implementation of it.
https://openstax.org/books/introduction-computer-science/pages/3-summary
Time complexity is the formal measure of how much time an algorithm requires during execution as it relates to the size of the problem. The goal of time complexity analysis is to produce a simple and easy-to-compare characterization of the runtime of an algorithm as it relates to the size of the problem.
https://openstax.org/books/introduction-computer-science/pages/3-summary
Space complexity is the formal measure of how much memory an algorithm requires during execution as it relates to the size of the problem.
https://openstax.org/books/introduction-computer-science/pages/3-summary
Steps in time complexity analysis are to identify a metric for representing the size of the problem; to model the number of steps needed to execute the algorithm; and to formalize the model using either precise English or asymptotic notation to define the order of growth. Big O notation is the most common type of asymp...
https://openstax.org/books/introduction-computer-science/pages/3-summary
Differences in orders of growth are massive: as the input size grows, the difference between orders of growth becomes more and more vast. For problems dealing with just 1,000 elements, the time it would take to run an exponential-time algorithm on that problem exceeds the current age of the universe—whereas that same...
https://openstax.org/books/introduction-computer-science/pages/3-summary
In practice, across applications working with large amounts of data, O(N2) is often considered the limit for real-world algorithms. For algorithms that need to run frequently on large amounts of data, algorithm designers target O(N), O(logN), or O(1).
https://openstax.org/books/introduction-computer-science/pages/3-summary
Algorithmic paradigms are the common concepts and ideas behind algorithm design patterns, such as divide and conquer algorithms, brute-force algorithms, greedy algorithms, and reduction algorithms.
https://openstax.org/books/introduction-computer-science/pages/3-summary
Divide and conquer algorithms break down a problem into smaller subproblems (divide), recursively solve each subproblem (conquer), and then combine the result of each subproblem to inform the overall solution. Recursion is an algorithm idea fundamental to divide and conquer algorithms that solves complex problems by di...
https://openstax.org/books/introduction-computer-science/pages/3-summary
Binary search is an example of divide and conquer algorithm with a single recursive subproblem. Merge sort is an example of a divide and conquer algorithm with two recursive subproblems.
https://openstax.org/books/introduction-computer-science/pages/3-summary
Brute-force algorithms solve combinatorial problems by systematically enumerating all potential solutions in order to identify the best candidate solution. Combinatorial problems identify the best candidate solution out of a space of many potential solutions.
https://openstax.org/books/introduction-computer-science/pages/3-summary
Brute-force algorithms exist for every combinatorial problem, but they are not typically used in practice because of long run time issues. To enumerate all potential solutions, a brute-force algorithm must generate every possible combination of the input data.
https://openstax.org/books/introduction-computer-science/pages/3-summary
Greedy algorithms solve combinatorial problems by repeatedly applying a simple rule to select the next element to include in the solution. Unlike brute-force algorithms that solve combinatorial problems by generating all potential solutions, greedy algorithms instead focus on generating just one solution.
https://openstax.org/books/introduction-computer-science/pages/3-summary
Greedy algorithms are not always guaranteed to compute the best solution depending on the assumptions and goals of the problem. A greedy algorithm for the interval scheduling problem will not compute the correct result if we choose to complete the shortest tasks.
https://openstax.org/books/introduction-computer-science/pages/3-summary
Kruskal’s algorithm and Prim’s algorithm are two examples of greedy algorithms for the minimum spanning trees problem. These algorithms are a rare example of a greedy algorithm that is guaranteed to compute the correct result.
https://openstax.org/books/introduction-computer-science/pages/3-summary
Reduction algorithms solve problems by transforming them into other problems. In other words, reduction algorithms delegate most of the work of solving the problem to another algorithm meant for a different problem.
https://openstax.org/books/introduction-computer-science/pages/3-summary
Reduction algorithms allow algorithm designers to rely on optimized canonical algorithms rather than designing a solution by composing algorithm design patterns, which can lead to performance or correctness bugs. Reduction algorithms also enable computer scientists to make claims about the relative difficulty of a prob...
https://openstax.org/books/introduction-computer-science/pages/3-summary
Data structure problems focus on the storage and retrieval of elements for implementing abstract data types such as lists, sets, maps, and priority queues. Data structure problems include sorting, searching, and hashing.
https://openstax.org/books/introduction-computer-science/pages/3-summary
Searching is the problem of retrieving a target element from a collection of elements. Searching in a linear data structure such as an array list can be done using either sequential search or binary search.
https://openstax.org/books/introduction-computer-science/pages/3-summary
Sorting is the problem of rearranging elements into a logical order, typically from least-valued (smallest) to greatest-valued (largest). Sorting is a fundamental problem not only because of the tasks that it directly solves, but also because it is a foundation for many other algorithms such as the binary search algori...
https://openstax.org/books/introduction-computer-science/pages/3-summary
Merge sort and quicksort are two examples of divide and conquer algorithms for sorting. Heapsort is a sorting algorithm that relies on adding to a heap and then repeatedly removing each element in sorted order.
https://openstax.org/books/introduction-computer-science/pages/3-summary
Hashing is the problem of assigning a meaningful integer index (hash value) for each object. Hash tables are a data structure for implementing sets and maps by applying the concept of hashing.
https://openstax.org/books/introduction-computer-science/pages/3-summary
Graph problems include a wide variety of problems involving the graph data type. Graph problems include traversal, minimum spanning trees, and shortest paths.
https://openstax.org/books/introduction-computer-science/pages/3-summary
Traversal is the problem of exploring all the vertices in a graph. Depth-first search and breadth-first search are both graph traversal algorithms that expand outward from a start vertex, ultimately visiting every reachable vertex.
https://openstax.org/books/introduction-computer-science/pages/3-summary
Minimum spanning trees is the problem of finding a lowest-cost way to connect all the vertices to each other, where cost is the sum of the selected edge weights. The two canonical greedy algorithms for finding a minimum spanning tree in a graph are Kruskal’s algorithm and Prim’s algorithm.
https://openstax.org/books/introduction-computer-science/pages/3-summary
Shortest paths is the problem of finding a lowest-cost way to get from one vertex to another. The output of a shortest paths algorithm is a shortest paths tree from the start vertex to every other vertex in the graph.
https://openstax.org/books/introduction-computer-science/pages/3-summary
Breadth-first search computes the unweighted shortest paths tree, the shortest paths in terms of the number of edges. Dijkstra’s algorithm computes the weighted shortest paths tree, the shortest paths in terms of the sum of the edge weights.
https://openstax.org/books/introduction-computer-science/pages/3-summary
Problem modeling is constrained by the model of computation, or the rules of the underlying computer that is ultimately responsible for executing the algorithm. Combinatorial explosion poses a problem for computer algorithms because our model of computation assumes computers only have a single thread of execution and o...
https://openstax.org/books/introduction-computer-science/pages/3-summary
A Turing machine is an abstract model of computation for executing any computer algorithm. A Turing machine describes computers in terms of three key ideas: a memory bank, an instruction table, and a program counter.
https://openstax.org/books/introduction-computer-science/pages/3-summary
Although today’s computers are much more efficient than the first computers that realized the Turing machine, most computers still rely on the same fundamental assumptions about how to execute algorithms. Even as computers become faster over time inefficient algorithms still cannot be used to solve any problems large...
https://openstax.org/books/introduction-computer-science/pages/3-summary
The complexity of a problem is the complexity (i.e., the time or memory resources required) of the most efficient algorithms for solving the problem. In this chapter, we have focused on solving problems known to have polynomial time algorithms that can be described with a polynomial expression such as O(1), O(log N), O...
https://openstax.org/books/introduction-computer-science/pages/3-summary
Nondeterministic polynomial (NP) time complexity class refers to all problems that can be solved in polynomial time by a nondeterministic algorithm. A nondeterministic algorithm is a kind of algorithm that can rely on the special power of exploring infinitely many possible “alternate universes” in order to complete...
https://openstax.org/books/introduction-computer-science/pages/3-summary
Technically, all P problems are also NP problems because we already have deterministic algorithms for solving them and therefore do not need to rely on the special power of nondeterminism. NP-complete refers to all the hardest NP problems—the combinatorial problems for which we do not have deterministic polynomial-ti...
https://openstax.org/books/introduction-computer-science/pages/3-summary
Longest paths and the traveling salesperson problem (TSP) are two well-known examples of NP-complete problems. What makes both these problems difficult is that we do not have a simple rule for selecting the next element to include in the solution.
https://openstax.org/books/introduction-computer-science/pages/3-summary
All NP-complete problems can be reduced to all the others, so an algorithm for solving any NP-complete problem solves every NP-complete problem. The question of P versus NP asks whether it is possible to design a deterministic polynomial-time algorithm for solving any—and therefore all—of these NP-complete problems...
https://openstax.org/books/introduction-computer-science/pages/3-summary
Most theoretical computer scientists believe that it is impossible to design an efficient algorithm for longest paths, TSP, or any other NP-complete problems. An efficient algorithm for any one NP-complete problems would not only directly solve routing and logistics problems but would also enable massive advancements i...
https://openstax.org/books/introduction-computer-science/pages/3-summary
abstract model : technique that derives simpler high-level conceptual models for a computer while exploring the science of what new algorithms can or cannot do
https://openstax.org/books/introduction-computer-science/pages/4-key-terms
allocated memory : memory region set aside to hold a value
https://openstax.org/books/introduction-computer-science/pages/4-key-terms
archive file : .afile that contains a static library
https://openstax.org/books/introduction-computer-science/pages/4-key-terms
Arduino : hardware platform intended for creating simple, low-cost hardware for educational or hobbyist purposes
https://openstax.org/books/introduction-computer-science/pages/4-key-terms
assembler : program that translates assembly language source code into machine code
https://openstax.org/books/introduction-computer-science/pages/4-key-terms