4.2 Fundamentals of Data Structures Flashcards

1
Q

Difference between binary and text files

A

All files can be categorized into one of two file formats — binary or text. The two file types may look the same on the surface, but they encode data differently. While both binary and text files contain data stored as a series of bits (binary values of 1s and 0s), the bits in text files represent characters, while the bits in binary files represent custom data.

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

Abstract Data Type

A

An abstract data type is a data structure whose properties are specified independently of any particular programming language. ADTs have not only properties/values, but also have functions and procedures to interface
with.

  • 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 vs Dynamic Data Structures

A

In static data structures the size of the structure is fixed. The content of the data structure can be modified but only without changing the memory space allocated to it. An example of static data structure is an array.

In dynamic data structures the size of the structure in not fixed and can be modified during the operations performed on it. Dynamic data structures are designed to facilitate change of data structures in the run time. An example of a Dynamic Data Structure is a Linked List.

Static data structures provide easier access to elements compared to dynamic data structures. However, unlike static data structures, dynamic data structures are flexible and can adjust dynamically to accommodate the changing
needs for the amount of memory required at run time.

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

Linear Queues

A

A queue is a first-in first-out (FIFO) abstract data type. Uses for queues involve
anything where events must happen in the order that they were called/added.
Examples of common queue uses in an operating software include keyboard
buffers and print queues.

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

Circular Queues

A

Unlike linear queues, circular queues allow for memory to be re-used in a more
efficient manner when dequeue events have taken place.

Benefits
* They reuse memory space, meaning they won’t overwrite data or run out of
memory (within limits)

Drawbacks
* Involve storing pointers as well as data, taking up more space than linear queues
* Limited by the amount of data available in the array

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

Priority Queues

A

A real-world example of this would be an Accident and Emergency Department waiting room. Someone who had broken an arm would be a lower priority to someone who is having a stroke.

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

What is a stack?

A

A stack is a container of objects that are inserted and removed according to the
last-in first-out (LIFO) principle.

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

Uses of a stack

A
  • Return values for recursive procedures
  • The syntax check on a computer for matching braces.
  • ‘Undo’ mechanisms in software.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Graph Definition

A

A Graph is a diagram consisting of end points, called vertices that are joined by lines, called edges.

A labelled graph is a graph in which the vertices are labelled (i.e. consist of a number or word).
A weighted graph consists of edges which have a value (usually a number)
A directed graph consists of vertices that are joined by directed edges (edges that only travel in a single direction).

A graph is said to contain a cycle where a vertex has an edge which connects to itself.

The degree of a vertex is the number of end segments of edges that “stick out of” the vertex.
The neighbours of a vertex is the count of all connected vertices to the stated vertex.

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

Uses of Graphs

A

Telephone, electric power, gas pipeline, and air transport systems can all be represented by graphs

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

What is a tree

A

A tree is a connected, undirected graph with no cycles. Trees often have a root; however, they do not have to have one.

Data is added to the tree in the order it is encountered.

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

Binary tree

A

A binary tree is a rooted tree in which each node has at most two children. A common application of a binary tree is as a binary search tree. Binary trees a dynamic data structure and allows for efficient sorting, searching and retrieval of data.

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

Hashing algorithms

A

Hashing algorithms take a large range of values (such as all possible strings or all possible files) and map them onto a
smaller set of fixed sized values (such as a 128-bit number).
Sometimes these may be called digests or simply a hash.

Hashing is the process of applying a hashing algorithm to a hashing key to create a hash value.
* Hashing Algorithm (Example: SHA-256)
* Hashing Key: The data item to hash
* Hashing Value: The output from the hashing algorithm.

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

Hash tables

A

A hash table is a data structure that creates a mapping between keys and values. A Hash table combines the benefits
of an array with the benefits of a linked list by using a hash function. The hash function will always output the same
value for any given key.

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

Collisions in hash tables

A

A collision occurs when two key values compute the same hash.

There are two ways to resolve a collision. Closed Hashing which uses the next available location and Open Hashing
which uses the linked list method of resolving the collision.

Closed Hashing is simple to implement but can result in a problem of clustering, which increases the chance of
further collisions. Ideally a hash function should be created that minimises collisions but that is not always possible.
Open hashing works slightly better, as it means when a collision happens, the collided items are simply added to a
linked list and the value returned by a key becomes a pointer to the first item in a linked list containing all the values
which would be stored at that key location.

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

What is a dictionary?

A

A collection of key-value pairs in which the value is accessed via the associated key.
A dictionary is an abstract data type that maps keys to data. A dictionary has a set of keys, and each of these keys
has a single value associated with it. When the key is supplied, the associated value is returned.

Pairs in a dictionary and not stored in any particular order. The key is actually hashed and placed in to a location
based upon a hashing function.

17
Q

What is a Vector?

A

A series of numbers which represent
spatial information such as Position, Velocity, Acceleration, Force.

17
Q

Uses of dictionaries

A
  • Database Indexing
  • Caches
  • Sets
  • Object representation