Y1 Flashcards
1What is a variable?
A variable is a named container, held by the computer in a memory location
What is variable scope?
The block of code where the variable can be declared, used and modified
What is a local variable?
variable that is given local scope. A local variable reference in the function or block in which it is declared overrides the same variable name in the larger scope
When should you use local variables and when should you use global variables?
If you feel that a certain variable will take multiple values by passing through various functions then use local variables and pass them in function calls. If you feel that a certain variable you need to use will have constant value, then declare it as a global variable
Why do computers use binary to store data?
Easier to manufacture, therefore cheaper and it is more reliable
Examples of ways to store data using binary?
RAM, hard disk, optical disk and flash memory
What is a data structure?
A way of storing and managing data
What is a data type?
A classification that specifies which type of value a variable has and what type of mathematical, relational or logical operations can be applied to it without causing an error
What is an array?
A set of data items of the same type grouped together using a single identifier. Each of the data items or elements are addressed by the variable name eg myArray and an index. It is static - size is fixed when the structure is created/size cannot change at runtime.
What is a dimension?
The dimension of an array is the number of indices needed to select an element. A one-dimensional has one index. A 1D array is like a column of data. A two-dimensional has two indexes, one for the row and another for the column. A 2D array is like a table of data.
What is a list?
Ordered set of data accessed by index, not fixed size
What is a record?
think database, a record comprises multiple, related attributes (fields/columns) of different data types
What is a tuple?
immutable list (cannot be changed)
How do you declare a 1d array pseudocode(first way)?
array names[3]
names[0] = “Ahmad”
names[1] = “Ben”
names[2] = “Catherine”
How do you declare a 1d array pseudocode(second way)?
array names[3] = [“Ahmad”, “Ben”, “Catherine”]
Show the pseudocode for a linear search
array names[6] = [“Dave”, “Richard”, “Astrid”, “Dima”, “Charlie”, “Paul”]
found = false
for i = 0 to names.length - 1
if (names[i] == “Roberto”) then
print(“Found at index “ + i)
found = true
break // stops the for loop
endIf
next i
if (found == false) then
print(“No matching item is found”)
endIf
First way to declare 2d array
array scores[2][2]
scores[0][0] = 14
scores[0][1] = 80
scores[1][0] = 20
Scores[1][1] = 82
Second way to declare 2d array
array scores[2][2] = [[14, 80],[20, 82]]
Example of data that could be stored in a 2d array?
Scores for a class of students for multiple tests
How many elements would be in the array chores[3][3]
9
Pseudocode for bubble sort?
array myNumbers[6]
for (i = 0 to myNumbers.length-2)
swapped = false
for (j = 1 to myNumbers.length-1-i)
if (myNumbers[j-1] > myNumbers[j])
temp = myNumbers[j-1]
myNumbers[j-1] = myNumbers[j]
myNumbers[j] = temp
swapped = true
endif
next j
if (swapped == false) then
break //breaks out of loop
endif
next i
Disadvantages of bubble sort
In standard form, it’s inefficient as it may continue to makes passes even though the list is sorted (this can be overcome by setting a swaps variable – if swaps are made continue, otherwise stop)
Advantages of bubble sort?
Easy to implement
Good for small data sets that are almost sorted
Thinking concurrently?
What can be done at the same time
Thinking abstractly?
Hiding details and identifying and highlighting key elements
Thinking ahead?
What inputs / outputs will you need
Thinking procedurally?
Order of events / subproblems
Thinking logically?
Decisions to be made
Reason for abstraction?
Reduces complexity of a program / easier to read and understand
Reduces time to find a solution
Reduces design and programming time
Reduces computational resources eg memory, processing power
The above therefore reduces the cost of designing and building the program
Focus on the main purpose of the program
What are the two types of abstraction?
Data abstraction and problem abstraction
What is data abstraction?
Variables: represent real-world values (4.56, “Anna”, “21/01/2019”)
Objects: in Object Oriented Programming (OOP) a class is an abstract representation of something with certain properties (attributes) and operations (methods). (chair, car, dog, person)
Data structures: arrays, linked-lists, stacks and queues.
What is problem abstraction?
When faced with a problem deciding which factors are relevant to the problem and solution
(networks, database systems (E-R diagram), operating systems (device drivers, flight simulator, map, weather system, GPS)
What is primary storage?
Means memory. This is made up of RAM (volatile) and ROM. It is directly accessible by the CPU.
What is secondary storage?
Storage that is non-volatile. It is not directly accessible by the CPU.
What is virtual storage?
Storage that appears to be local but is physically located elsewhere
What is top down design?
Solved by breaking it down into smaller sub-systems
What is top down design an example of?
Decomposition
Advantages of top-down design ?
the problem is easier to understand, program, test and maintain.
Shows clearly how different parts of the problem relate to each other
Division of labour - different teams working on different parts of the problem independently
May make code more modular as it broken into smaller subroutines.
Disadvantages of top-down design
It assumes that the whole solution to the problem is knowable in advance.
Poorly understood programs are hard to decompose.
Not every problem can be broken down in this way, for example event driven programs like GUIs
Symbol for an and gate
upside down v
symbol for an or gate
v
symbol for a not gate
line above or top right corner of a rectangle
What rule are stacks built on
Last in first out
What is adding items to a stack called
push
What is removing items from a stack called
pop
What are some uses of stacks
Back/forward button on browsers
What is a systems development lifecycle?
A framework defining tasks performed at each step in the software development process.
What is the waterfall lifecycle model?
A linear, sequence of stages. Each stage is completed before the next stage begins. Good for small, simple projects where requirements are clear and do not change.
What are agile methods?
Agile development is an umbrella term for a set of methods and practices based on the values and principles expressed in the Agile Manifesto.
What is xp(extreme programming)
An agile methodology for software development that is iterative, focussing on high quality code and customer involvement / feedback.
What is iterative development?
Iterative development is a process, or a method, in which a software product is developed after breaking it down into smaller, easily developable “chunks”. Each chunk is analysed, designed, developed and tested in repeated cycles (iterations).
What is a prototype?
An original or first model of something from which other forms are copied or developed. Early prototypes will likely have reduced functionality.
What is risk analysis?
The process of identifying and analyzing potential issues that could negatively impact a software project. Risk factors in software development include inadequate estimation of time, cost, scope and resources.
What is a methodology?
A system of methods and principles for doing something,
What type of model is the waterfall mode?
Sequential/linear
What is the first stage of the waterfall model?
System and Software requirements. Documenting requirements gathered from questionnaires, observation, and structured interviews. Acceptance tests often paired with requirements.
What is the second stage of the waterfall model?
Feasibility – is it technically viable, economical, legal? How effective the project will be in solving the problem? Can it be done in time?
What is the third stage of the waterfall model?
White/black box, alpha/beta, performance etc
What is the final stage of the waterfal model?
installation, migration, support, and maintenance e.g. corrective, perfective, adaptive maintenance (to keep a software product usable in a changed or changing environment)
Positives of the waterfall model?
Lots of documentation
Easy to schedule and arrange tasks and judge progress
Simple and easy to understand model
Does not require a lot of customer involvement
Negatives of the waterfall model>?
Lots of documentation
No new ideas can be included during development.
Users not involved until testing
Cannot accommodate changing requirements
No working software is produced until late during the life cycle.
Efficient code is not prioritized
What are the 4 values of the agile methods
1.Individuals over processes
2.Working software over documents
3.Customer collab
change
What is xp
Extreme type of agile methodology
Positives of xp
Quality of code should be very high
Testing is continuous which will result in fewer bugs/issues
Sustainable pace - less chance of tired programmers!
Negatives of xp?
Programmers need to be based in same geographic location
Customer needs to provide a representative to work with the development team
When might xp be used
Early implementation is important
When requirements are changing
Can’t be used on a project with a huge staff
When code must be of high quality eg critical systems perhaps in health care
When might the waterfall method be used?
Straight forward projects where requirements are known and understood at the beginning and do not change
When there is no benefit to the customer of having parts of the system available early.
Short projects
What is a queue?
a data structure which uses the operations enqueue() and dequeue()
What type of structure is a queue?
First in first out
What are the error conditions of a queue?
A queue’s error conditions are isEmpty and isFull. If the queue is full you cannot enqueue anything on to it. If it is empty then you cannot dequeue anything from it.
How do queues use priority?
Different items in the queue have different priorities
Is a queue dynamic or static?
Dynamic
Is a queue linear or circular?
It can be either
What are the uses of queues
Printing and cpu processing
What does enqueue(item) do?
add an item to the end of the queue
What does dequeue() do?
remove and return an item from the front of the queue
What does peek() do?
gets the element at the front of the queue without removing it
How many pointers does a queue use?
2 (one at front and one at back) as oppose to a stack which uses 1
What is an entity?
A single object, person, event or thing eg customers, appointments, products about which data is to be recorded. Several tables may relate to a single entity.
What is an atribute?
A specific type of data representing a particular characteristic of each data record. Also known as a field or column.
What is data integrity?
The overall accuracy and completeness of data
What is referential integrity?
A foreign key must refer to an existing primary key. Referential integrity is violated when the primary key to which a foreign key refers no longer exists. A measure of the consistency of the data in a database.
What is a field?
A part of a record that holds data of a specific type about one characteristic of the subject of the record.
What is normalisation?
The process of structuring the data in a relational database according to formal rules, in order to avoid problems of data redundancy which leads to inconsistency and inaccuracy.
Pros of flat file database?
Easy to set up - no knowledge required
Easy to use in code - e.g. CSV files are easy to process
Easy to share, e.g. email attachments
Cons of flat file database?
Duplication of data (data redundancy) which take more time to update eg if Miss Read moves house you have to update her address in multiple rows, can lead to inconsistency eg you forget to update Miss Read’s details in every place they are stored.
Take up more space so more storage is required.
Everyone can see everything (not good if some data is sensitive)
Inefficient – have to have all fields for every record
Can’t perform complex queries as easily
Pros of relational database?
Reduces duplication of data meaning easier to update, accurate, better consistency, less storage space
Can set different access rights for each user for each table
Can index fields for quicker searching
If implemented with DBMS, it will allow concurrent access to the database allowing multiple users
Complex queries can be carried out
Cons of relational databases?
More difficult to correctly set up (normalization is the process of structuring the data in a relational database according to formal rules to avoid problems of data redundancy which leads to inconsistency and inaccuracy (incorrect) and inconsistency (between different fields).
What is secondary key?
is a non key field which is indexed
What do secondary keys do?
Speed up searches however it slows down inserts, updates and deletes as the computer has to write the data and the index
What does using secondary keys do to storage?
An index needs space on hard disk (and much more important) in RAM
What does the insertion sort do that is different?
It does not swap values. (Bubble sort swaps, insertion sort shifts)
Where does the insertion sort begin?
It begins at the second item (index 1) since the first item is already sorted (a list of length 1 can’t not be sorted)
What is the pseudocode for an insertion sort?
for i = 1 to A.length – 1
key = A[i]
j = i - 1
while j >= 0 AND A[j] > key
A[j + 1] = A[j]
j–
endWhile
A[j + 1] = key
next i