WorksheetsY12 PRE_SANTA mmd
Total questions: 177
Worksheet time: 2hrs 38mins
¬¬A =
A
1
0
¬A
A ∧ A =
A
1
0
¬A
A ∧ ¬A =
A
1
0
¬A
A ∧ 1 =
A
1
0
¬A
A ∧ 0 =
A
1
0
¬A
A v A =
A
1
0
¬A
A v ¬A =
A
1
0
¬A
A v 1 =
A
1
0
¬A
A v 0 =
A
1
0
¬A
A v AB =
A
1
0
¬A
Applying DeMorgan's rule to:
¬(A v B) gives
¬(A v B)
¬A v ¬B
¬A ∧ ¬B
¬(A ∧ B)
Applying DeMorgan's rule to:
¬(A ∧ B) gives
¬(A v B)
¬A v ¬B
¬A ∧ ¬B
¬(A ∧ B)
Simplify the following Boolean expression: ¬B∧¬A∨¬B
¬B∧¬A
¬A∧¬B
¬B∨¬A
¬A∨¬B
¬B
Apply one of De Morgan’s Laws to the following Boolean expression: ¬(A∧C)
¬A ∨ ¬C
¬(A∨C)
¬(A∧C)
¬(A∨¬C)
(¬A∨C)
9.What is the Boolean expression for this logic gate?
A.X=A^B
B.X=A˅B
C.X=A*B
10.What is the Boolean expression for this logic gate?
A.X=˅A
B.X=&A
C.X=¬A
12.How many intermediate outputs do you require to realise the truth table of this logic circuit?
A.1
B.2
C.3
D.4
13.What is the output of gate 1, when A=1 and B=0?
A.0
B.1
14.What is the output of gate 2, when C=1 and D=0?
A.0
B.1
15.What is the output (X) of gate 3, when A=1, B=1, C=1 and D=0?
A.0
B.1
16.What is the output (X) of gate 3, when A=0, B=1, C=1 and D=1?
A.1
B.0
17.When is the output (X) of gate 3 FALSE?
A.A=1, B=0, C=1 and D=1
B.A=1, B=1, C=0 and D=1
C.A=1, B=1, C=0 and D=0
D.A=1, B=0, C=0 and D=0
18.What is the Boolean expression of the circuit shown?
A.X = (A˅B) ^ (C^D)
B.X = (A˅B) ^ (C˅D)
C.X = (A^B) ˅ (C^D)
D.X = (A^B) ˅ (C˅D)
Which of the following logic statement holds good for this truth table?
A.X= (A AND B) OR ((NOT A) AND (NOT B))
B.X= (A OR B) AND ((NOT A) OR (NOT B))
C.X= (A AND B) OR (NOT (A AND B))
Which of the following logic statement holds good for this truth table?
A.X= A˅B˅C
B.X= (A^B^¬C) ˅ (A^¬B^C) ˅ (¬A^¬B^C)
C.X= (A^B^C) ˅ (A^B^C) ˅ (A^B^C)
D.X= (A^B^¬C) ˅ (A^¬B^C) ˅ (¬A^B^C)
Electronic components used to perform Boolean Algorithms.
Adders
Flip-flops
Algorithms
Boolean expression
A memory unit that changes state with each pulse of the clock from 0 to 1.
Adder
Result is true if any of the inputs false.
Select the best description to explain what a binary search algorithm is.
Put the elements in order, check each item in turn.
Put the elements in order, compare with the middle value, split the list in order and repeat.
Elements do not need to be in order, check each item in turn.
Elements do not need to be in order, compare to the middle value, split the list in order and repeat
12 6 8 1 3
How many comparisons would it take to find number 1?
3 5 9 10 23
How many comparisons would it take to find number 9?
1 5 10 13 48 68 100 101
How many comparisons would it take to find number 101?
What will be displayed as output?
What will be displayed as output?
How do bubble sorts work?
They split the list to single elements before piecing them back together, one sublist at a time.
Each item in the list is compared with the following item starting with the last value till the first.
Taking one item at a time from an unsorted list, each new item is compared with the previous until its place is found.
Each item in the list is individually compared with the following item starting with the first value till the last.
What is an advantage of a bubble sort?
It is difficult to implement.
It is fast.
It uses less memory.
It is easier to implement and follow.
How do you calculate the maximum number of passes/iterations? Where n = number of elements in a list.
n - 1
n + 1
n(n+1)
n(n-1)
How many passes are required to sort a list with 5 elements?
5
4
10
2
The following list is to be sorted using a bubble sort:
12 6 8 1 3
What will the list look like after the first iteration/run through the list?
6 8 1 3 12
6 12 1 8 3
1 3 6 8 12
6 8 1 12 3
Why does a bubble sort do a final pass even when the data is in the correct order?
To save the data.
It does not recognise that the data is in order until the final pass requires no changes.
It needs to do this to put the data back in to a list.
To annoy the user.
What is a disadvantage of a bubble sort?
It takes a long time to implement.
It is difficult to follow and understand.
It uses less memory.
It requires many operations to complete.
How do merge sorts work?
They split the list to single elements before piecing them back together, one sublist at a time.
Each item in the list is compared with the following item starting with the last value till the first.
Taking one item at a time from an unsorted list, each new item is compared with the previous until its place is found.
Each item in the list is individually compared with the following item starting with the first value till the last.
The following two lists are to be merged, which element first goes into the new merged list?
List 1
2 4 7 9
List 2
1 6 8 12
0
1
2
3
The following two lists are to be merged, which element will be in position 5 in the new merged list?
List 1
2 4 7 9
List 2
1 6 8 12
8
7
6
4
Which of the following is an advantage of merge sorting?
It is cheap (computationally).
It's easy to understand.
It speeds up sorting slow-access data e.g. tape drive or hard disk.
Good for sorting slow-access data e.g. tape drive or hard disk.
For which of the problems would the bubble sort algorithm provide an appropriate solution. Choose all that apply.
Arranging a deck of cards from the lowest to the highest value cards.
Looking up a name in the phone book.
Sorting a stack of paper money into denominations -- i.e., £5, £10, £20 etc.
Sorting a basket of laundry into socks, shirts, shorts, and sheets.
Arranging books on a bookshelf by author's last name.
For what purpose would a merge sort algorithm be used?
To list items alphabetically.
To reorder a single list.
To combine identical lists together.
To reorder multiple lists into a singular ordered list.
Where would a merge sort be used?
To arrange files in a cupboard.
To arrange data in a computer folder.
To sort data on the fly.
To sort data that is too large to store in memory.
What is a disadvantage of merge sort?
It can take up to half the amount of memory than that of the original list.
It is the best for sorting data that is normally accessed sequentially.
It can take up to double the amount of memory than that of the original list.
It is the worst at sorting data that is normally accessed sequentially.
Which line best represents the time complexity n!
Orange
Blue
Green
Red
Pink
Which line best represents the time complexity log n
Orange
Blue
Green
Red
Pink
Which line best represents the time complexity n
Orange
Blue
Green
Red
Pink
Find the slowest time complexity
O (n)
O (n^2)
O (n!)
O (2^n)
Indicate constant time complexity in terms of Big-O notation
O(n)
O(1)
O(log n)
O (n^2)
Which notation is consistent for every execution?
O (n)
O (n^2)
O (1)
O (2^n)
Which notation grows in proportion to the size of the input
O (n)
O (n^2)
O (1)
O (2^n)
Which notation would you usually use for a nested loop?
O (n)
O (n^2)
O (1)
O (2^n)
Indicate polynomial time complexity in terms of big-O notation
O (n!)
O (1)
O (n^2)
O (log n)
When calculating the Big-O for an algorithm, which of the following rules is not true?
Focus on the dominant term
Disregard any constants
Focus only on polynomials
Count the number of assignments
A linear function takes the form
f(n) = an + b
f(n) = an2 +bn + c
f(n) = alog2n
f(n) = a + b
A quadratic function takes the form
f(n) = an + b
f(n) = an2 +bn + c
f(n) = alog2n
f(n) = a + b
A logarithmic function takes the form
f(n) = an + b
f(n) = an2 +bn + c
f(n) = alog2n
f(n) = a + b
1 + 3n + n
3 + n
3n
1 + 3n
The graphs shows
O(n^2)
O(n)
O(log n)
O(1)
O(n log n)
The graphs shows
O(n^2)
O(n)
O(log n)
O(1)
O(n log n)
The graphs shows
O(n^2)
O(n)
O(log n)
O(1)
O(n log n)
The graphs shows
O(n^2)
O(n)
O(log n)
O(1)
O(n log n)
The graphs shows
O(n^2)
O(n)
O(log n)
O(1)
O(n log n)
No matter how large the input is, the time taken doesn’t change.
Quadratic
Linear
Logarithmic
Constant
Linearithmic
For every element, you are doing a constant number of operations, such as comparing each element to a known value.
Quadratic
Linear
Logarithmic
Constant
Exponential
The time taken will double with each additional element in the input data set.
Quadratic
Linear
Logarithmic
Constant
Exponential
Which is correct for increasing time complexity.
O(1), O(log n), O(n), O(n log n), O(n^2)
O(log n), O(n log n), O(n)
O(n), O(n log n), O(n^2)
O(1), O(n), O(log n)
The red line on the graph shows which Big O time complexity?
Linear
Linearithmic
Logarithmic
Constant
Quadratic
The yellow line on the graph shows which Big O time complexity?
Linear
Linearithmic
Logarithmic
Constant
Quadratic
What algorithm does Google Maps use?
Dijkstra's
Distance-Vector
A*
D*
Select all correct applications of a shortest-path algorithm
Navigation
NPC control in gaming
Sending data packets
Financial investment choices
AI neural network training
Which type of queue is used in Dijkstra's Algorithm?
Priority
Circular
Linear
Which of the following could a weighted node represent within a path finding algorithm?
Time
Cost
Steps
Distance
Starting at node B, what is the minimum cost to reach node F?
8
9
4
6
Starting at node A, which is the shortest path to reach node E?
a-b-e
a-c-e
a-c-d-e
a-c-d-b-e
guess=input()
guess=input()
guess=input()
guess=input()
Tara has written a "Hide and Seek Simulator" - what will happen when she runs it?
It will print "1,2,3,4,5,6,7,8,9,10 Coming ready or not!"
The program will not run
It will print "1,2,3,4,5,6,7,8,9,11 Coming ready or not!"
It will print ("10 Coming ready or not!")
What does the following code do? myAge = int (myAge)
Converts the var (variable) myAge to a string
Converts the var (variable) myAge to a integer
Converts the var (variable) myAge from a integer to a string
Converts the var (variable) myAge to if statement
Which of the following is an advantage of using local variables?
They allow the variable to be used throughout the whole program
They allow variable identifiers to be reused each time
They are easier to program than global variables
A wider range of data types can be used
What term is used to describe data passed into/out of a program?
Variable
Loop
Constant
Parameter
Leo wants to create a subroutine that will roll a dice. Which syntax is correct?
def dice roll ():
def diceroll ()
def diceroll ():
def diceroll []:
What would the output be from the program shown here? (assuming that the user enters "John" and "Smith"
John
Smith
John Smith
Error
What would the output be from this program?
Error
Hello
Hello, World
World
What is the difference between a subroutine and a function?
They are the same thing
A subroutine passes values back out to the program, a function does not
A function passes values back out to the program, a subroutine does not
A function can run without being called
What will be the output of this program if the user enters "Han" and then "Solo"?
An error
Nothing
first surname
Han Solo
Which of the following statements is not true?
Functions/subroutines are examples of reusable code
Functions and subroutines are always appropriate in programs
Using functions/subroutines make it easier to "deconstruct" a problem into smaller pieces
They can make programs easier to read and understand
What would the output be for the following program if the user enters 4 and 6?
10
14
16
error
Which of the following is NOT a reason that loops are useful when writing code?
Loops help us write the same program with less lines of code.
Loops let us make shapes of multiple sizes.
Loops make it easier to alter code once it’s written.
Loops make our code easier to read.
If Tracy starts at the left edge of the canvas and moves forward 50 pixels, how many times will this code need to be repeated to have Tracy reach the right edge of the canvas?
4 times
8 times
12 times
16 times
If I use the command right(180), which way will Tracy turn?
She will turn in a circle.
She will turn around.
She will turn to face up
She will turn to face left
What is a program?
A series of a step-by-step instructions that tell a computer how to solve a task
A video that is watched on a computer
A flowchart written on a computer
The make and model of a computer
print("3+4")
What command is used to access a library of functions?
import
load
get
library
What are the 3 programming constructs?
input ,process, output
sequence, selection, iteration
variable, constant, value
code, test, review
Consider the file "d://test.txt" with the contents as given below:
Hi there,
I am loving Python.
Python is Simple
Choose the correct output from the above code snippet from the given options:
Read String is : Hi there,
Read String is : Python is simple.
Syntax error
Read String is : Hi there,
I am loving Python.
Python is simple.
Consider the file "d://test.txt" with the contents as given below:
Hi there,
I am loving Python.
Python is Simple
Choose the correct output from the above code snippet from the given options:
Read String is : Hi there
Read String is : Hi there,
Syntax error
Hi there,
I am loving Python.
Python is simple.
Consider a file test.txt in D Drive with the following contents:
I Love Python
Choose the output for the following Python code from the given options(Select all applicable):
Stmt2 prints the contents of the file test.txt
Stmt5 will print number of tokens(words) in the file separated by a space ' '
Stmt6 should be uncommented to close the open file.
Stmt3 results in an error
Consider a file read.txt in D Drive with the following contents:
Banana
Apple
Grapes
Choose the output for the following Python code from the given options:
{}
{0: 'Banana', 1: 'Apple', 2: 'Grapes'}
[0: 'Banana', 1: 'Apple', 2: 'Grapes']
{'Banana':0, 'Apple':1, 'Grapes':2}
Consider a file read.txt in D Drive with the following contents:
Banana
Apple
Grapes
Choose the output for the following Python code from the given options:
[]
['Banana', 'Apple', 'Grapes']
{'Banana', 'Apple', 'Grapes'}
Error
Consider a list, fruits=["Mango", "Banana", "Guava", "Strawberry"]. Match the following:
a. fruits[-4:]
b. fruits[-2:]
c. fruits[-4:-1]
d. fruits[1:4]
Select the correct answer for a, b, c & d
['Banana', 'Guava', 'Strawberry']
['Mango', 'Banana', 'Guava', 'Strawberry']
['Mango', 'Banana']
['Mango', 'Banana', 'Guava']
['Guava', 'Banana', 'Mango']
Assume the following list definition:
a = ['foo', 'bar', 'baz', 'qux', 'quux', 'corge']
print(a[4::-2])
a[:] is a
max(a[2:4] + ['grault'])
print(a[-5:-3])
List a is defined as follows:
a = ['a', 'b', 'c']
Which of the following statements adds 'd' and 'e' to the end of a, so that it then equals ['a', 'b', 'c', 'd', 'e']:
a += 'de'
a += ['d', 'e']
a.append(['d', 'e'])
a[len(a):] = ['d', 'e']
a.extend(['d', 'e'])
What gets printed?
names = ['Amir', 'Barry', 'Chales', 'Dao']
print(names[-1][-1])
A
r
Amir
Dao
o
What gets printed from the above piece of code?
11
12
21
22
33
names1 = ['Amir', 'Barry', 'Chales', 'Dao']
loc = names1.index("Edward")
print(loc)
-1
0
4
Edward
An exception is thrown
Which of the following are true of Python lists?
These represent the same list:['a', 'b', 'c'] ['c', 'a', 'b']
A given object may appear in a list more than once
All elements in a list must be of the same type
A list may contain any type of object except another list
There is no conceptual limit to the size of a list
You have a list a defined as follows:
a = [1, 2, 7, 8]
Write a Python statement using slice assignment that will fill in the missing values so that a equals [1, 2, 3, 4, 5, 6, 7, 8].
(a)
List a is defined as follows:
a = [1, 2, 3, 4, 5]
Select all of the following statements that remove the middle element 3 from a so that it equals [1, 2, 4, 5]:
a[2:2] = []
del a[2]
a[2] = []
a[2:3] = []
a.remove(3)
