































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
C949/ WGU C949 - DATA STRUCTURES AND ALGORITHMS PRE-ASSESSMENT | FREQUENTLY TESTED QUESTIONS WITH CORRECT ANSWERS | BRAND NEW!
Typology: Exams
1 / 39
This page cannot be seen from the preview
Don't miss anything!
































Which sequence of letters represents preorder traversal 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 - โโโ correct answer > 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] - โโโ correct answer > B 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) - โโโ correct answer > C This stack reads left to right with the top to the right: 'green' 'yellow' 'blue' 'red'
'blue' C.) 'purple' 'green' 'yellow' 'blue' 'red' D.) 'green' 'yellow' 'blue' 'red' 'purple' - โโโ correct answer > A Which command helps to speed up comparisons using 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) - โโโ correct answer > D What does the method any(b) return in Python if b is 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. - โโโ correct answer > C Which Java method is used to read bytes from a standard file? A.) Java.mp.In B.) Java.io.StdArrayIO C.) Java.lang.BinaryStdIn D.) Java.io.FileInputStream - โโโ correct answer > D Which command will retrieve an item from the top of the stack? A.) Pop() B.) Deque()
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 - โโโ correct answer > B 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 - โโโ correct answer > C 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 } }
D.) 0, 2, 1 - โโโ correct answer > A 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 C.) Determining the maximum number D.) Checking that the list contains at least one number - โโโ correct answer > D 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
24 - โโโ correct answer > B How many times in this pseudocode is the function F 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
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 - โโโ correct answer > B What is displayed in Step 5 if A = 15 and B = 5 in the 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
for (int i = 0; i < N; i++) for (int j = 0; j < i; j++) count++; A.) 0 B.) 1 C.) 2 D.) 3 - โโโ correct answer > D At the end of obj, what is the time complexity of inserting 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) - โโโ correct answer > A What is the time complexity of this pseudocode? double sumCol(double table[][], int numRows, int numCols, int col) { double cSum = 0; for (int row = 0; row < numRows; row++) { cSum += table[row][col]; }
What is the time complexity of this pseudocode? Algorithm Algo1(A) Input: An array A storing n โฅ 1 integers Output: The sum of the elements in A 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) - โโโ correct answer > A What is the time complexity of this pseudocode? Algorithm Algo3(A, B) Input: Arrays A and B, each of them storing nโฅ1 integers Output: Count array B[i], where B[i] equals the sum of A[1] to A[i], i=1 to n
c= 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+ return c A.) O(1) B.) O(n 3) C.) O(log n) D.) O(n log n) - โโโ correct answer > B What is an attribute of a bubble sort algorithm? A.) Considered an adaptive sort B.) Ideal for small number of n C.) Fast multiplication algorithm D.) Uses finding the closest pair of points - โโโ correct answer > B
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. - โโโ correct answer > D Which data structure allows inserting and deleting data elements at both the front and the rear? A.) Trees B.) Deques C.) Stacks D.) Queues - โโโ correct answer > B 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 - โโโ correct answer > C What are the official 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 C.) 1, 2, 3, 4, 5, 6 D.) 2, 4, 6, 8, 10, 12 - โโโ correct answer > 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 - โโโ correct answer > A