Font size
WorksheetsA2 CS Paper 2 MAR 21- mmd
Total questions: 139
Worksheet time: 2hrs 32mins
A procedure that calls itself is called
illegal call
reverse polish
recursive
none of the above
Queue data structure works on
LIFO
FIFO
FILO
none of the above
The following formular is of
left_subtree (keys) ≤ node (key) ≤ right_subtree (keys)
Binary Tree
Complete Binary Tree
Binary Search Tree
All of the above
What is the value of the ROOT node in this Tree?
35
24
42
20
Root
data structure similar to a graph, with no loops.
an object in a graph also known as a vertex
a join of relationship between nodes - also know as an arc
the starting node in a rooted tree structure from which all other nodes branch off./
Tree
data structure similar to a graph, with no loops.
an object in a graph also known as a vertex
a join of relationship between nodes - also know as an arc
the starting node in a rooted tree structure from which all other nodes branch off./
Binary TREE
data structure similar to a graph, with no loops.
an object in a graph also known as a vertex
a join of relationship between nodes - also know as an arc
a tree where each node can only have 2 child nodes attached to it
In preorder traversal of a binary tree the second step is ____________
traverse the right subtree
traverse the left subtree
traverse right subtree and visit the root
visit the root
The decision tree structure begins at a node called the _____.
span
top
root
branch
How many leaf are there in the tree?
1
3
4
7
Which of these tree traversal methods is used to output the contents of a binary tree in ascending order?
Pre-Order
In-Order
Post-Order
Monastic Orders
What are the 3 depth traversals for a tree data structure?
Pre-, In- and Post-order
Pro-, In- and Past-order
Pre-, Out- and Post-order
Pre-, In- and New-order
When traversing a binary tree, which diagram is post-order?
When traversing a binary tree, which diagram is pre-order?
A Data Structure is:
A C++ vector
A way of organizing, storing and performing operations on data.
A function in any programming language
A sequence of steps to solve a problem.
Given a sequence of number below:
50,60,40,70,45,55,30,80,65,35,25,75,85
When creating a binary search tree, what is the height of the tree?
3
4
5
6
Given a binary search tree, insert 27, 15, 63, 99, 70 and 85 (in this order) into the binary search tree. What is the post-order traversal?
5,15,27,34,47,54,63,70,72,75,83,85,88,94,99,101
72,54,34,5,27,15,47,63,70,83,75,88,85,101,94,99
15,27,5,47,34,70,63,54,75,85,99,94,101,88,83,72
15,27,5,47,34,63,54,70,75,85,99,94,101,88,83,72
none of the above
Choose the correct statement
A data structure is a specialised format for organising and storing data
A data structure is a specialised format for organising and storing information
A data structure is a format for organising and storing only one data type
A data structure is too complicated to truly understand or use
What is the degree of vertex 4?
3
4
5
7
Which two vertices are adjacent vertices?
5 is adjacent to 6
3 is adjacent to 6
4 is adjacent to 1
3 is adjacent to 2
The graph represents the following vocabulary term.
Cycle
Path
Complete Graph
Complete Bipartite Graph
What is the weight of the shortest path from A to F?
5
7
9
11
Which vertices are adjacent to E?
B and C
B, C, D, and A
B
A, B, C, D, F, G
Which is an example of a disconnected graph?
None are disconnected graphs
Which of the following is not a style of graph traversal in computing?
Breadth-First
Depth-First
Height-First
Which method of graph traversal makes use of a stack?
Depth-First
Breadth-First
Which method of graph traversal makes use of a queue?
Depth-First
Breadth-First
Which order of traversal is correct using depth-first?
A B C G D E F
A B D C E C G
Which of the following beginnings to a graph traversal would not be correct for depth-first?
A B C G
A D F
A E D F
A B D C
Which order of traversal is correct using breadth-first?
A B D E C F G
A B C G D E F
A has been visited what happens next
Visit B
Visit D
Visit E
Visit C
With breadth-first traversal, which node will be visited next?
C
F
G
With breadth-first traversal, which node will be visited next?
C
F
G
A _________ is a simple path is which the first and last vertices are same
Cycle
Circular
If the elements “A”, “B”, “C” and “D” are placed in a queue and are deleted one at a time, in what order will they be removed?
ABCD
DCBA
DCAB
ABDC
In linked list implementation of a queue, where does a new element be inserted?
At the head of link list
At the centre position in the link list
At the tail of the link list
None of the mentioned
In linked list implementation of a queue, from where is the item deleted?
At the head of link list
At the centre position in the link list
At the tail of the link list
None of the mentioned
In linked list implementation of a queue, the important condition for a queue to be empty is?
FRONT is null
REAR is null
LINK is empty
None of the mentioned
In a circular queue, how do you increment the rear end of the queue?
rear++
(rear+1) % Number of Item
(rear % Number of Item)+1
rear–
What is the term for inserting into a full queue known as?
overflow
underflow
null pointer exception
all of the mentioned
Let the following circular queue can accommodate maximum six elements with the following data
front = 2 rear = 4
queue = _______; L, M, N, ___, ___
What will happen after ADD O operation takes place?
front = 2 rear = 5
queue = ______; L, M, N, O, ___
front = 3 rear = 5
queue = L, M, N, O, ___
front = 3 rear = 4
queue = ______; L, M, N, O, ___
front = 2 rear = 4
queue = L, M, N, O, ___
A circular queue is implemented using an array of size 10. The array index starts with 0, front is 6, and rear is 9. The insertion of next element takes place at the array index.
0
7
9
10
What is the reason for using a "circular queue" instead of a regular one?
running time of enqueue() is improved
reuse empty spaces
you can traverse all the elements more efficiently
none of the above
In Queue Insertion & Deletion take place at ________________.
same end
first end
different end
last end
One difference between a queue and a stack is:
Queues require dynamic memory, but stacks do not
Stacks require dynamic memory, but queues do not.
Queues use two ends of the structure; stacks use only one.
Stacks use two ends of the structure, queues use only one.
If the numbers 5, 10, 3, 42 are enqueued onto a queue in that order, what does dequeue return?
5
10
3
42
Queue can be implemented using a list?
True
False
What is the term for inserting into a full queue known as?
underflow
overflow
front
rear
The essential condition which is checked before insertion in a linked queue is?
Underflow
Overflow
Front value
Rear value
A queue of characters currently contained a,b,c,d. What would be the contents of queue after the following operationDELETE, ADD W, ADD X, DELETE, ADD Y.
A,B,C,W,Y
A,B,C,D,W
C,D,W,X,Y
W,Y,X,C,D
If front=rear ,then the queue is?
full
undeflow
overflow
empty
What advantage does a linked list have over an array?
Size of the list doesn't need to be mentioned at the beginning of the program
You can add or remove elements from the middle of the list.
The linked list doesn't have a size limit
All of these are true.
Nodes in a linked list contain two things
Direction and a pointer
Data and a pointer
A Pointer and a reference
A pointer and a node
The situation when in a linked list Head==NULL
is
Full
Empty
Half full
saturated
In the above image what will be printed when Head->next->data?
83
9
27
Error
What is the operation of the below statements?
Insert a new node to the front of a linked list
Create a new node for a linked list
Insert a new node to the end of the linked list
Calculate the size of a linked list
3, 5, 9, 10, 23
How many comparisons would it take to find the number 9?
A recursive function is
A function that calls other functions in a recursive way.
Any function that calls itself is called recursive
A function that has a base case or termination condition
None of the above
Recursion is:
is a computer programming technique involving the use of a procedure, subroutine, function, or algorithm that calls itself in a step having a termination condition.
is a computer programming technique involving the use of a procedure, subroutine, function, or algorithm that calls other function in a step.
is a computer programming technique involving the use of a procedure, subroutine, function, or algorithm that calls itself in a step having no termination condition.
None of the above
The program may run out of memory in a
non-recursive function call
recursive function call
condition when too many variables are declared
none of the above
Which of the following condition is true?
Recursion is always better than iteration.
Recursion uses more memory as compared to iteration.
Recursion uses less memory as compared to iteration.
Iteration is always better and simpler than recursion.
Which of the following problems can be solved using recursion?
finding Nth number of the Fibonacci sequence
finding the factorial of a number
finding the length of a string
all of the above
Recursion is similar to which of the following?
if-else
switch-case
loops
none of the above
What would happen if the base case if not defined in the recursive method?
Stack Overflow
Stack Underflow
Program Crashes
None of the above
The number of recursive calls is limited to the ____ of the stack.
time
ability
quality
size
Which of the following sorting algorithms use recursion?
Selection Sort
Insertion Sort
Mergesort
What is the returned value of recmethod(5)?
68
70
75
82
What is returned as a result of the call mystery(4,6)?
2
3
4
1
What order of complexity does this graph represent?
Exponential
Polynomial
Linear
Logarithmic
{2, 3, 5, 8, 9, 11};
How would you access the fourth element in nums
A Queue can only store 6 data items. The Queue is sent 4 data items: Bert, Cynthia, Cedric and Albert. Where does the "Front" pointer point?
0
1
2
3
A Queue can only store 6 data items. The Queue is sent 4 data items: Bert, Cynthia, Cedric and Albert. Where does the "Rear" pointer point?
0
1
2
3
A Queue can only store 6 data items. The Queue is sent 4 data items: Bert, Cynthia, Cedric and Albert. Where does the "Front" pointer point?
Bert
Cynthia
Cedric
Albert
A Queue can only store 6 data items. The Queue is sent 4 data items: Bert, Cynthia, Cedric and Albert. Where does the "Rear" pointer point?
Bert
Cynthia
Cedric
Albert
A Queue can only store 6 data items. The Queue is sent 4 data items: Bert, Cynthia, Cedric and Albert. Where does the "Rear" pointer point if a deQueue operation is performed.
Bert
Cynthia
Cedric
Albert
A Queue can only store 6 data items. The Queue is sent 4 data items: Bert, Cynthia, Cedric and Albert. Where does the "Front" pointer point if a deQueue operation is performed.
Bert
Cynthia
Cedric
Albert
Which is NOT an elementary data type?
String
Char
Boolean
Int
Float
What does the term immutable mean?
unable to be changed
unable to speak
can be modified
can be increased in size
What is a tuple?
A data value which can be modified.
A data value which cannot be modified.
An immutable data structure that contains related elements.
A data structure that can only hold 3 elements.
Which data structure cannot have elements of different data types?
Array
Tuple
Record
Stack
Queue
In terms of data structures, what does mutable mean?
A mutable structure is one which can only have data added to it
A mutable structure is one which is fixed in size
A mutable structure is one which allows data to be added, edited, deleted or moved
Which of the following is not a valid array?
names=("Tom","Ali","22","Connie")
scores=(2,3,5,4,2,1)
names=("Tom", "Ali", 22, "Connie")
Which is NOT an operation performed on a queue?
Add
Remove
isFull
isEmpty
push
Which is NOT a type of queue?
Priority
Linear
Circular
Semaphore
In a dynamic data structure where is the memory allocated from to hold the data structure?
Heap
Cache
Secondary Storage
ROM
Virtual Memory
What is an advantage of a circular queue?
Free space can be reused
Easy to program
Gives preference to important items
It is static
A data structure which consists of a collection of elements, typically in fixed number and sequence and typically indexed by names.
Array
Record
Queue
List
Stack
Which of these data structures is LIFO?
Stack
Queue
Binary Tree
Double linked list
In a Hash Table what happens if the hashing algorithm generates the same address for different primary keys?
this situation is impossible
collisions
errors
the hashing algorithm is run again
In a Hash Table, what ideally should the size of the table be?
same size as the amount of data to hold
an odd number
an even number
a prime number
Which mathematical function do all hashing algorithms use?
MOD
DIV
EXP
COS
RAND
Which of these data structures is LIFO?
Stack
Queue
Binary Tree
Double linked list
What is the name of the function to add an item to a stack?
push()
pop()
peek()
isFull()
isEmpty()
What is the name of the function to remove an item from a stack?
push()
pop()
peek()
isFull()
isEmpty()
An item of data which is passed to a procedure or function.
Local variable
Parameter
Global variable
Selection
What does inheritance mean in python?
The transfer of the characteristics of a class to other classes that are derived from it.
A variable that is defined inside a method and belongs only to the current instance of a class
The creation of an instance of a class.
It is what you sometimes get when a relative passes away
What is an instance in python?
A special kind of function that is defined in a class definition.
The creation of an instance of a class.
An individual object of a certain class. An object obj that belongs to a class Circle, for example, is an instance of the class Circle.
A moment in time
What is instantiation in python?
The creation of an instance of a class.
The transfer of the characteristics of a class to other classes that are derived from it.
A variable that is defined inside a method and belongs only to the current instance of a class.
A unique instance of a data structure that's defined by its class. An object comprises both data members (class variables and instance variables) and methods.
What is a method in python?
a way of doing something
a special kind of function that is defined in a class definition
the creation of an instance of a class
orderliness of thought or behavior; systematic planning or action
What is an object in python?
A unique instance of a data structure that's defined by its class. An object comprises both data members (class variables and instance variables) and methods.
A special kind of function that is defined in a class definition.
The assignment of more than one function to a particular operator.
An individual object of a certain class. An object obj that belongs to a class Circle, for example, is an instance of the class Circle.
Which of the following is not done by decomposition?
Allows multiple people to work on the problem together
Disregards non-essential information
Breaks the problem down into smaller tasks
Which of the following is not done by abstraction?
Identifies essential details
Disregards non-essential information
Breaks the problem down into smaller tasks
When drawing a dog, which of the following characteristics is non-essential?
Dogs have 4 paws
Dogs have fur
Dogs have brown fur
When designing a building that must be accessible for wheelchairs, which of the following characteristics is non-essential?
Number of doors
Number of walls
Number of wall paintings
Decomposition allows the entire task to be completed as _____
A Team
A Whole
Quickly as possible
A school database has lots of information on students, the data manager needs to use abstraction. What data should she leave out?
Age
Guardian's phone numbers
Classes
Eye colour
What is a parameter in a function?
input value to a function for the function’s execution
a variable used to send information to a function
the name of the function
the name of the main program calling the function
