1.1 data structures Flashcards

(30 cards)

1
Q

pre order

A

dots to the left

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

in order

A

dots on the bottom

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

post order

A

dots on the right

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

linked list characteristics

A
  • dynamic data structure it can grow and stinks in size after declaration
  • each element is called a node - first element is head node
  • each node consists of the data and the reference to the next node
  • consists of starter pointer which points at the first item in the list and so on
  • items can be added into a linked list without having to shift the other items to fill the gap left (adv over 1D array)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

how to create binary trees

A

from first element - bigger (right) smaller (left)

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

remove from a binary tree with 2 children

A

go the right pointer and find the lowest value child from that element then replace the value being deleted with that child

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

what is a data structure

A

a set of related data items

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

why are the data structures are useful

A
  • efficient way of organising data relating to a real problem
  • may be efficient to deal with various elements as one item
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

an example of data that could be stored in a 2D array

A

sales of each product number by month

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

what are the key features of an array

A
  • a data structure which is a set of data elements of the same type
  • can be directly accessed via indexes, subscripts, row/column names
  • has a fixed number of elements (static)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

give an example of data that could be stored in 3D arrays

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

what is a record data and structure and when would they be used

A
  • a record is a set of data items all related to a single individual/ entity
  • a record can contain data of different types
  • a record would be used if there is data of more than one type
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

drawbacks of using 3D arrays

A
  • more complex to program/process
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

what data is suitable for a 1D array

A

when the data set comprises of single values of the same data type

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

what is a stack

A
  • a container of objects that are inserted and removed according to LIFO
  • It has a limited access data structure - elements can be added and removed from the stack only at the top
  • push adds an item to the top of the stack
  • pop removes the item from the top
  • a stack can be used as a recursive data structure
  • a stack is either empty or is consists of a top and the rest which is a stack
  • underflow occurs when an attempt is made to pop an empty stack or when an attempt is made to push a full stack
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Examples of when a stack could be used

A
  • undo and back button
  • a subprogram to return addresses (winding back nesting of subprograms)
  • recursion values
  • reversing a queue / list (LIFO)
17
Q

what is a queue

A

operates on the FIFO principle and data items are added at the end of the queue and removed from the front

18
Q

what happens when there is an attempt is made to add an item to a full queue

A

returns an appropriate message or condition
(produces an error message)

19
Q

examples of where a queue could be used in computing and why

A
  • a printer queue
  • keyboard buffer
  • a download buffer
  • a processor scheduling queue
  • because the natural/desirable processing order is FIFO so the job waiting the longest should be printed next
20
Q

what is a linked list (simple)

A

a set of data elements, where each element contains the data itself and a pointer to the next element

21
Q

advantages and drawbacks of a linked list compared to an array

A

advantages:
- new items can be inserted into a linked list without rearranging all the other elements
- if programmed dynamically uses memory more efficiently

disadvantages:
- 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

22
Q

what is an unbalanced binary tree

A

not the same amount on each branch

23
Q

example of in order traversal

A

-searching for a file in the file system
-listing files in alphabetical order

24
Q

example of post order traversal

A

delete all the files in the file system (each folder could only be deleted once all the files beneath have been deleted)

24
example of pre order traversal
create copy files in the file system (each file above has to be copied before the files below)
25
what is the first node called in a binary tree
root
26
advantages and disadvantages of using a binary tree
advantages: - faster to add a value - faster to search for a value disadvantages: -more complex to program/process -may be slow processing/ traversal if unbalanced
27
what is a hash table
- a structure that can map keys to values
28
how are hash tables used
a hash function is used to compute an index ( a hash code) into an array of buckets or slots from which the desired value can be found
29
examples of where hash tables are used
- to deal with collisions - many kinds of computer software, particularly for associative arrays, database indexing, caches and sets