Fundamentals of Data Structure Flashcards
Abstract Data Type
A conceptual model of how the data is stored and the operations that were performed upon them.
Static Data Structure
A method of storing data where the amount of data stored (and memory used to store it) is fixed.
Dynamic Data Structure
A method of storing data where the amount of data stored (and memory used to store it) will vary as the program is being run.
Stack
A stack is an example of LIFO
A stack in a computer works exactly as a stack of books waiting to be marked - whichever item was added to the top is the first to be dealt with. However, data dealt with is NOT removed from the stack. What happens is that a variable called the stack pointer keeps track of where the top of the stack is.
Data is ‘pushed’ onto the stack or is ‘popped’ from the stack.
Stack Frame
A collection of data about a subroutine call
Call Stack
A special type of stack used to store information about active subroutines and functions within a program
Recursion
The process of a subroutine calling itself
Stack Pointer
A small register that stores the address of the last program request in a stack.
Queue
A queue is an example of FIFO
FIFO - First in First out (where the first data item is first to leave)
A common use for queues is when sending a document to the printer.
Linear Queue
http://image.ibb.co/dgKP0y/20180603_155036.jpg
Circular Queue
http://image.ibb.co/kO8j0y/20180603_155042.jpg
A common implementation for Circular Queue is for buffering, when items of data need to be stored temporarily while they are waiting to be passed to/from the device.
Priority Queues
A variation of a FIFO structure where some data may leave out of sequence where it has a higher priority than other data items.
Example: If documents are being sent to a printer on a network, the administrator may be able to control the queue.
Graph
A mathematical structure that models the relationship between pairs of objects.
A tree is similar to a graph, but with no loops.
Arc/Edge
Join/show relationship between 2 nodes
Vertex/Vertices
An object in a graph - also known as a node
Weighted Graph
A graph with data values on each arc/edge
Graph/Weighted graph/Undirected Graph/Directed Graph
Draw examples of each one.
http://image.ibb.co/b7ksnd/20180603_155953.jpg
Adjacency List
A data structure that stores a list of nodes with their adjacent nodes.
http: //image.ibb.co/exjP0y/20180603_160223.jpg
http: //image.ibb.co/dRD3Sd/20180603_160343.jpg
Adjacency Matrix
This uses a two-dimensional array or grid populated with 1s and 0s
http: //image.ibb.co/hNigDJ/20180603_160355.jpg
http: //image.ibb.co/jLOWDJ/20180603_160359.jpg
Binary Tree
A tree where each node can only have up to two child nodes attached to it.
Hashing Algorithm
Code that creates a unique index from given items of key data
Hash Table
A data structure that stores key/value pairs based on an index calculated from an algorithm
Uses of hashing algorithms
Databases - Used to create indices for databases enabling quick storage and retrieval of data (more efficient than linear for example)
Memory addressing - Used to generate memory addresses where data will be stored
Collision
When a hashing algorithm produces the same index for two or more different keys
Clustering
When a hashing algorithm produces indices that are not randomly distributed.
Index
The location where values will be stored, calculated from the key.
When collision occurs, there must be some way of handling it so that a unique index can be assigned to the key:
Chaining - adding the key/value to a list stored at the same index.
Rehashing - The process of running the hashing algorithm again when a collision occurs. This normally uses a technique called probing, which means that the algorithm probes or searches for an empty slot, and uses it.
Dictionary (Data Structure)
An abstract data type that maps keys to data. It is called an associative array in that it deals with two sets of data that are associated with each other.
eg
http://images.slideplayer.com/16/4911256/slides/slide_3.jpg
Representing vector as a data structure
eg
fibonacci[0] = 0; fibonacci[1] = 1; fibonacci[2] = 1
in a dictionary, would be represented as
{0:0, 1:1, 2:1}
Vector Addition
A = (A1, A2, A3) B = (B1, B2, B3)
A + B = (A1+B1, A2+B2, A3+B3)
Dot Product
A = (3,5) B = (7,2)
A.B = 37+52 = 31
Convex Combinations
The convex combinations is inbetween the two vectors. It is calculated as au+Bv Where u and v are vectors a+B = 1 a and B must be 0 or greater
https://www.youtube.com/watch?v=6N_caSzNpkc