Font size
WorksheetsY12 CS mmd PC2
Total questions: 111
Worksheet time: 1hrs 17mins
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)
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)
11, 8, 13, 9, 7, 3
12, 6, 8, 1, 3
How many searches would it take to find the number 1?
3, 5, 9, 10, 23
How many comparisons would it take to find the number 9?
4 5 9 6 2 7
4 5 6 2 7 9
4 5 2 6 7 9
11, 8, 13, 9, 7, 3
How many searches will it take to find 10 in [1,3,5,7,10,12,15] using BINARY search?
3
4
5
6
The complexity of Binary search algorithm is
O(n)
O(log n)
O(n2)
O(n log n)
A linear function takes the form
f(n) = an + b
f(n) = an2 +bn + c
f(n) = alog2n
f(n) = a + b
Find the slowest algorithm:
O (n)
O (n^2)
O (n!)
O (2^n)
The number of executions grows extremely quickly as the size of the input increases
Exponential Time
Linear Time
Polynomial Time
Constant Time
What is the worst case running time of the above pseudo code?
O(n)
O(n log n)
O(n2)
O(n3)
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.
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
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.
What will be the output?
name = "Dave"
print (name)
Dave
name
"Dave"
(name)
What is a input?
To plug in something
A function that allows us to ask the user to enter some data
Data displayed on a screen
A routine
A variable must have been assigned (given) a value before that value is referenced (used).
True
False
The correct way to convert user input is:
birth_year = number(input())
birth_year = int(input())
birth_year = (input(int))
birth_year = int(input)
To display the following on screen Hello World! the following command should be used:
print(Hello World!)
print("Hello World" + !)
print("Hello World!")
print"(Hello World!)"
You assign a value to a variable with which symbol
@
==
=
*
The code you use to receive and input from the keyboard
enter()
add()
receive()
input()
Program statements are executed in sequence, one after the other...
True
False
if you receive a NameError when you run your program it means....
A variable has been assigned before it has been referred to
An incorrect name has been chosen
A variable has been referred to before it has been assigned
A language key word has been used
If the coding steps are in the incorrect order, the computer can still execute the program.
True
False
guess=input()
guess=input()
guess=input()
guess=input()
Which word completes this sentence: "Iteration makes code more ___________"
Complex
Efficient
Simple
Straightforward
A FOR loop is....
A COUNT controlled loop
A CONDITION controlled loop
A WHILE loop is....
A COUNT controlled loop
A CONDITION controlled loop
What will the output be for the code shown here?
3,2,1,0
0,1,2,3
3,2,1
1,2,3
What would the output be for the code shown here?
0,1,2,3,4,5,6,7,8,9
1,2,3,4,5,6,7,8,9,10
0,2,4,6,8,10
0,2,4,6,8
Anil is writing a "rock, scissors, paper" program. He wants the game to repeat until the user doesn't want to play anymore. What loop should he use?
a FOR loop
a WHILE loop
Clara is writing a program that will print out the first ten numbers of a times table (chosen by the user). Should she use....
a FOR loop
a WHILE loop
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!")
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 the output of this program be when it is run?
Nothing
Hello, world
It will generate an error
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
