Docsity

C949 Data Structures and Algorithms Pre Assessment - Multiple Choice, Exams of Advanced Education

Toggle sidebar
bg1
1 / 35
C949 Data Structures and Algorithms Pre
Assessment - Multiple Choice
1.
D:
Which
statement
describes
a
queue
data
structure?
A.)
It
is
a
sequence
of
elements
in
which
insertion
and
deletion
takes
place
at
one
end.
B.)
It
is
a
sequence
of
elements
in
which
insertion
and
deletion
takes
place
at
both
ends.
C.)
It
is
a
sequence
of
elements
in
which
insertion
can
take
place
anywhere
in
the
sequence
and
deletion
takes
place
only at the front.
D.)
It
is
a
sequence
of
elements
in
which
insertions
can
take
place
only
at
the
back
end
and
deletions
can
take
place
only at the front end.
2.
B:
Which
data
structure
allows
inserting
and
deleting
data
elements
at
both
the
front
and
the
rear?
A.)
Trees
B.)
Deques
C.)
Stacks
D.)
Queues
3.
C:
Which data structure allows elements to be inserted and deleted from one end and provides
no direct access
to the other end?
A.)
List
B.)
Deque
C.)
Stack
D.)
Queue
4.
A:
What are the oflcial indexes for the list list01 given this
declaration? int[ ] list01 = {0, 2, 4, 6, 8, 10};
A.)
0,
1,
2,
3,
4,
5
B.)
0,
2,
4,
6,
8,
10
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23

Partial preview of the text

Download C949 Data Structures and Algorithms Pre Assessment - Multiple Choice and more Exams Advanced Education in PDF only on Docsity!

1 / 35

C949 Data Structures and Algorithms Pre

Assessment - Multiple Choice

  1. D: Which statement describes a queue data structure? A.) It is a sequence of elements in which insertion and deletion takes place at one end. B.) It is a sequence of elements in which insertion and deletion takes place at both ends. C.) It is a sequence of elements in which insertion can take place anywhere in the sequence and deletion takes place only at the front. D.) It is a sequence of elements in which insertions can take place only at the back end and deletions can take place only at the front end.
  2. B: Which data structure allows inserting and deleting data elements at both the front and the rear? A.) Trees B.) Deques C.) Stacks D.) Queues
  3. C: Which data structure allows elements to be inserted and deleted from one end and provides no direct access to the other end? A.) List B.) Deque C.) Stack D.) Queue
  4. A: What are the oflcial indexes for the list list01 given this declaration? int[ ] list01 = {0, 2, 4, 6, 8, 10}; A.) 0, 1, 2, 3, 4, 5 B.) 0, 2, 4, 6, 8, 10

2 / 35

C.) 1, 2, 3, 4, 5, 6

D.) 2, 4, 6, 8, 10, 12

  1. A: Which abstract data type (ADT) has elements of the same type so that the elements can be retrieved based on the index or position? A.) List B.) Bag C.) Stack D.) Queue
  2. C: Which data structure allows insertion and removal from only one end of the data structure? A.) List B.) Queue C.) Stack D.) Deque
  3. C: Which data type does the mystery function return?return_type mystery (int R) { int NumUnits = R; return NumUnits * 3.14; } A.) Byte B.) String C.) Double D.) Boolean
  4. C: Which category of data does ("FB", 75.00, 75.03, 74.90) represent in the pseudocode? import datetime def middle(stock, date): symbol, current, high, low = stock return (((high + low) / 2), date)

4 / 35 int x,y,z; x=y=z= 0; A.) Ternary B.) Assignment C.) Comparison D. Equality

  1. C: What is the most eflcient data type to use for this data set of a fixed size in Java? a = [0, 0, 1, 4, 7, 16, 31, 64, 127] A.) List B.) Tuple C.) Array D.) Dictionary
  2. D: Which data type is appropriate for this array to store the given data? a = ["AF", "71", "BC", "157", "BA", "253"] A.) Byte B.) Char C.) Short D.) String
  3. A: Which data type is appropriate for the given data set? a = [1, 717, 23, 12, 314, 6] A.) Int B.) Byte C.) Char D.) Boolean

5 / 35

  1. B: Which data type should be used for this object? days = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"} A.) Float B.) String C.) Integer D.) Boolean
  2. C: Which data type should be used for this variable? phoneNum = "212-555-1212" A.) Long B.) Short C.) String D.) Integer
  3. D: What is true about garbage collection? A.) It is often portrayed as the same as manual memory management. B.) It is no longer a primary concern since memory is very inexpensive. C.) It is scheduled to take place at regular time intervals to reclaim memory. D.) It reclaims memory from data structures implemented using linked allocations.
  4. B: What is true about a data structure implemented using linked allocation? A) Elements may not be added once the data structure is filled. B.) Storage is allocated using pointers to new locations as needed. C.) The amount of memory used is no greater than a sequential allocation version. D.) An empty structure uses more memory compared to a version using sequential allocation.
  5. B: What are the array elements corresponding to the mid-values in the first and second iterations of a binary search in an array arr = {45, 77, 89, 90, 94, 99, 100} and key = 100? A.) 89 and 94 B.) 90 and 99

7 / 35 C.) It is a Computing object that is already null, which does not require garbage collection. D.) It is a Computing constructor that has no parameters, and is not available for garbage collection.

  1. D: What are the mid-values in the first and second levels of recursion in this binary search? int arr = {46, 76, 89, 90, 94, 99, 100} and key = 99 A.) 89 and 94 B.) 89 and 99 C.) 90 and 94 D.) 90 and 99
  2. D: Which data set is represented using the dictionary data type? A.) A set of book titles B.) A set of Celsius temperatures C.) A set of soda cans in a refrigerator D.) A set of students and their test scores
  3. B: What is a characteristic of keys in an associative dictionary data type? A.) They are unique and mutable. B.) They are unique and immutable. C.) They are non-unique and mutable. D.) They are non-unique and immutable.
  4. D: Which method can be used to take a value out of a dictionary? A.) D1[key].pop(value) B.) D1[key].pull(value) C.) D1[key].delete(value) D.) D1[key].remove(value)
  5. C: Given this data dictionary in Python: dict = {'white':0x0000, 'black':0x1111}

8 / 35 Which command/function generates the output ['white','black']?

10 / 35

  1. A: What is an attribute of a binary tree? A.) Each node has at most two children. B.) The root node is empty in a full tree. C.) The leftmost child is null in a full tree. D.) The rightmost child is null in a full tree.
  2. C: Which data structure uses a last in, first out (LIFO) removal of items? A.) Tree B.) Queue C.) Stack D.) Dictionary
  3. B: Given: heapList = [22, 33, 44, 55, 66] Which index is the right child of item 22? A.) 33 B.) 44 C.) 55 D.) 66
  4. A: Items were added sequentially in this stack starting with 'ham': 'sausage' 'toast' 'eggs ' 'ham' What is the correct order of contents after the push operation is performed with the value 'bacon'? A.) 'bacon'

11 / 35 'sausag e' 'toast'

13 / 35 A.) "dog" B.) "cat" C.) "rabbit" D.) "bird"

  1. B: Which sequence of letters represents preorder traversal of the nodes of this tree? A.) A B C D E F G H I

14 / 35

B.) A B C D F E G I H

C.) B A D F C I G E H

D.) B F D I G H E C A

  1. B: An array soc of size 1009 is used where the index is an integer in [0,1008] and the hash- function key%1009. Where will the data associated with the key given by the last 4 social security digits '2023' be stored? A.) In soc[4] B.) In soc[5] C.) In soc[1009] D.) In soc[2023]
  2. C: A stack s, a queue q, and a max value priority queue p each have a single 3 in them. Next s.push(4), q.push(4), and p.push(4) are executed. What is the triple (s.pop(), q.pop(), p.pop())? A.) (3,4,4) B.) (4,3,3) C.) (4,3,4) D.) (4,4,3)
  3. C: This stack reads left to right with the top to the right: 'gree n' 'yello w' 'blue ' 'red' What could be the stack after a push operation?

16 / 35

  1. A: Items were added sequentially onto the stack starting with 'red': 'gree n' 'yello w' 'blue ' 'red' What is the stack after a pop operation? A.) 'yellow' 'blue' 'red' B.) 'green' 'yellow' 'blue' C.) 'purple' 'green' 'yellow' 'blue' 'red' D.) 'green' 'yellow' 'blue' 'red' 'purple'
  2. D: Which command helps to speed up comparisons using dictionary keys during a

17 / 35 dictionary (d) lookup in this pseudocode clip? h = hash(key) for pair in d: if h == pair[0]: return pair[1]

19 / 35 C.) Contains(Object x) D.) Set(int index, Object x)

  1. B: When should a dictionary be used instead of a list? A.) When the program only uses strings B.) When the program uses key-value pairs as its data C.) When the programmer needs to delete some of its data items D.) When the program needs to quickly modify the contents of its data structures
  2. C: What is the logical first step in an algorithm that extracts all the positive values from a given list of numbers? A.) Initialize the result to 0 B.) Set the current number to 0 C.) Initialize the result to an empty list D.) Check that the given list contains at least one number
  3. A: What is displayed when n = 2 in this pseudocode? for(int i = 2; i <= n; i++){ for(j = 0; j <= n;){ display j; j = j + n/2; the division is integer division, decimal part neglected } } A.) 0, 1, 2 B.) 1, 0, 2 C.) 1, 2, 0 D.) 0, 2, 1
  4. D: Given a set of numeric data and two declared variables: small and max, what is the logical first step in an algorithm that finds the smallest number? A.) Declaring a variable for small B.) Setting the variable equal to zero

20 / 35 C.) Determining the maximum number D.) Checking that the list contains at least one number

  1. A: What is the logical last step in an algorithm that averages the high temperatures for 10 days and displays the average high temperature? A.) Printing the temperature B.) Declaring the variable temperature C.) Computing the average high temperature D.) Conditionally accepting the average high temperature
  2. B: What is the output of the pseudocode below if the variables declared in the main program are global? Main Declare X as Integer, Y as Integer Set X = 1 Set Y = 2 Call Sub(X, Y) Write X Write Y End Program Subprogram Sub(Integer Num1, Integer Num2 as Reference) Declare X as Integer Set Num1 = 3 Set Num2 = 4 Set X = 5 Write X End Subprogram A.) 5 34 B.) 5 14