Definitions Flashcards
(38 cards)
Record
A record is the data structure that stores subitems, often called fields, with a name associated with each subitem.
Array
An array is a data structure that stores an ordered list of items, where each item is directly accessible by a positional index.
Inserting an item at a specific location in an array requires making room for the item by shifting higher-indexed items.
Linked list
A linked list is a data structure that stores an ordered list of items in nodes, where each node stores data and has a pointer to the next node.
A linked list stores an ordered list of items. The links in each node define the order in which items are stored.
To insert new item in a linked list, a list node for the new item is first created. Item B’s next pointer is assigned to point to item C. Item A’s next pointer is updated to point to item B. No shifting of other items is required, which is an advantage of using linked lists.
Binary tree
A binary tree is a data structure in which each node stores data and has up to two children, known as a left child and a right child.
A binary tree node can have no children, a single left or right child, or both a left and right child.
Hash table
A hash table is a data structure that stores unordered items by mapping (or hashing) each item to a location in an array.
Heap
In data structures, a “heap” is a tree-based data structure where the nodes are arranged in a specific order, either with the largest value at the root (max-heap) or the smallest value at the root (min-heap), ensuring that the parent node always has a value greater than or equal to its children, making it particularly useful for implementing priority queues where you need to quickly access the highest or lowest priority element; it’s often implemented as a complete binary tree for efficient operations.
Key points about heaps:
- Heap property:
The core principle of a heap is the “heap property” which dictates the ordering of nodes within the tree, either with the parent node always having a larger value than its children (max-heap) or a smaller value (min-heap).
- Binary heap:
The most common implementation of a heap is a “binary heap” where each node has at most two children.
- Applications:
Heaps are used in algorithms like heapsort (for sorting data), Dijkstra’s algorithm (for finding shortest paths), and priority queues where elements need to be accessed based on their priority
A max-heap is a tree that maintains the simple property that a node’s key is greater than or equal to the node’s children’s keys.
A min-heap is a tree that maintains the simple property that a node’s key is less than or equal to the node’s children’s keys.
Graph
A graph is a data structure for representing connections among items, and consists of vertices connected by edges. A vertex represents an item in a graph. An edge represents a connection between two vertices in a graph.
Algorithm
An algorithm is a set of commands that must be followed for a computer to perform calculations or other problem-solving operations.
According to its formal definition, an algorithm is a finite set of instructions carried out in a specific order to perform a particular task. It is not the entire program or code; it is simple logic to a problem represented as an informal description in the form of a flowchart or pseudocode.
- Problem: A problem can be defined as a real-world problem or real-world instance problem for which you need to develop a program or set of instructions. An algorithm is a set of instructions.
- Algorithm: An algorithm is defined as a step-by-step process that will be designed for a problem.
- Input: After designing an algorithm, the algorithm is given the necessary and desired inputs.
- Processing unit: The input will be passed to the processing unit, producing the desired output.
- Output: The outcome or result of the program is referred to as the output.
Logical vs Physical data flow diagram
Logical DFDs (data flow diagrams) focus on what happens in a particular information flow: what information is being transmitted, what entities are receiving that info, what general processes occur, etc. The processes described in a logical DFD (data flow diagram) are business activities—a logical data flow diagram doesn’t delve into the technical aspects of a process or system, such as how the process is constructed and implemented. So you don’t need to include details like configuration or data storage technology. Non-technical employees should be able to understand these diagrams, making logical DFDs (data flow diagrams) an excellent tool for communicating with project stakeholders.
Physical data flow diagrams focus on how things happen in an information flow. These diagrams specify the software, hardware, files, and people involved in an information flow. A detailed physical data flow diagram can facilitate the development of the code needed to implement a data system.
NP-complete
NP-complete problems are a set of problems for which no known efficient algorithm exists. NP-complete problems have the following characteristics:
No efficient algorithm has been found to solve an NP-complete problem.
No one has proven that an efficient algorithm to solve an NP-complete problem is impossible.
If an efficient algorithm exists for one NP-complete problem, then all NP-complete problems can be solved efficiently.
By knowing a problem is NP-complete, instead of trying to find an efficient algorithm to solve the problem, a programmer can focus on finding an algorithm to efficiently find a good, but non-optimal, solution
Algorithm efficiency
Algorithm efficiency is most commonly measured by the algorithm runtime, and an efficient algorithm is one whose runtime increases no more than polynomially with respect to the input size.
In contrast, an algorithm with an exponential runtime is not efficient.
Abstract data types (ADTs)
An abstract data type (ADT) is a data type described by predefined user operations, such as “insert data at rear,” without indicating how each operation is implemented. An ADT can be implemented using different underlying data structures. However, a programmer need not have knowledge of the underlying implementation to use an ADT.
Abstract Data Types examples
List, Dynamic array, Stack, Queue, Deque, Bag, Set, Priority queue, Dictionary (Map)
Stack
A stack is an Abstract Data Type (ADT) in which items are only inserted on or removed from the top of a stack.
Common underlying data structures:
Linked list
Queue
A queue is an Abstract Data Type (ADT) in which items are inserted at the end of the queue and removed from the front of the queue.
Common underlying data structures:
Linked list
Deque
A deque (pronounced “deck” and short for double-ended queue) is an Abstract Data Type (ADT) in which items can be inserted and removed at both the front and back.
Common underlying data structures:
Linked list
Bag
A bag is an Abstract Data Type (ADT) for storing items in which the order does not matter and duplicate items are allowed.
Common underlying data structures:
Array, linked list
Set
A set is an Abstract Data Type (ADT) for a collection of distinct items. Duplicate items are not allowed.
Common underlying data structures:
Binary search tree, hash table
Priority Queue
A priority queue is a Abstract Data Type (ADT) 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. Duplicate items are allowed.
Common underlying data structures:
Heap
Dictionary (map)
A dictionary is an Abstract Data Type (ADT) that associates (or maps) keys with values.
Common underlying data structures:
Hash table, binary search tree
Dynamic Array
A dynamic array is an Abstract Data Type (ADT) for holding ordered data and allowing indexed access.
Common underlying data structures:
Array
List
A list is an Abstract Data Type (ADT) for holding ordered data. Duplicate items are allowed.
Common underlying data structures:
Array, linked list
Heuristics
Heuristic: A technique that willingly accepts a non-optimal or less accurate solution in order to improve execution speed.
In practice, solving a problem in the optimal or most accurate way may require more computational resources than are available or feasible. Algorithms implemented for such problems often use a heuristic.
Self-adjusting heuristic
A self-adjusting heuristic is an algorithm that modifies a data structure based on how that data structure is used. Ex: Many self-adjusting data structures, such as red-black trees and AVL (Adelson-Velsky and Landis) trees, use a self-adjusting heuristic to keep the tree balanced. Tree balancing organizes data to allow for faster access.
Ex: A self-adjusting heuristic can be used to speed up searches for frequently-searched-for list items by moving a list item to the front of the list when that item is searched for. This heuristic is self-adjusting because the list items are adjusted when a search is performed.