WGU C949 - Data Structures And Algorithms

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

type()

A Python function that returns the class type of the argument (object) passed as parameter.

Heap

A complete binary tree-based data structure.

Max-heap

A tree that maintains the simple property that a node's key is greater than or equal to the node's childrens' keys.

Min-heap

A tree that maintains the simple property that a node's key is less than or equal to the node's childrens' keys.

Sequence type

A type that specifies a collection of objects ordered from left to right. A string's characters are ordered from the first letter of the string to the last.

reference count

An integer counter that represents how many variables reference an object.

membership operators

These operators include the in and not in operators and yield True or False if the left operand matches the value of some element in the right operand, which is always a container.

any()

A Python function that returns True if any key of the dictionary is true.

id()

A Python function that returns identity (unique integer) of an object.

len()

A Python function to find the length of a string (and any other sequence type).

binary search tree (BST)

A binary tree that has an ordering property that any node's left subtree keys ≤ the node's key, and the right subtree's keys ≥ the node's key. That property enables fast searching for an item, as will be shown later.

max-heap

A binary tree that maintains the simple property that a node's key is greater than or equal to the node's childrens' keys.

min-heap

A binary tree that maintains the simple property that a node's key is less than or equal to its children's keys.

empty-after-removal

A bucket had an item removed that caused the bucket to now be empty.

empty-since-start

A bucket has been empty since the hash table was created.

Radix sort bucket

A collection of integer values that all share a particular digit value. Ex: Values 57, 97, 77, and 17 all have a 7 as the 1's digit, and would all be placed into item 7 when subdividing by the 1's digit.

Open addressing

A collision resolution technique where collisions are resolved by looking for an empty bucket elsewhere in the table.

Chaining

A collision resolution technique where each bucket has a list of items

Expression

A combination of items such as variables, literals, and operators that evaluates to a value. Can be just a literal, just a variable, or some combination of variables, literals, and operators.

bucket

A container for numerical values in a specific range. Ex: All numbers in the range 0 to 49 may be stored in a bucket representing this range. Bucket sort is designed for arrays with non-negative numbers. - Useful when the input is uniformly distributed over the range.

singly-linked list

A data structure for implementing a list ADT, where each node has data and a pointer to the next node. The list structure typically has pointers to the list's first node and last node.

doubly-linked list

A data structure for implementing a list ADT, where each node has data, a pointer to the next node, and a pointer to the previous node. It is a type of positional list.

Graph

A data structure for representing connections among items, and consists of vertices connected by edges.

Binary tree

A data structure in which each node stores data and has up to two children, known as a left child and a right child.

Linked list

A data structure that stores ordered list of items in nodes, where each node stores data and has a pointer to the next node.

Record

A data structure that stores subitems, with a name associated with each subitem.

Array

A data structure that stores subitems, with a name associated with each subitem. May only store homogeneous data elements.

Hash table

A data structure that stores unordered items by mapping (or hashing) each item to a location in an array.

Tuple

A data type behaves similar to a list but is immutable - once created the elements cannot be changed.

Abstract Data Type (ADT)

A data type described by predefined user operations, such as "insert data at rear," without indicating how each operation is implemented.

Class object

A factory that creates instance objects.

Scientific notation

A floating-point literal written using an e preceding the power-of-10 exponent, as in 6.02e23 to represent 6.02x10^23. The e stands for exponent. Likewise, 0.001 is 1x10-^3 so can be written as 1.0e-3.

duck typing

A form of dynamic typing based on the maxim "If a bird walks, swims, and quacks like a duck, then call it a duck".

recurrence relation

A function f(N) that is defined in terms of the same function operating on a value < N.

Lower bound

A function f(N) that is ≤ the best case T(N), for all values of N ≥ 1.

Upper bound

A function f(N) that is ≥ the worst case T(N), for all values of N ≥ 1.

recursive function

A function that calls itself, either directly or indirectly.

Space complexity

A function, S(N), that represents the number of fixed-size memory units used by the algorithm for an input of size N.

Runtime complexity

A function, T(N), that represents the number of constant time operations performed by the algorithm on an input of size N.

quadratic probing

A hash table handles a collision by starting at the key's mapped bucket, and then quadratically searches subsequent buckets until an empty bucket is found. If an item's mapped bucket is H, the formula (H + c1 ∗ i + c2 ∗ i**2) mod (tablesize) is used to determine the item's index in the hash table.

direct access table

A hash table with a direct hash function.

circular linked list

A linked list where the tail node's next pointer points to the head of the list, instead of null. Can be used to represent repeating processes.

array-based list

A list ADT implemented using an array. It supports the common list ADT operations, such as append, prepend, insert after, remove, and search.

reverse traversal

A list traversal that visits all nodes starting with the list's tail node and ending after visiting the list's head node.

Positional list

A list where elements contain pointers to the next and/or previous elements in the list.

positional list

A list where elements contain pointers to the next and/or previous elements in the list.

Mapping type

A mapping type is a data type comprised of a collection of keys and associated values. Python's only built-in mapping type is the dictionary. Dictionaries implement the associative array abstract data type.

Function

A named series of statements

Tree

A non-linear data structure that organizes data in a hierarchical way.

floating-point literal

A number with a fractional part, even if that fraction is 0, as in 1.0, 0.0, or 99.573

Fibonacci sequence

A numerical sequence where each term is the sum of the previous 2 terms in the sequence, except the first 2 terms, which are 0 and 1.

Bucket sort

A numerical sorting algorithm that distributes numbers into buckets, sorts each bucket with an additional sorting algorithm, and then concatenates buckets together to build the sorted result.

gap value

A positive integer representing the distance between elements in an interleaved list. For each interleaved list, if an element is at index i, the next element is at index i + ___________.

Priority queue

A queue where each item has a priority, and items with higher priority are closer to the front of the queue than items with lower priority.

Priority Queue

A queue where each item has a priority, and items with higher priority are closer to the front of the queue than items with lower priority. Duplicates items are allowed.

Linear search

A search algorithm that starts from the beginning of a list, and checks each element until the search key is found or the end of the list is reached.

name/identifier

A sequence of letters (a-z, A-Z, _) and digits (0-9), and must start with a letter. Note that "_", called an underscore, is considered to be a letter.

Block

A series of indented statements following the function definition.

NP-Complete

A set of problems for which no known efficient algorithm exists.

Head

A singly-linked list's first node.

Tail

A singly-linked list's last node.

Radix sort

A sorting algorithm designed specifically for integers. The algorithm makes use of a concept called buckets and is a type of bucket sort.

Merge sort

A sorting algorithm that divides a list into two halves, recursively sorts each half, and then merges the sorted halves to produce a sorted list.

fast sorting algorithm

A sorting algorithm that has an average runtime complexity of O(N log N) or better.

Bubble sort

A sorting algorithm that iterates through a list, comparing and swapping adjacent elements if the second element is less than the first element. O(n^2)

element comparison sorting algorithm

A sorting algorithm that operates on an array of elements that can be compared to each other. Ex: An array of strings can be sorted with a comparison sorting algorithm, since two strings can be compared to determine if the one string is less than, equal to, or greater than another string.

Quicksort

A sorting algorithm that repeatedly partitions the input into low and high parts (each part unsorted), and then recursively sorts each of those parts. To partition the input, it chooses a pivot to divide the data into low and high parts. - Recursively breaks down a problem into two or more subproblems of the same or related type

Heapsort

A sorting algorithm that takes advantage of a max-heap's properties by repeatedly removing the max and building a sorted array in reverse order.

Shell sort

A sorting algorithm that treats the input as a collection of interleaved lists, and sorts each list individually with a variant of the insertion sort algorithm. It uses gap values to determine the number of interleaved lists.

insertion sort

A sorting algorithm that treats the input as two parts, a sorted part and an unsorted part, and repeatedly inserts the next value from the unsorted part into the correct location in the sorted part.

Selection sort

A sorting algorithm that treats the input as two parts, a sorted part and an unsorted part, and repeatedly selects the proper next value to move from the unsorted part to the end of the sorted part.

Literal

A specific value in code like 2 or "abc".

global statement

A statement that must be used to change the value of a global variable inside of a function.

String literal

A string value specified in the source code of a program.

Operator

A symbol for a built-in language calculation like + for addition.

recursion tree

A visual diagram of a operations done by a recursive function, that separates operations done directly by the function and operations done by recursive calls.

Data structure

A way of organizing, storing, and performing operations on data. Operations include accessing or updating stored data, searching for specific data, inserting new data, and removing data.

Set

An ADT for a collection of distinct items.

List

An ADT for holding ordered data. Duplicate items are allowed.

Bag

An ADT for storing items in which the order does not matter and duplicate items are allowed.

Queue

An ADT in which items are inserted at the end and removed from the front. referred to as a first-in first-out ADT.

stack

An ADT in which items are only inserted on or removed from the top of a stack. Referred to as a last-in first-out ADT. Can be implemented using a linked list, an array, or a vector.

Stack

An ADT in which items are only inserted on or removed from the top.

Deque

An ADT in which items can be inserted and removed at both the front and back.

Dictionary

An ADT that associates (or maps) keys with values. Can be used to describe associative relationships in Python.

Longest Common Substring

An algorithm that determines the longest common substring that exists in two inputs strings.

Dijkstra's Shortest Path

An algorithm that determines the shortest path from a start vertex to each vertex in a graph.

Quickselect

An algorithm that selects the kth smallest element in a list. Ex: Running quickselect on the list (15, 73, 5, 88, 9) with k = 0, returns the smallest element in the list, or 5.

list traversal

An algorithm that visits all nodes in the list once and performs an operation on each node.

Polynomial time algorithm

An algorithm whose execution time grows as a polynomial of input size. An efficient algorithm is one whose runtime increases no more than polynomially with respect to the input size.

Binary Search

An efficient algorithm for searching a list. The list's elements must be sorted and directly accessible (such as an array).

Element

An item of a list

Double hashing

An open-addressing collision resolution technique that uses 2 different hash functions to compute bucket indices. Using hash functions h1 and h2, a key's index in the table is computed with the formula (h1(key) + i ∗ h2(key)) mod (tablesize). Inserting a key uses the formula, starting with i = 0, to repeatedly search hash table buckets until an empty bucket is found.

Heapify

An operation is used to turn an array into a heap.

constant time operation

An operation that, for a given processor, always operates in the same amount of time, regardless of input values.

stride

An optional component of slice notation which indicates how many elements are skipped between extracted items in the source list.

pivot

Any value within the array being sorted, commonly the value of the middle array element. Ex: For the list (4, 34, 10, 25, 1), the middle element is located at index 2 (the middle of indices [0, 4]) and has a value of 10.

pass-by-assignment

Arguments to functions are passed by object reference

Assignment statement

Assigns the name on the left side to reference the value on the right side.

Sequence-type functions

Built-in functions that operate on sequences like lists and strings.

Clas interface

Consists of the methods that a programmer calls to create, modify, or access a class instance.

class attribute

Defined within the scope of a class, this attribute is shared amongst all of the instances of that class

Algorithm

Describes a sequence of steps to solve a computational problem or perform a calculation.

base case

Every recursive function must have a case that returns a value without performing a recursive call.

linear probing

Handles a hash table collision by starting at the key's mapped bucket, and then linearly searches subsequent buckets until an empty bucket is found.

Parent

In a binary tree, a node with a child. Root: The one tree node with no parent (the "top" node).

ancestors

In a binary tree, a node's parent, the parent's parent, etc., up to the tree's root.

Perfect Binary Tree

In a binary tree, all internal nodes have 2 children and all leaf nodes are at the same level.

Complete binary tree

In a binary tree, all levels, except possibly the last level, are completely full and all nodes in the last level are as far left as possible.

Full binary tree

In a binary tree, every node contains 0 or 2 children.

Binary tree edge

In a binary tree, the link from a node to a child

depth

In a binary tree, the number of edges on the path from the root to the node.

Root

In a binary tree, the one node with no parent.

Internal node

In a binary tree, this is a node with at least one child.

Leaf

In a binary tree, this is a node with no children.

binary tree

In this list, each node has up to two children, known as a left child and a right child.

Mutability

Indicates whether the object's value is allowed to change.

Queue push

Inserts an item at the end of the queue.

stack push

Inserts an item on the top of the stack.

probing sequence

Iterating through sequential values to obtain the desired table index.

rich comparison methods

Methods like __lt__ that can be altered using operator overloading

Containers

Objects that contain references to other objects instead of data.

Overflow

Occurs when a value is too large to be stored in the memory allocated by the interpreter.

Collision

Occurs when an item being inserted into a hash table maps to the same bucket as an existing item in the hash table.

list object type

One of the most important and often used types in a Python program. It is a container, which is an object that groups related objects together. It is also a sequence; thus, the contained objects maintain a left-to-right positional ordering.

Queue pop

Removes and returns the item at the front of the queue.

stack pop

Removes and returns the item at the top of the stack.

Edge

Represents a connection between two vertices in a graph.

Vertex

Represents an item in a graph.

Queue peek

Returns but does not remove item at the front of the queue

Computational Problem

Specifies an input, a question about the input that can be answered using a computer, and the desired output.

PEP 8

The Python style guide that outlines the basics of how to write Python code neatly and consistently.

Computational complexity

The amount of resources used by the algorithm. The most common resources considered are the runtime and memory usage.

in-place modification

The capability of a list to grow and shrink without the program having to replace the entire list with an updated copy.

Asymptotic notation

The classification of runtime complexity that uses functions that indicate only the growth rate of a bounding function. Three notations are commonly used in complexity analysis: O - Growth rate for an algorithm's upper bound. Ω - Growth rate for an algorithm's lower bound. Θ - Growth rate that is both an upper and lower bound.

Character index

The position of a character in a string.

memory allocation

The process of an application requesting and being granted memory.

Class customization

The process of defining how a class should behave for some common operations. Such operations might include printing, accessing attributes, or how instances of that class are compared to each other.

Scope resolution

The process of searching for a name in the available namespaces.

preorder traversal

The root node is visited first, then the left subtree and finally the right subtree. Used to create a copy of the tree.

worst-case runtime

The runtime complexity for an input that results in the longest execution.

Auxiliary space complexity

The space complexity not including the input data.

Percolating

The upward movement of a node in a max-heap

Instance attribute

This attribute is unique to each class instance and is created within a method, or from outside of the class' scope.

perfect hash function

This hash function maps items to buckets with no collisions. It can be created if the number of items and all possible item keys are known beforehand. The runtime for insert, search, and remove is O(1).

multiplicative string hash

This hash function repeatedly multiplies the hash value and adds the ASCII (or Unicode) value of each character in the string. It starts with a large initial value. For each character, the hash function multiplies the current hash value by a multiplier (often prime) and adds the character's value. Finally, the function returns the remainder of the sum divided by the hash table size N.

good hash function

This hash function should uniformly distribute items into buckets. With chaining, it results in short bucket lists and thus fast inserts, searches, and removes. With linear probing, it will avoid hashing multiple items to consecutive buckets and thus minimize the average linear probing length to achieve fast inserts, searches, and removes. On average, it will achieve O(1) inserts, searches, and removes, but in the worst-case may require O(N).

mid-square hash

This hash function squares the key, extracts R digits from the result's middle, and returns the remainder of the middle digits divided by hash table size N. Ex: For a hash table with 100 entries and a key of 453, the decimal (base 10) hash function computes 453 * 453 = 205209, and returns the middle two digits 52. The index is then computed as 52 % 100 = 52. For N buckets, R must be greater than or equal to ⌈logN⌉ to index all buckets.

direct hash function

This hash function uses the item's key as the bucket index. Ex: If the key is 937, the index is 937.

modulo hash

This hash function uses the remainder from division of the key by hash table size N.

operator overloading

This technique of Class customization can redefine the functionality of built-in operators like <, >=, +, -, and * when used with class instances.

Numeric type

This type includes int and float which represent the most common types used to store data. These types all support the normal mathematical operations such as addition, subtraction, multiplication, and division, among others.

Algorithm efficiency

Typically measured by the algorithm's computational complexity.

global variables

Variables declared in the main body of the program and so can be accessed anywhere in the code

local variables

Variables declared within a function or procedure and so can be accessed only by the code within that function or procedure

inorder traversal

Visits all nodes in a BST from smallest to largest, which is useful for example to print the tree's nodes in sorted order.

nearly sorted

When a list only contains a few elements not in sorted order.

instance object

When created by the class object, this is initialized via the __init__ method.

Reserved words

Words that have special meaning and therefore cannot be used as identifiers.

Modulo operator

Written as %, evaluates to the remainder of the division of the two integer operands.

list comprehension

a convenient construct that iterates over a list, modifies each element, and returns a new list consisting of the modified elements.

Garbage collection

automatic reclamation of memory occupied by objects that are no longer referenced; It reclaims memory from data structures implemented using linked allocations.

Scope

the area of code where a name is visible.


संबंधित स्टडी सेट्स

CSC440 Chapter 4: Requirements Engineering (Software Engineering, Sommerville, 10th Edition)

View Set

Characteristics of Tangent and Cotangent function

View Set

Causes & Characteristics of World War I & the Russian Revolution

View Set

Chapter 2 Test - Positive Choices/Positive Changes

View Set

Psy 201- Intelligence and Creativity

View Set

Henri Fayol's - 14 Principles of Management

View Set

bible - Ezra, Nehemiah and Esther

View Set

Oceanography Chp 9 Study Questions

View Set

Consumer Behavior Final (chp.11-18) pg. 246-557.

View Set