





















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






















data structure A data structure is a way of organizing, storing, and performing operations on data. record A record is the data structure that stores subitems, often called fields, with a nameassociated with each subitem.
array An array is a data structure that stores an ordered collection of elements, where eachelement is directly accessible by a positional index.
linked list A linked list is a data structure that stores an ordered list of items in nodes, where eachnode stores data and has a reference to the next node.
binary tree A binary tree is a data structure in which each node stores data and has up to twochildren, known as a left child and a right child.
hash table A hash table is a data structure that stores unordered items by mapping (or hashing) eachitem to a location in an array.
max-heap A max-heap is a tree that maintains the simple property that a node's key is greater thanor equal to the node's childrens' keys.
min-heap A min-heap is a tree that maintains the simple property that a node's key is less than orequal to the node's childrens' keys.
graph A graph is a data structure for representing connections among items, and consists ofvertices connected by edges.
vertex A vertex represents an item in a graph. edge An edge represents a connection between two vertices in a graph. algorithm An algorithm describes a sequence of steps to solve a computational problem orperform a calculation.
computational problem A computational problem specifies an input, a question about the input that can beanswered using a computer, and the desired output.
heuristic Heuristic: A technique that willingly accepts a non-optimal or less accurate solution inorder to improve execution speed.
heuristic algorithm A heuristic algorithm is an algorithm that quickly determines a near optimal orapproximate solution.
0-1 knapsack problem 0-1 knapsack problem: The knapsack problem with the quantity of each item limited to 1. self-adjusting heuristic A self-adjusting heuristic is an algorithm that modifies a data structure based on how thatdata structure is used.
greedy algorithm A greedy algorithm is an algorithm that, when presented with a list of options, choosesthe option that is optimal at that point in time.
fractional knapsack problem The fractional knapsack problem is the knapsack problem with the potential to take eachitem a fractional number of times, provided the fraction is in the range [0.0, 1.0].
activity selection problem The activity selection problem is a problem where one or more activities are available,each with a start and finish time, and the goal is to build the largest possible set of activities without time conflicts. dynamic programming Dynamic programming is a problem solving technique that splits a problem into smallersubproblems, computes and stores solutions to subproblems in memory, and then uses the stored solutions to solve the larger problem. longest common substring The longest common substring algorithm takes 2 strings as input and determines thelongest substring that exists in both strings.
list A list is a common ADT for holding ordered data, having operations like append a dataitem, remove a data item, check if a data item exists, and print the list.
singly-linked list A singly-linked list is a data structure for implementing a list ADT, where each node hasdata and a reference to the next node.
head / tail (^) A singly-linked list's first node is called the head, and the last node the tail.
positional list A singly-linked list is a type of positional list: A list where elements contain references tothe next and/or previous elements in the list.
append The singly-linked list append operation inserts a new node after the list's tail node. prepend Given a new node, the prepend operation for a singly-linked list inserts the new nodebefore the list's head node.
search Given a data value, a linked list search operation returns the first node whose data equalsthat data value, or None if no such node exists.
insert-node-after Given a new node, the insert-node-after operation for a singly-linked list inserts the newnode after a provided existing list node.
remove-node-after Given a specified existing node in a singly-linked list, the remove-node-after operationremoves the node after the specified list node.
doubly-linked list A doubly-linked list is a data structure for implementing a list ADT, where each node hasdata, a reference to the next node, and a reference to the previous node.
positional list A doubly-linked list is a type of positional list: A list where elements contain references tothe next and/or previous elements in the list.
append Given a new node, the append operation for a doubly-linked list inserts the new nodeafter the list's tail node.
prepend Given a new node, the prepend operation of a doubly-linked list inserts the new nodebefore the list's head node and assigns the head attribute with the new node.
search Given a data value, a linked list search operation returns the first node whose data equalsthat data value, or None if no such node exists.
insert-node-after Given a new node, the insert-node-after operation for a doubly-linked list inserts the newnode after a provided existing list node.
remove-node The remove-node operation for a doubly-linked list removes a provided existing listnode.
bounded stack A bounded stack is a stack with a length that does not exceed a maximum value. full A bounded stack with a length equal to the maximum length is said to be full. queue A queue is an ADT representing a collection of items in which items are inserted at theend and removed from the front.
enqueue The queue enqueue operation inserts an item at the end of the queue. dequeue The queue dequeue operation removes and returns the item at the front of the queue. first-in first-out / FIFO A queue is referred to as a first-in first-out (FIFO) ADT. bounded queue A bounded queue is a queue with a length that does not exceed a specified maximumvalue.
full A bounded queue with a length equal to the maximum length is said to be full. unbounded queue An unbounded queue is a queue with a length that can grow indefinitely. deque A deque (pronounced "deck" and short for double-ended queue) is an ADT in whichitems can be inserted and removed at both the front and back.
peek A peek operation returns an item in the deque without removing the item. Queue A Queue class is defined in the queue module and can be imported with the from queueimport Queue statement.
map / dictionary A map (or dictionary) is an ADT that associates (or maps) keys with values. insert The map insert operation takes two parameters, a key and a value. If the key does notexist in the map, the key-value pair is inserted. If the key does exist, the value is updated.
get The map get operation takes one parameter for the key and returns the associated value,or None if the key does not exist in the map.
hash code The first problem is addressed with a hash code: a non-negative integer that attempts touniquely identify a key.
hash function A hash function is a function that computes a hash code for a given value. hash table A hash table is a data structure that stores unordered items by mapping (or hashing) eachitem to a location in an array.
bucket Each hash table array element is called a bucket. hash map A hash map is an implementation of a map ADT using a hash table. collision A hash table collision occurs when two different keys map to the same bucket index. Chaining Chaining is a collision resolution technique where each bucket has a list of items (sobucket 6's list could have keys 86 and 16).
Open addressing Open addressing is a collision resolution technique where collisions are resolved bylooking for an empty bucket elsewhere in the table (so key 16 might be stored in bucket 7). Chaining Chaining handles hash table collisions by using a list for each bucket, where each liststores the items that map to that bucket.
linear probing A hash table with linear probing handles a collision by starting at the key's mappedbucket, and then linearly searches subsequent buckets until an empty bucket is found.
empty-since-start An empty-since-start bucket has been empty since the hash table was created. empty-after-removal An empty-after-removal bucket had an item removed that caused the bucket to now beempty.
quadratic probing A hash table with quadratic probing handles a collision by starting at the key's mappedbucket, and then quadratically searches subsequent buckets until an empty bucket is found.
password hash function A password hash function is a cryptographic hash function that produces a hash value fora password.
binary tree (^) In a binary tree, each node has up to two children, known as a left child and a right child. Leaf Leaf: A tree node with no children. Internal node Internal node: A node with at least one child. Root Root: The one tree node with no parent (the "top" node). Parent Parent: A node with a child is that child's parent. ancestors A node's ancestors include the node's parent, the parent's parent, etc., up to the tree'sroot.
descendants A node's descendants include the node's children, the childrens' children, etc. edge The link from a node to a child is called an edge. depth A node's depth is the number of edges on the path from the root to the node. level All nodes with the same depth form a tree level. height A tree's height is the largest depth of any node. full A binary tree is full if every node contains 0 or 2 children. complete A binary tree is complete if all levels, except possibly the last level, contain all possiblenodes and all nodes in the last level are as far left as possible.
perfect A binary tree is perfect if all internal nodes have 2 children and all leaf nodes are at thesame level.
subtree (^) A binary tree subtree is any node X in the tree and all of X's descendants.
Binary space partitioning / BSP Binary space partitioning (BSP) is a technique of repeatedly separating a region of spaceinto two parts and cataloging objects contained within the regions.
BSP tree A BSP tree is a binary tree used to store information for binary space partitioning. binary search tree / BST A binary search tree (BST), which has an ordering property that each node's key is > allkeys in the node's left subtree and < all keys in the node's right subtree. That property enables fast searching for an item. BST search Given a key, a BST search operation returns the first node with a matching key, or None ifno matching key is found.
visit A BST search operation is said to visit a node if that node's key is accessed during theoperation.
successor A BST node's successor is the node that comes after in the BST ordering, so in A B C, A'ssuccessor is B, and B's successor is C.
predecessor A BST node's predecessor is the node that comes before in the BST ordering. insert-node Given a new node, a BST insert-node operation inserts the new node in a proper locationobeying the BST ordering property.
remove Given a key, a BST remove operation removes the first-found matching node,restructuring the tree to preserve the BST ordering property.
tree traversal A tree traversal algorithm visits all nodes in the tree once and performs an operation oneach node.
inorder traversal An inorder traversal visits all nodes in a BST from smallest to largest. visit During traversal, to visit a node means to perform an action of interest with that node. BST reverse inorder traversal (^) A BST reverse inorder traversal visits all nodes from largest to smallest. BST preorder traversal For each node N, a BST preorder traversal visits N, then recursively visit's N's left subtree,then recursively visits N's right subtree.
insert-node Given a new node, a red-black tree insert-node operation inserts the new node in theproper location such that all red-black tree requirements still hold after the insertion completes. remove-key Given a key, a red-black tree remove-key operation removes the key from the tree, ifpresent, restructuring as needed to preserve all red-black tree requirements.
max-heap A max-heap is a complete binary tree that maintains the simple property that a node's keyis greater than or equal to the node's children's keys.
insert (^) An insert into a max-heap starts by inserting the node in the tree's last level, and thenswapping the node with the node's parent until no max-heap property violation occurs.
percolate-up The operation that moves the node upward is called a percolate-up operation. percolate-down A max-heap percolate-down operation swaps a node with the node's greatest child untilno max-heap violation occurs.
remove A max-heap remove operation always removes the root, and is done by replacing theroot with the last level's last node, then performing a percolate-down operation on the root node. min-heap A min-heap is similar to a max-heap, but a node's key is less than or equal to the node'schildren's keys.
Heapsort Heapsort is a sorting algorithm that takes advantage of a max-heap's properties byrepeatedly removing the max and building a sorted list in reverse order.
heapify (^) The heapify operation is used to turn a list into a heap. priority queue A priority queue is a queue where each item has a priority, and items with higher priorityare closer to the front of the queue than items with lower priority.
enqueue The priority queue enqueue operation inserts an item such that the item is closer to thefront than all items of lower priority, and closer to the end than all items of equal or higher priority.
dequeue The priority queue dequeue operation removes and returns the item at the front of thequeue, which has the highest priority.
peek A peek operation returns the highest priority item, without removing the item from thefront of the queue.
enqueue-with-priority Enqueue-with-priority operation: An enqueue operation that includes an argument forthe enqueued item's priority.
treap A treap uses a main key that maintains a binary search tree ordering property, and asecondary key generated randomly (often called "priority") during insertions that maintains a heap property. search A treap search is the same as a BST search using the main key, since the treap is a BST. insert A treap insert initially inserts a node as in a BST using the main key, then assigns a randompriority to the node, and percolates the node up until the heap property is not violated.
delete A treap delete can be done by setting the node's priority such that the node should be aleaf (-∞ for a max-heap), percolating the node down using rotations until the node is a leaf, and then removing the node. PriorityQueue A PriorityQueue class is defined in the queue module and can be imported with the fromqueue import PriorityQueue statement.
set A set is an ADT representing a collection of distinct elements. add A set add operation adds an element to the set, provided an equal element doesn'talready exist in the set.
equal sets Two sets that contain the same elements are equal sets. length / cardinality A set's length (or cardinality) is the number of elements in the set. remove A set remove operation removes an element from the set. subset A set S1 is a subset of set S2 only if every element of S1 is also an element of S2.
distance The distance between two vertices is the number of edges on the shortest path betweenthose vertices.
connected (^) A connected graph contains a path between every pair of vertices. disconnected A disconnected graph does not contain a path between every pair of vertices. adjacency list In an adjacency list graph representation, each vertex has a list of adjacent vertices, eachlist item representing an edge.
sparse graph A sparse graph has far fewer edges than the maximum possible. adjacency matrix In an adjacency matrix graph representation, each vertex is assigned to a matrix row andcolumn, and a matrix element is 1 if the corresponding two vertices have an edge or is 0 otherwise. graph traversal An algorithm commonly must visit every vertex in a graph in some order, known as agraph traversal.
visit To visit a vertex during a graph traversal means to perform an action of interest with thatvertex, like printing the vertex's label or adding the vertex to an output list.
breadth-first search / BFS A breadth-first search (BFS) is a traversal that visits a starting vertex, then all vertices ofdistance 1 from that vertex, then of distance 2, and so on, without revisiting a vertex.
peer-to-peer network (^) In a peer-to-peer network, computers are connected via a network and may seek anddownload file copies (such as songs or movies) via intermediary computers or routers.
vertex visitor method A method that is called each time a vertex is visited during traversal. discovered When the BFS algorithm first encounters a vertex, that vertex is said to have beendiscovered.
frontier In the BFS algorithm, the vertices in the queue are called the frontier, being vertices thusfar discovered but not yet visited.
depth-first search / DFS A depth-first search (DFS) is a traversal that visits a starting vertex, then visits every vertexalong each path starting from that vertex to the path's end before backtracking.
directed graph / digraph A directed graph, or digraph, consists of vertices connected by directed edges. directed edge A directed edge is a connection between a starting vertex and a terminating vertex. adjacent In a directed graph, a vertex Y is adjacent to a vertex X if an edge exists from X to Y. path A path is a sequence of directed edges leading from a source (starting) vertex to adestination (ending) vertex.
cycle A cycle is a path that starts and ends at the same vertex. cyclic / acyclic A directed graph is cyclic if the graph contains a cycle, and acyclic if the graph does notcontain a cycle.
outgoing edge For a vertex V in a directed graph, an outgoing edge is an edge that has V as the startingvertex.
incoming edge For a vertex V in a directed graph, an incoming edge is an edge that has V as theterminating vertex.
degree A vertex's degree is the number of edges containing the vertex. weighted graph A weighted graph associates a weight with each edge. weight / cost A graph edge's weight, or cost, represents some numerical value between vertex items,such as flight cost between airports, connection speed between computers, or travel time between cities. path length In a weighted graph, the path length is the sum of the edge weights in the path. cycle length The cycle length is the sum of the edge weights in a cycle. negative edge weight cycle A negative edge weight cycle has a cycle length less than 0.
order The order is the maximum number of children a node can have. full A 2-3-4 tree node containing three keys is said to be full. 2-node A node with one key is called a 2-node. 3-node A node with two keys is called a 3-node. 4-node A node with three keys is called a 4-node. subtree A 2-3-4 tree subtree is any node X in the tree and all of X's descendants. search Given a key, a 2-3-4 tree search algorithm returns the node containing that key, or None ifno such node exists.
insert (^) Given a new key, a 2-3-4 tree insert operation inserts the new key in the proper locationsuch that all 2-3-4 tree properties are preserved.
split The split operation moves the middle key from a child node up into the child's parent. preemptive split The preemptive split insertion scheme is a 2-3-4 tree key insertion algorithm that alwayssplits any full node encountered during insertion traversal.
rotation A rotation is a rearrangement of keys between three nodes that maintains all 2-3-4 treeproperties in the process.
right rotation (^) A right rotation on a node causes the node to lose one key and the node's right sibling togain one key.
left rotation A left rotation on a node causes the node to lose one key and the node's left sibling togain one key.
fusion A fusion is a combination of three keys: two from adjacent sibling nodes that have onekey each, and a third from the siblings' parent.
merge A 2-3-4 tree merge operates on a node with one key and increases the node's key countto two or three using either a rotation or fusion.
remove Given a key, a 2-3-4 tree remove operation removes the key, if found, restructuring asneeded to maintain a valid 2-3-4 tree.
preemptive merge The 2-3-4 tree preemptive merge removal scheme merges each single-key node visitedduring traversal.
successor / predecessor Given a key K in a 2-3-4 tree, the tree's next largest key is K's successor and the nextsmallest key is K's predecessor.
algorithm An algorithm is a sequence of steps for accomplishing a task. Linear search Linear search is a search algorithm that starts from the beginning of a list, and checkseach element until the search key is found or the end of the list is reached.
Binary search Binary search is an algorithm for searching a sorted list. constant time operation A constant time operation is an operation that, for a given processor, always operates inthe same amount of time, regardless of input values.
Lower bound Lower bound: A function f(N) that is ≤ the best case T(N), for all values of N ≥ 1. Upper bound Upper bound: A function f(N) that is ≥ the worst case T(N), for all values of N ≥ 1. Asymptotic notation Asymptotic notation is the classification of runtime complexity that uses functions thatindicate only the growth rate of a bounding function.
O notation / Big O notation O notation (Big O notation) provides a growth rate for an algorithm's upper bound. Ω notation / Big Omega notation Ω notation (Big Omega notation) provides a growth rate for an algorithm's lower bound. Θ notation / Big Theta notation Θbound. notation (Big Theta notation) provides a growth rate that is both an upper and lower
Big O notation Big O notation is a mathematical way of describing how a function (running time of analgorithm) generally behaves in relation to the input size.