1.1 Data Structures Flashcards

1
Q

Data structure

A

A data structure is a group / set / collection of related data items / elements

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

Types of data structure

A
·   queue
·   stack
·   (binary) tree 
·   record
·   Linked lists
·   array
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Top node of a binary tree

A

Root (node).

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

Advantage and disadvantage of binary trees

A

Advantage: faster to add a value / search for a value
Disadvantage: more complex to program / process / May slow processing/traversal if unbalanced.

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

Two dimensional array of:

Narberth, Cardiff, Pontypridd, Wrexham, Rhyl, Bangor, Denbigh

A

Table

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

Explain what is meant by the term linked list.

Describe one benefit and one drawback of using a linked list compared with using an array.

A

A linked list is a set of data elements, where each element contains:
· the data itself
· a pointer to the next element
Benefit :
New items can be inserted into a linked list without rearranging all the other elements
· If programmed dynamically uses memory more efficiently
Drawback :
· A linked list is more complex to program / manipulate than an array
· Extra programming is required to access the data in the opposite direction
· Can only be accessed in a linear manner.

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

Write a simple program using the assembly language commands in the table
above to demonstrate how two numbers can be added together and stored in a register

A
CLR R
LOD R, 0001
LOD S, 0002
ADD R,S
STR R 0003
CLR R
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Fetch phase of the fetch execute cycle, making clear the role of the :
PC (program counter)
MAR (memory address register)
MDR (memory data register)

A

· The address of the next instruction is copied from the PC to the MAR
· The instruction is copied to the MDR
· The PC is incremented so that it holds the address of the next instruction.

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

Difference between searching for an item in an ordered list compared with searching an unordered list.

A

When searching an ordered list the search can be terminated when an item greater than the search value (or less than) is reached

When searching an unordered list the search cannot be terminated until the last item has been reached.

For an ordered list a binary search can be used.

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

Records

A

A record is a set of data Items all related to a single individual/entity it can contain data of different types.

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

Stacks

A

A stack is a small register that stores the address of the last program request a stack

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

Describe a computer application that is the most appropriate data structure to use and explain why it is the most appropriate data structure in this case

A

Example could be subprogram return addresses this is because of the idea of winding back nesting of sub programs

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

Queues

A

Q pointer is a pointer that points to a part of the queue. A queue will have two pointers front and rear
FIFO

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

Trees

A

The tree is a data structure that holds a large amount of data for the process of quick searching and producing different ordered lists. The tree needs to be balanced for the accesses to be quick

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

Advantages and disadvantages of a binary tree

A

And advantage is it is faster to search/add a value

A disadvantage is it is more complex to program/process

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

Balanced binary tree

A

The above tree is balanced and the maximum number of comparisons to locate an item would be the same as the number of levels

17
Q

Unbalanced binary tree

A

The above tree is unbalanced and a maximum number of comparisons to locate an item would be the same as the number of items

18
Q

Linked lists

A

A link to the list is a set of data elements which each element contains the data itself and a pointer to the next element

19
Q

Benefits and drawbacks of linked lists

A

Benefits:
New items can be inserted into a link list without re-arranging all the other elements
If programmed dynamically uses memory more efficiently

Drawbacks:
A link to the list is more complex to program than an array
Extra programming is required to access the data in the opposite direction
Can only be accessed in linear manner

20
Q

Process of hashing

4 points

A

A random access file is one where the physical location of the record is calculated from the data in the key field

Sometimes a date a collision a case. In the second stances there needs to be an overflow area where the latest data is stored. A flag is set in the original block and the data is moved into designated overflow area for subsequent linear search

When the file begins to get quite full then maybe many items in the overflow area and access maybe come slow

A solution to this problem is to create a new crashing algorithm and I larger file may be needed