1.4 - Data types, data structures and algorithms Flashcards
What is a data type?
It is the classification of data telling the computer how the computer will use the data.
What is an integer?
Any positive/negative whole number.
What is a real/float?
Any real world quantity expressed as a number (decimals).
What is boolean?
Used to represent one of two truth values (True/False)
What is a character?
Represents a single character, alphanumeric/symbol.
What is a string?
A collection of characters.
What is casting data types?
Changing data types
What is a primitive data type?
A basic data type.
What base in binary?
Base 2 = 01
What base is denary?
Base 10 0-9
What base is hexadecimal?
Base 16 0-9, A-F
What are the 5 positives of hexadecimal?
- Values easier to remember/read than binary.
- Quicker to write, less characters.
- Less chance of eror when typing hex.
- Defines colours, MAC addresses, in assembly languages/machine code.
- Easy to convert to/from Binary.
How do you use sign + magnitude?
(Negative numbers in binary)
The most significant number represents whether the number is positive (= 0)/negative (=1).
How do you use two’s compliment?
(Negative numbers in binary)
The most significant number represents whether the number is positive (= 0)/negative (=1). Then all the numbers afterwards (until the last 1 (1 closest to the end)) are switched to the opposite value.
How do you convert from Denary to Binary?
Put in place value to add to make total of the number.
e.g. 99 = 01100011
128/64/32/16/8/4/2/1
0 1 1 0 0 0 1 1
How do you convert from Hexadecimal to Denary
Do the rule of place values. 256 16 1 time number based on plate.
How do you convert from Denary to Hexadecimal?
Divide number by 16 and add remainder.
e.g. 43/16 = 2 + 11 = 2B
(11 = remainder in the example)
How do you convert from Binary to Hexadecimal?
Divide binrary number into 2 (2 x 4 digits)= 0011 1100 (Use 8421 place values) and then add to make up the 2 hex digits.
What is a bit?
An individual digit in a binary value.
Used to represent ON + OFF voltage signals om a computer.
What is a byte
- 8 Bits grouped together.
- Can group 2 or more bytes together to hold larger values.
What is a fixed bit?
extra zeros that pad the data at the front. So that the binary can be a full byte.
How big is a Kilobyte?
10^3 = 1,000 bytes
KB = Kilobyte
How big is a Megabyte?
10^6 = 1,000,000 Bytes
MB = Megabyte
How big is a Gigabyte?
10^9 = 1,000,000,000 Bytes
GB = Gigabyte
How big is a Terabyte?
10^12 = 1,000,000,000,000 Bytes
TB = Terabyte
How big is Kibibyte?
2^10 = 1,024 Bytes
KiB = Kibibyte
How big is a Mebibyte?
2^20 = 1,048,576
MiB = Mebibyte
How big is a Gibibyte?
2^30 = 1,073,741,824
GiB = Gibibyte
How big is a Tebibyte?
2^40 = 1,099,511,627,776
TiB = Tebibyte
What is ASCII?
- American Standard Code for Information Interchange.
- Established in 1963 to encode symbols found in the english Alphabet.
- 7 bit = 2^7 = 128 possible binary codes
How does ASCII work?
- Every single character on the keyboard is represented by a binary value.
- 1st 32 codes are control characters e.g. Backspace / Enter
- 8th bit introduced later for extra characters. e.g. ©️
What is the purpose of Unicode?
- Introduced to standardise the encoding of characters of all languages.
- Either apply the variable length of 16 bits or 32 bits encoding.
- 1st 128 characters same as ASCII, to improve the adoption of it.
- Every single character in every single language, mathematic + scientific can be represented.
What are the binary addition number rules?
- 1+1 = 0 carry 1
- 1 + 1 + 1= 1 carry 1
- 0 + 0 = 0
What is an overflow error?
The result of an addition is too large for the number of bits the computer works with.
What determines the calculating range?
No. bits determines how many values can be represented in binary.
How much of the range of values can represent the binary values?
- Positive = the full range.
- Negative = half the range.
Max for 8 bit = 127↓10 = 0111 1111
Min for 8 bit = -128↓20 = 1000 0000
How do you do binary subtraction?
Turn the number you are subtracting into its negative form then add the two numbers together.
What are the 3 types of data?
- Elementary
- Composite
- Abstract
What are some examples of an elementary data type?
- e.g Char, Real, Integer, Boolean
What are Structured data types?
- Built in = Strings, Arrays, Lists, Records.
- Mainly made up of Elementary data types.
What is an array?
- An array is an ordered, finite set of elements of a single type
- They are zero indexed (First element at index 0)
- 1D array = linear e.g. [1]
What is a 2D array?
- 2 different indexes (Seperated by commas).
- Like a table e.g [0, 1]
What is a multidimensional array?
- Can define w any no. of dimensions.
- e.g. 3D = hold xyz coordinates, [x, y, z]
- e.g. 4D can hold the sales of branches of a supermarket by country/store/department/year, sales[c, s, d, y] = 23450
What are 4 features of Tuples?
- Ordered set of values.
- May have elements of mixed types.
- Immutable - elements cannot change.
- ## Doesn’t use square brackets.