2: Fundamentals of Data Structures Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

n-Dimensional Array

A

A set of elements with the same data type that are indexed by a tuple of n integers, where a tuple is an ordered list of elements

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

Abstract Data Structures (7)

A
  • Queue
  • Stack
  • Graph
  • Tree
  • Hash table
  • Dictionary
  • Vector
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Static Data Structures

A

They reserve memory for a set amount of data and cannot be resized

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

Dynamic Data Structures

A

They have no limit to the amount of data they can hold so can be resized

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

Static vs Dynamic Data Structures (6)

A
  • Static data structures have storage size determined at compile-time
  • Dynamic data structures can grow during execution
  • Static data structures can waste memory if the number of data items stored is small relative to the size of the structure
  • Dynamic data structures only take up the amount of storage space required for the
    actual data
  • Dynamic data structures require pointers to the next item whereas static data structures do not
  • Static data structures store data in consecutive memory locations whereas dynamic data structures do not
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Queue (4)

A
  • Items are added to the back of the queue
  • Items are removed from the front of the queue
  • Front and rear pointers are used
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Linear Queue

A

Once the maximum number of items has been added to the queue, no more items can be added even if some are removed

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

Circular Queue

A

Once the maximum number of items has been added, if some are removed, items are added to the front of the queue

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

Priority Queue (5)

A
  • Each item has a priority associated with it
  • The queue has different points at which items can join the queue according to priority
  • They join at the back of the section according to their priority
  • If there are no items queued in the correct priority section then they join the queue at the front of the next
    lower priority
  • Items are still taken one at a time from the front of the entire queue
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Stack (3)

A
  • Items are pushed to the back of the stack
  • Items are popped from the back of the stack
  • A top pointer is used for the item at the back
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Graph

A

A data structure used to represent more complex relationships

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

Weighted Graph

A

A graph with a value associated with each edge

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

Vertex / Node

A

A point on a graph

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

Edge / Arc

A

A connection between two vertices

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

Undirected Graph

A

A graph where you can traverse an edge either way

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

Directed Graph

A

A graph where edged may have associated directions

17
Q

Adjacency Matrices + (3)

A
  • Appropriate when there are many edges between vertices or when graph is not sparse
  • Appropriate when edges frequently changed
  • Appropriate when presence of specific edges needs to be tested frequently
18
Q

Tree

A

A connected, undirected graph with no cycles

19
Q

Rooted Tree (3)

A
  • A tree in which one vertex has been designated as the root
  • A rooted tree has parent-child relationships between nodes
  • The root is the only node with no parent and all other nodes are descendants of the root
20
Q

Binary Tree

A

A rooted tree in which each node has at most two children

21
Q

Rooted Tree Uses (4)

A
  • Binary trees are used in compilers to build syntax trees
  • Binary trees are used within routers to store routing tables
  • Binary search trees can be built to speed up searching
  • Expression trees can be used to represent algebraic and Boolean expressions in a way that simplifies the processing of the expression
22
Q

Hash Table

A

A data structure that creates a mapping between keys and values

23
Q

Collision

A

When two key values compute the same hash

24
Q

Rehashing (4)

A
  • When a collision occurs, the value is placed in the next free position in the hash table
  • A pointer to the position of the value is stored in its hashed position
  • When retrieving values, the key is checked against the key in the hashed position
  • If they are different, the pointer position is checked
25
Q

Dictionary

A

A collection of key-value pairs in which the value is accessed via the associated key

26
Q

Dictionary Applications

A

Information retrieval

27
Q

Vector

A

A vector can be represented as a list of numbers, as a function and as a way of representing a geometric point in space

28
Q

Vector Notations (5)

A
  • [2.0, 3.14159, -1.0, 2.718281828]
  • 4-vector over ℝ written as ℝ⁴
  • Function interpretation
    0 ↦ 2.0
    1 ↦ 3.14159
    2 ↦ -1.0
    3 ↦ 2.718281828
  • ↦ means maps to
  • All the entries must be drawn from the same field, e.g., ℝ
29
Q

Vector Addition

A

Achieves translation

30
Q

Scalar-Vector Multiplication

A

Achieves scaling

31
Q

Convex Combination of Two Vectors

A

An expression of the form αu + βv where α, β ≥ 0 and α + β = 1

32
Q

Dot / Scalar Product of Two Vectors

A

The dot product of u = [u₁, …., uₙ ] and v = [v₁, ….., vₙ ] is:
u ∙ v = u₁v₁ + u₂v₂ + …… + uₙvₙ

33
Q

Dot Product Applications

A

Finding the angle between two vectors