stuff bad Flashcards
A new employee called CHRISTOPHER WAY is added to a hash table, however the key generated is the same as that of CAMERON WALKER. Explain what the affect of this would be and suggest a possible solution.
- the two names would be written to the same address
- the new name would overwrite the old one
- store the new name in the next open address in the hash table
- store a pointer that points to a list fo values that have the same key
One advantage for storing text data in a file.
human readable
can be opened in a general purpose text editor
Explain what is meant by LIFO
(you must say last in first out)
the most recently added item will be the first on not be accessed. LIFO is a stack
state a set that is infinite.
N OR R (natural or real)
Explain ‘encapsulate what vaires’
means that individual classes should only contain attributes and methods that differ from other classes
State two items that will be stored in the stack frame when a subroutine is stored.
- local variables
- parameters
- return address
Explain what is meant by inheritance
a class/subclass/child class that shares attributes or methods from a base/parent/super class
State the name for adding two vectors
translation
How do you identify a constructor from a class diagram?
The constructor method should always have same identifier as the class
explain what is meant by the base case of a BNF rule
a non-recursive case
or
a case that doesn’t include an example of the definition within the definition
sate the base case of rule 1
1 ::= | _
2 ::= | _
3 ::= a|b|c|d|e|f|g|h|….
State one disadvantage of using a binary search instead of a linear search
list must be sorted
linear search is easier to program
There is an attribute fuellevel explain why there is also a method named getfuellevel()
the fuellevel attribute is private and so can only be accessed within its class.
the getfuelevel method is public and so can be accessed within other classes.
Difference between public, private, protected.
public = can be accessed/called by any class private = can only be accessed/called by that class protected = can only be accessed by derived class/ subclass (and its self)
Describe a typical use for calculating a dot product of two vectors
find the angle between two vectors
give the Cartesian product of
A = {1, 2} and B = {5, 6, 7}
{(1, 5), (1, 6), (1, 7), (2, 5), (2, 6), (2, 7)}
Explain how and why hashing algorithms are often used for storing passwords
HOW
complex hashing algorithms are used to create complex keys
the keys are stored instead of the password
each time the user enters their password, the hashing algorithm is applied and the key is compared to the key that is stored
WHY
in the event of a data breach, only the hash keys can be discovered
a malicious user who is able to access the hash keys, will not be able to login
Describe the difference between association aggregation and composition aggregation
association aggregation describes a ‘has a’ relationship between two classes where both exist independently
in composition aggregation the parent class is composed of the child class object, so if the parents object is destroyed so are the child objects.
Describe two advantages for using procedures and functions in a program. (4 marks)
(in pairs)
- code can be called from different points in the program |
reducing the need to duplicate code
or
- code is easier to update/maintain |
because the programmer only had to update one subroutine no matter how many times its used
or
- easier to debug code |
because an error will likely only need to be found and fixed once
Give two potential disadvantages for storing binary data in a file.
only this program will be able to decode the date/understand
the file can not be read/understood by general purpose software
Describe one advantage of storing binary data in a file
smaller file size
data more secure/ no human readable, so cannot be easily altered
developer has more control over the program/data
State the most appropriate data type for:
12.67
real/float
Explain why it is preferable to use a procedural paradigm rather than a program that does not use procedures.
code can be reused
each change of the code only needs to be changed once
easier to find and debug errors
State two reasons why it is usually preferable that subroutines don’t use global variables?
- easier to reuse in another program.
- subroutine can be used in a library
- the code is easier to understand
- make sure the code is independent of the rest of the program
- more memory efficient
- makes it easier to debug
Describe what is meant by a dictionary data structure
key-value pair, in which the value is accessed via the key
Explain what is meant by the term instantiation.
instantiation is the process of creating an object based on a class | it is carried out using a constructor providing values for each of the attributes.
Explaining what is meant by overriding
overriding is creating a method in a subclass that has the same identifier as a method of a parent class
in order to give the subclass method different functionality
in this case, the subclasses have different attributes to set and so different functionality/code is required