Data types, data structures and algorithms Flashcards
(39 cards)
Properties of array
Static/size cannot be changed during processing
Element can be accessed directly
Contents stored contiguously in memory
Array contents are mutable
Holds data of a single type
Properties of lists
Dynamic (size can changed)
Can hold data of different types
Ordered (textbook)
Properties of tuples
Immutable / cannot be changed at runtime (other than this, same as a list: dynamic, can hold different data types, ordered)
What is a linked list (definition only)
Dynamic data structure, each node consists of a data and pointer, pointer gives location of next node
Properties of linked list
Dynamic/size can change during processing
Needs to be traversed until desired element is found
Contents may not be stored contiguously in memory (this has been corrected)
What is a record (textbook)
A record is a structure used within a database to store data by categories under key fields
Properties of records (3, textbook)
-A record is accessed through an attribute (or field).
-Unordered data structure
-Consists of different data types
Describe how to access the 2nd item in a linked list
-Go to the first position indicated by the start pointer
-From the first position, read the next pointer value
BFT vs DFT (i.e. suitability, performance etc.)
BFT is more efficient when data is closer to root, in general better time complexity
DFT is more efficient when data further down, memory requirement is linear, can be written recursively to aid understanding, in large trees may never return a value
Graphs vs trees (at least 4 differences)
Trees have one root node // graphs do not have a root node
Trees do not allow cycles/loops // graphs do allow cycles / loops
Trees store hierarchy // graphs have no hierarchy
Trees are always undirected // graphs can be directed
Trees are always connected // graphs can be connected or disconnected
Binary search trees (properties and advantages)
Each node can have a maximum of 2 child nodes
Nodes are ordered (left nodes less than the parent and right nodes greater)
The location to which a node is added depends on its order
Allows for faster searching (O(log n))
Inserting new nodes is faster
Do not need to sort the structure each time a new node is added
What are heuristics (AO1)
-Heuristics are used to reduce time taken to solve a problem
-It is a general ‘rule of thumb’ or an educated guess
-It finds a solution which is ‘good enough’ / close to the best solution
-Heuristic is a weight added to a node/decision
-E.g. Description of use such as in A* algorithm as estimate of distance to destination
How do heuristics help?
-Heuristics reduce the time complexity as every possibilities within a program does not need to be examined
-Avoid programs running indefinitely - in a computer game there could be too many possibilities so will terminate with a solution faster
Uses/applications of heuristics
-Heuristics are more appropriate with complex time-critical tasks - some aspects of game may require faster searching/decisions
-Heuristics are more appropriate with large-scale tasks - game could be large scale and AI algorithms may need to be shortened
-Games are not life-critical, so a good answer is likely enough, a perfect answer is not necessarily required
-Used in AI when the exact steps cannot be pre-programmed and decisions need making
Limitations/disadvantages of heuristics?
-Heuristics require skill to implement effectively
-Due to time-saving, they are not always accurate, the solution e.g. shortest path might not be the most efficient
What is meant by a character set?
What is the number of values represented by n bits?
-Number of values represented with n bits is 2^n
-Character set means all the characters a computer can understand (1), may include control characters (1), binary code equates to symbols (1), e.g. ASCII (1)
What is Unicode?
-Each character is represented by 1-4 bytes
-Supports very large number of characters
-Backward compatible with ASCII
What is a D-type flip flop?
Stores a value of one bit when signal is given (specifically on the rising edge according to my fwends, attributions: Toba, Oliver, Yusra)
Purpose of head pointer
To identify the first item/element
Purpose of tail pointer
To identify the next free space
Time complexity for traversing linked list
O(n) or linear complexity
Time complexity of recursive algorithm?
O(2^n)
Data structure for BFT
Queue
Data structure for DFT
Stack