WGU C949 DATA STRUCTURES AND ALGORITHMS I OBJECTIVE ASSESSMENT EXAM 300 QUESTIONS AND CORRECT DETAILED ANSWERS WITH RATIONALES (VERIFIED ANSWERS) |AGRADE

C949 Data Structures and Algorithms PreAssessment – Multiple Choice
Study online at https://quizlet.com/_935bch

  1. Which statement describes a queue data structure? D
    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. Which data structure allows inserting and deleting B
    data elements at both the front and the rear?
    A.) Trees
    B.) Deques
    C.) Stacks
    D.) Queues
  3. Which data structure allows elements to be inserted C
    and deleted from one end and provides no direct access to the other end?
    A.) List
    B.) Deque
    C.) Stack
    D.) Queue
  4. What are the official indexes for the list list01 given A
    this declaration?
    int[ ] list01 = {0, 2, 4, 6, 8, 10};
    A.) 0, 1, 2, 3, 4, 5
    B.) 0, 2, 4, 6, 8, 10
    C.) 1, 2, 3, 4, 5, 6
    D.) 2, 4, 6, 8, 10, 12
    1 / 22
    C949 Data Structures and Algorithms PreAssessment – Multiple Choice
    Study online at https://quizlet.com/_935bch
  5. Which abstract data type (ADT) has elements of the A
    same type so that the elements can be retrieved based
    on the index or position?
    A.) List
    B.) Bag
    C.) Stack
    D.) Queue
  6. Which data structure allows insertion and removal C
    from only one end of the data structure?
    A.) List
    B.) Queue
    C.) Stack
    D.) Deque
  7. Which data type does the mystery function return?re- C
    turn_type mystery (int R)
    {
    int NumUnits = R;
    return NumUnits * 3.14;
    }
    A.) Byte
    B.) String
    C.) Double
    D.) Boolean
  8. Which category of data does (“FB”, 75.00, 75.03, 74.90) C
    represent in the pseudocode?
    import datetime
    def middle(stock, date):
    symbol, current, high, low = stock
    return (((high + low) / 2), date)
    mid_value, date = middle((“FB”, 75.00, 75.03, 74.90),
    datetime.date(2014, 10, 31))
    2 / 22
    C949 Data Structures and Algorithms PreAssessment – Multiple Choice
    Study online at https://quizlet.com/_935bch
    A.) List
    B.) Float
    C.) Tuple
    D.) Operator
  9. Which value is appropriate for Test1 given the expres- A
    sion?
    char Test1;
    A.) ‘L’
    B.) 77
    C.) 6.5
    D.) “value”
  10. Which value is appropriate for the variable middle A
    given the pseudocode?
    function mystery()
    {
    string last;
    string first;
    char middle;
    int phone;
    float rate;
    }
    A.) ‘D’
    B.) ‘Da’
    C.) “david”
    D.) “David”
  11. Which type of operation is represented in the B
    pseudocode?
    int x,y,z;
    x=y=z=100;
    3 / 22
    C949 Data Structures and Algorithms PreAssessment – Multiple Choice
    Study online at https://quizlet.com/_935bch
    A.) Ternary
    B.) Assignment
    C.) Comparison
    D. Equality
  12. What is the most efficient data type to use for this data C
    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
  13. Which data type is appropriate for this array to store D
    the given data?
    a = [“AF”, “71”, “BC”, “157”, “BA”, “253”]
    A.) Byte
    B.) Char
    C.) Short
    D.) String
  14. Which data type is appropriate for the given data set? A
    a = [1, 717, 23, 12, 314, 6]
    A.) Int
    B.) Byte
    C.) Char
    D.) Boolean
  15. Which data type should be used for this object? B
    days = { “Sunday”, “Monday”, “Tuesday”, “Wednesday”, “Thursday”, “Friday”, “Saturday”}
    A.) Float
    4 / 22
    C949 Data Structures and Algorithms PreAssessment – Multiple Choice
    Study online at https://quizlet.com/_935bch
    B.) String
    C.) Integer
    D.) Boolean
  16. Which data type should be used for this variable? C
    phoneNum = “212-555-1212”
    A.) Long
    B.) Short
    C.) String
    D.) Integer
  17. What is true about garbage collection? D
    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.
  18. What is true about a data structure implemented using B
    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.
  19. What are the array elements corresponding to the B
    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?
    5 / 22
    C949 Data Structures and Algorithms PreAssessment – Multiple Choice
    Study online at https://quizlet.com/_935bch
    A.) 89 and 94
    B.) 90 and 99
    C.) 94 and 99
    D.) 90 and 100
  20. What is the effect on the object Computing regarding B
    garbage collection?
    Computing obj = new Computing(); obj = null;
    A.) It is partially available for garbage collection.
    B.) It is automatically available for garbage collection.
    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.
  21. What are the mid-values in the first and second levels D
    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
  22. Which data set is represented using the dictionary D
    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
  23. What is a characteristic of keys in an associative dic- B
    tionary data type?
    A.) They are unique and mutable.
    6 / 22
    C949 Data Structures and Algorithms PreAssessment – Multiple Choice
    Study online at https://quizlet.com/_935bch
    B.) They are unique and immutable.
    C.) They are non-unique and mutable.
    D.) They are non-unique and immutable.
  24. Which method can be used to take a value out of a D
    dictionary?
    A.) D1[key].pop(value)
    B.) D1[key].pull(value)
    C.) D1[key].delete(value)
    D.) D1[key].remove(value)
  25. Given this data dictionary in Python: C
    dict = {‘white’:0x0000, ‘black’:0x1111}
    Which command/function generates the output
    [‘white’,’black’]?
    A.) dict_keys()
    B.) keys_values()
    C.) dict.keys()
    D.) keys.values()
  26. The reference of the head of the doubly linked list is C
    passed to the reverse() method:
    1<–>2<–>3<–>4<–>5<–>6
    What is the modified linked list when complete?
    A.) 2<–>1<–>4<–>3<–>6<–>5
    B.) 5<–>4<–>3<–>2<–>1<–>6
    C.) 6<–>5<–>4<–>3<–>2<–>1
    D.) 6<–>5<–>4<–>3<–>1<–>2
  27. Which data structure is indexed? B
    A.) Heap
    B.) Array
    7 / 22
    C949 Data Structures and Algorithms PreAssessment – Multiple Choice
    Study online at https://quizlet.com/_935bch
    C.) Linked list
    D.) Directed graph
  28. Which data structure may only store homogeneous A
    data elements?
    A.) Arrays
    B.) Classes
    C.) Dictionaries
    D.) Linked lists
  29. What is a hierarchical data structure? B
    A.) List
    B.) Tree
    C.) Array
    D.) Linked list
  30. What is an attribute of a binary tree? A
    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.
  31. Which data structure uses a last in, first out (LIFO) C
    removal of items?
    A.) Tree
    B.) Queue
    C.) Stack
    D.) Dictionary
  32. Given: B
    heapList = [22, 33, 44, 55, 66]
    Which index is the right child of item 22?
    A.) 33
    8 / 22
    C949 Data Structures and Algorithms PreAssessment – Multiple Choice
    Study online at https://quizlet.com/_935bch
    B.) 44
    C.) 55
    D.) 66
  33. Items were added sequentially in this stack starting A
    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’
    ‘sausage’
    ‘toast’
    ‘eggs’
    ‘ham’
    B.) ‘sausage’
    ‘toast’
    ‘eggs’
    ‘ham’
    ‘bacon’
    C.) ‘sausage’
    ‘toast’
    ‘eggs’
    ‘bacon’
    ‘ham’
    D.) ‘sausage’
    ‘bacon’
    ‘toast’
    ‘eggs’
    ‘ham’
  34. Items were added sequentially in this stack starting D
    with “dog”:
    “bird”
    “rabbit”
    9 / 22
    C949 Data Structures and Algorithms PreAssessment – Multiple Choice
    Study online at https://quizlet.com/_935bch
    “cat”
    “dog”
    What is the return value of the pop operation?
    A.) “dog”
    B.) “cat”
    C.) “rabbit”
    D.) “bird”
  35. Which sequence of letters represents preorder traver- B
    sal of the nodes of this tree?
    A.) A B C D E F G H I
    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
  36. An array soc of size 1009 is used where the index is an B
    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]
  37. A stack s, a queue q, and a max value priority queue C
    p each have a single 3 in them. Next s.push(4),
    q.push(4), and p.push(4) are executed.
    10 / 22
    C949 Data Structures and Algorithms PreAssessment – Multiple Choice
    Study online at https://quizlet.com/_935bch
    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)
  38. This stack reads left to right with the top to the right: C
    ‘green’
    ‘yellow’
    ‘blue’
    ‘red’
    What could be the stack after a push operation?
    A.) [‘red’,’blue’,’yellow’]
    B.) [‘blue’,’yellow’, ‘green’]
    C.) [‘red’,’blue’,’yellow’, ‘green’, ‘purple”]
    D.) [‘purple’, ‘red’,’blue’,’yellow’, ‘green’]
  39. Items were added sequentially onto the stack starting A
    with ‘red’:
    ‘green’
    ‘yellow’
    ‘blue’
    ‘red’
    What is the stack after a pop operation?
    A.) ‘yellow’
    ‘blue’
    ‘red’
    B.) ‘green’
    ‘yellow’
    ‘blue’
    C.) ‘purple’
    ‘green’
    11 / 22
    C949 Data Structures and Algorithms PreAssessment – Multiple Choice
    Study online at https://quizlet.com/_935bch
    ‘yellow’
    ‘blue’
    ‘red’
    D.) ‘green’
    ‘yellow’
    ‘blue’
    ‘red’
    ‘purple’
  40. Which command helps to speed up comparisons us- D
    ing dictionary keys during a dictionary (d) lookup in
    this pseudocode clip?
    h = hash(key)
    for pair in d:
    if h == pair[0]:
    return pair[1]
    A.) 0(1)
    B.) pair[0]
    C.) pair[1]
    D.) hash(object)
  41. What does the method any(b) return in Python if b is C
    a dictionary?
    A.) Returns False if the dictionary is empty.
    B.) Method any() does not exist for the dictionary.
    C.) Returns True if any key of the dictionary is true.
    D.) Returns True if all keys of the dictionary are true.
  42. Which Java method is used to read bytes from a stan- D
    dard file?
    A.) Java.mp.In
    B.) Java.io.StdArrayIO
    C.) Java.lang.BinaryStdIn
    D.) Java.io.FileInputStream
  43. A
    12 / 22
    C949 Data Structures and Algorithms PreAssessment – Multiple Choice
    Study online at https://quizlet.com/_935bch
    Which command will retrieve an item from the top of
    the stack?
    A.) Pop()
    B.) Deque()
    C.) Hash ()
    D.) Append()
  44. Which command will insert object x at position index C
    in a list?
    A.) Get(int index)
    B.) Remove(int index)
    C.) Add(int index, Object x)
    D.) Set(int index, Object x)
  45. Which command will return true if x is in a list, other- C
    wise return false?
    A.) IndexOf(Object x)
    B.) Remove(Object x)
    C.) Contains(Object x)
    D.) Set(int index, Object x)
  46. When should a dictionary be used instead of a list? B
    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
  47. What is the logical first step in an algorithm that C
    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
    13 / 22
    C949 Data Structures and Algorithms PreAssessment – Multiple Choice
    Study online at https://quizlet.com/_935bch
    D.) Check that the given list contains at least one
    number
  48. What is displayed when n = 2 in this pseudocode? A
    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
  49. Given a set of numeric data and two declared vari- D
    ables: 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
    C.) Determining the maximum number
    D.) Checking that the list contains at least one number
  50. What is the logical last step in an algorithm that aver- A
    ages 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
  51. What is the output of the pseudocode below if the B
    variables declared in the main program are global?
    14 / 22
    C949 Data Structures and Algorithms PreAssessment – Multiple Choice
    Study online at https://quizlet.com/_935bch
    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
    C.) 5
    32
    D.) 5
    24
  52. How many times in this pseudocode is the function F B
    called?
    Main
    Declare K as Integer
    K = 3
    Set Result = F(K)
    Write Result
    End Program
    Function F(N) as Integer
    If N == 1 Then
    15 / 22
    C949 Data Structures and Algorithms PreAssessment – Multiple Choice
    Study online at https://quizlet.com/_935bch
    Set F = 1
    Else
    Set F = N * F(N – 1)
    Set N = N – 1
    End If
    End Function
    A.) 1
    B.) 3
    C.) 4
    D.) 6
  53. What is displayed in Step 5 if A = 15 and B = 5 in the D
    pseudocode below?
    Step 1: Start
    Step 2: Read A, B
    Step 3: C= A*B
    Step 4: D=A/B
    Step5: Print C
    Step 6: Stop
    A.) 3
    B.) 5
    C.) 15
    D.) 75
  54. What is displayed in step 3 if midterm = 60 and final = B
    65 in this pseudocode?
    Step 1: Declare midterm, final as integer
    Step 2: average = (midterm+final)/2
    Step 3: if (average < 50) then Print “Fail” Else Print
    “Pass” endif
    A.) Fail
    B.) Pass
    C.) Average
    D.) Average = (midterm + final)/2
    16 / 22
    C949 Data Structures and Algorithms PreAssessment – Multiple Choice
    Study online at https://quizlet.com/_935bch
  55. How many times will count++ execute when i = 3, in D
    this pseudocode?
    int count = 0;
    int N = 4;
    for (int i = 0; i < N; i++)
    for (int j = 0; j < i; j++)
    count++;
    A.) 0
    B.) 1
    C.) 2
    D.) 3
  56. At the end of obj, what is the time complexity of insert- A
    ing in this pseudocode?
    void DynamicArrayAppend(DynamicArray *obj, const
    void *input) {
    if (obj->logicalSize == obj->capacity – 1) {
    obj->capacity *= 2;
    obj->internalArray = realloc(obj->internalArray,
    obj->capacity * obj->itemSize);
    }
    obj->logicalSize += 1;
    DynamicArraySet(obj, obj->logicalSize – 1, input);
    }
    DynamicArray obj = DynamicArrayCreate(sizeof(int)); for (int i = 0; i < n; i++) { int number = rand() % 10; DynamicArrayAppend(obj, &number); } A.) O(1) or O(n) B.) O(-1) or O(n) C.) O(1) or O(nn)
    D.) O(2) or O(log n)
    17 / 22
    C949 Data Structures and Algorithms PreAssessment – Multiple Choice
    Study online at https://quizlet.com/_935bch
  57. What is the time complexity of this pseudocode? A
    double sumCol(double table[][], int numRows, int
    numCols, int col)
    {
    double cSum = 0;
    for (int row = 0; row < numRows; row++)
    {
    cSum += table[row][col];
    }
    return cSum;
    }
    A.) O(n)
    B.) O(1)
    C.) O(n^2)
    D.) O(log(n))
  58. What is the time complexity of the instructions in this B
    pseudocode?
    for (i = 0; i < N; i++) {
    for (j = i+1; j < N; j++) {
    … // sequence of statements that do not alter N
    }
    }
    A.) O(N)
    B.) O(N 2)
    C.) O(log N)
    D.) O(N log N)
  59. What is the time complexity of this pseudocode? A
    Algorithm Algo1(A)
    Input: An array A storing n e 1 integers
    Output: The sum of the elements in A
    18 / 22
    C949 Data Structures and Algorithms PreAssessment – Multiple Choice
    Study online at https://quizlet.com/_935bch
    s=A[1]
    for i=1 to n do
    s=s+A[i]
    return s
    A.) O(n)
    B.) O(1)
    C.) O(log n)
    D.) O(n log n)
  60. What is the time complexity of this pseudocode? B
    Algorithm Algo3(A, B)
    Input: Arrays A and B, each of them storing ne1 integers
    Output: Count array B[i], where B[i] equals the sum of
    A[1] to A[i], i=1 to n
    c=0
    for i=1 to n do
    for j=1 to n do
    s=A[1]
    for k=1 to j do
    s=s+A[k]
    if B[i]=s then
    c=c+1
    return c
    A.) O(1)
    B.) O(n 3)
    C.) O(log n)
    D.) O(n log n)
  61. What is an attribute of a bubble sort algorithm? B
    A.) Considered an adaptive sort
    B.) Ideal for small number of n
    C.) Fast multiplication algorithm
    D.) Uses finding the closest pair of points
    19 / 22
    C949 Data Structures and Algorithms PreAssessment – Multiple Choice
    Study online at https://quizlet.com/_935bch
  62. What is a characteristic of quick sort? C
    A.) Ability to detect that the list is sorted efficiently
    B.) Input size is reduced by a constant factor for each
    step
    C.) Recursively breaks down a problem into two or
    more subproblems of the same or related type
    D.) Finds distances between all pairs of points in a
    space of dimension d and selects the minimum
  63. Which Big-O notation represents the time complexity D
    of a bubble sort?
    A.) O(n)
    B.) O(n 3/2)
    C.) O(log n)
    D.) O(n 2)
  64. What is the typical run time for an insertion sort? C
    A.) O(n)
    B.) O(n + k)
    C.) O(n 2)
    D.) O(n log n)
  65. A large set of floating point numbers that are in range D
    from 0.0 to 1.0 and are uniformly distributed across
    the range need to be sorted.Which sort procedure is
    useful when the input is uniformly distributed over the
    range?
    A.) Radix
    B.) Shell
    C.) Bubble
    D.) Bucket
  66. How many buckets are needed when sorting 13 num- A
    bers that have 15 digits each, using the radix-sort
    algorithm?
    20 / 22
    C949 Data Structures and Algorithms PreAssessment – Multiple Choice
    Study online at https://quizlet.com/_935bch
    A.) 10
    B.) 13
    C.) 15
    D.) 28
  67. Four words were added to an initially empty linked D
    list in the following order: orange, carrot, banana, and
    apple.Which word is at the beginning of the list?
    A.) “apple”
    B.) “banana”
    C.) “carrot”
    D.) “orange”
  68. Which type of sorting algorithm is demonstrated in C
    this pseudocode?
    for i from 0 to N – 1
    if a[i] > a[i + 1]
    swap( a[i], a[i + 1] )
    end
    A.) Merge
    B.) Bucket
    C.) Bubble
    D.) Quicksort
  69. Which type of sorting algorithm is demonstrated in D
    this pseudocode?
    def shortSort(alist):
    exchanges = True
    passnum = len(alist)-1
    while passnum > 0 and exchanges:
    exchanges = False
    for i in range(passnum):
    if alist[i]>alist[i+1]:
    exchanges = True
    temp = alist[i]
    21 / 22
    C949 Data Structures and Algorithms PreAssessment – Multiple Choice
    Study online at https://quizlet.com/_935bch
    alist[i] = alist[i+1]
    alist[i+1] = temp
    passnum = passnum-1
    A.) Merge
    B.) Radix
    C.) Quick
    D.) Bubble
  70. Which type of sorting algorithm is demonstrated in B
    this code?
    int partition( void *a, int low, int high )
    {
    int left, right;
    void *pivot_item;
    pivot_item = a[low];
    pivot = left = low;
    right = high;
    while ( left < right ) { /* Move left while item < pivot / while( a[left] <= pivot_item ) left++; / Move right while item > pivot / while( a[right] > pivot_item ) right–; if ( left < right ) SWAP(a,left,right); } / right is final position for the pivot */
    a[low] = a[right];
    a[right] = pivot_item;
    return right;
    }
    A.) Radix
    B.) Quick
    C.) Merge
    D.) Bubble
    22 / 22

Leave a Comment

Scroll to Top