










Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!











D - Answer-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. B - Answer-Which data structure allows inserting and deleting data elements at both the front and the rear? A.) Trees B.) Deques C.) Stacks D.) Queues C - Answer-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 A - Answer-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 A - Answer-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 C - Answer-Which data structure allows insertion and removal from only one end of the data structure? A.) List B.) Queue C.) Stack D.) Deque C - Answer-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 C - Answer-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) mid_value, date = middle(("FB", 75.00, 75.03, 74.90), datetime.date(2014, 10, 31)) A.) List B.) Float C.) Tuple D.) Operator A - Answer-Which value is appropriate for Test1 given the expression? char Test1;
A.) Byte B.) Char C.) Short D.) String A - Answer-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 B - Answer-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 C - Answer-Which data type should be used for this variable? phoneNum = "212-555-1212" A.) Long B.) Short C.) String D.) Integer D - Answer-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. B - Answer-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. B - Answer-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 C.) 94 and 99 D.) 90 and 100 B - Answer-What is the effect on the object Computing regarding 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. D - Answer-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 D - Answer-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 B - Answer-What is a characteristic of keys in an associative dictionary data type? A.) They are unique and mutable. B.) They are unique and immutable.
D.) Linked lists B - Answer-What is a hierarchical data structure? A.) List B.) Tree C.) Array D.) Linked list A - Answer-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. C - Answer-Which data structure uses a last in, first out (LIFO) removal of items? A.) Tree B.) Queue C.) Stack D.) Dictionary B - Answer-Given: heapList = [22, 33, 44, 55, 66] Which index is the right child of item 22? A.) 33 B.) 44 C.) 55 D.) 66 A - Answer-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' 'sausage'
'toast' 'eggs' 'ham' B.) 'sausage' 'toast' 'eggs' 'ham' 'bacon' C.) 'sausage' 'toast' 'eggs' 'bacon' 'ham' D.) 'sausage' 'bacon' 'toast' 'eggs' 'ham' D - Answer-Items were added sequentially in this stack starting with "dog": "bird" "rabbit" "cat" "dog" What is the return value of the pop operation? A.) "dog" B.) "cat" C.) "rabbit" D.) "bird" B - Answer-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 B - Answer-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?
C.) 'purple' 'green' 'yellow' 'blue' 'red' D.) 'green' 'yellow' 'blue' 'red' 'purple' D - Answer-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) C - Answer-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. D - Answer-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 A - Answer-Which command will retrieve an item from the top of the stack? A.) Pop() B.) Deque() C.) Hash () D.) Append()
C - Answer-Which command will insert object x at position index in a list? A.) Get(int index) B.) Remove(int index) C.) Add(int index, Object x) D.) Set(int index, Object x) C - Answer-Which command will return true if x is in a list, otherwise return false? A.) IndexOf(Object x) B.) Remove(Object x) C.) Contains(Object x) D.) Set(int index, Object x) B - Answer-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 C - Answer-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 A - Answer-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 D - Answer-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?
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 D - Answer-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 A.) 3 B.) 5 C.) 15 D.) 75 B - Answer-What is displayed in step 3 if midterm = 60 and final = 65 in this pseudocode? Step 1: Declare midterm, final as integer Step 2: average = (midterm+final)/ Step 3: if (average < 50) then Print "Fail" Else Print "Pass" endif A.) Fail B.) Pass C.) Average
D.) Average = (midterm + final)/ D - Answer-How many times will count++ execute when i = 3, in 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 A - Answer-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) A - Answer-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++)
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) B - Answer-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 C - Answer-What is a characteristic of quick sort? 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 D - Answer-Which Big-O notation represents the time complexity of a bubble sort? A.) O(n) B.) O(n 3/2) C.) O(log n) D.) O(n 2) C - Answer-What is the typical run time for an insertion sort? A.) O(n) B.) O(n + k) C.) O(n 2) D.) O(n log n)
D - Answer-A large set of floating point numbers that are in range 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 A - Answer-How many buckets are needed when sorting 13 numbers that have 15 digits each, using the radix-sort algorithm? A.) 10 B.) 13 C.) 15 D.) 28 D - Answer-Four words were added to an initially empty linked 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" C - Answer-Which type of sorting algorithm is demonstrated in 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 D - Answer-Which type of sorting algorithm is demonstrated in this pseudocode? def shortSort(alist): exchanges = True passnum = len(alist)- while passnum > 0 and exchanges: exchanges = False for i in range(passnum):