Data Structures Flashcards

1
Q

Stack

A

Holds Data in a FILO, First-In-Last-Out, pattern. Each data item is stacked one on top of the other and only the top is accessible.

Examples:

  • Plates
  • Call Stack (many languages)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Stack Interface (6)

A

Pop() - Remove & Return top of stack
Push() - Add to top of stack
Peek() - Return top of stack
Contains() - Returns true if item in stack
Length() - Returns how many items in stack
Clear() - Remove all items from the stack

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Queue

A

Holds Data in a LILO, Last-In-Last-Out pattern. Each data item is added to the back of a queue and is accessible when everything before has been dequeued.

Examples:
- Shop ticket queue systems

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Queue Interface (5)

A

Enqueue() - Add item to back of queue
Dequeue() - Return & remove item from front of queue.
Contains() - is item in queue
Length() - Length of Queue
Clear() - Remove all items from the queue.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

(Linked & Double Linked) List

A

A List of Items where each node (data item with relational metadata) is linked to the next (& to the previous in double linked lists.
The list itself must point to the head (first item in the list) & the tail (last item in the list)

Examples:
Javascript Arrays

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Linked List Interface

A
AddFirst()
RemoveFirst()
AddLast()
RemoveLast()
AddAtIndex()
RemoveAtIndex()
Remove()
AddAfter()
Find()
Clear()
Length()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Graph

A

A linked collection of items whereby each Vertex (node) can contain an Edge (link) to any other vertex. Edges can have values (think as length or weight of link).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Graph Interface

A

isAdjacent() - Is there an edge between two vertices
neighbours() - Returns a list of
addVertex() - Adds a vertex if it is not there
removeVertex() - removes the vertex , if it is there;
addEdge(): adds the edge between 2 vertices if there
removeEdge() - Removes edge between 2 vertices if there.
getVertexValue(): returns the value associated with the vertex
setVertexValue(G, x, v): sets the value associated with the vertex.
Length() - How Many Items In Graph
Contains() - Is Vertex/Value in Graph (BFS/DFS)

getEdgeValue(): returns the value associated with an Edge
setEdgeValue(G, x, y, v): sets the value associated with the edge

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Tree

A

A Tree is a hierarchical collection of data, where each node points via an edge (link) to child nodes. iF

  • “Root” is a node with no parents.
  • “Sibling” children of the same parent
  • “Ancestor” parent, grandparent for a given node
  • “Depth of a node” length of the path from the root to that node
    “Height of a Node” height from a particular node to the deepest node (leaf node)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Tree Interface

A
AddChild()
RemoveChild()
ClearChildren()
IsAncestor()
IsSibling()
getDepth()
getHeight();
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Array

A

An Array is a set of contiguous data items in memory, which means they cannot be added to after initialisation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Record / Struct

A

A record is a simple data structure that contains indexed fields that contains rows of data for each index. Sometimes these are referred to as Plain Objects

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Set

A

A set is a collection that contains unique (no duplicates), unordered data values.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Set Interface

A

MAIN
union() - returns a set containing all items (removing duplicates) of all input sets.
intersection() - returns a set containing all items that are common to any input sets.
difference() - returns a set containing all items that are found in only one input set.
subset() - a predicate that tests whether the input set is a subset (all items contained within) of the set.

Contains(): checks whether the value in set.
isEmpty(): checks whether the set is empty.
size(): Returns size of set

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

B-Tree

A

A B-Tree is a tree that self resizes to make sure that one side of the tree

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Binary Search Tree

A

A Tree that stores lower values as left hand side children, and higher values as right side children. Each node can only hold a left & right child. Can quickly end up unbalanced so needs a way.

17
Q

Heap

A

Heap is a Binary Search Tree with keys that define the order.

in a max heap, for any given node C, if P is a parent node of C, then the key (the value) of P is greater than or equal to the key of C. In a min heap, the key of P is less than or equal to the key of C

18
Q

Hash Table

A

An array whereby each value