click below
click below
Normal Size Small Size show me how
285 test 1 study
| Question | Answer |
|---|---|
| ADTS allow programmers to | Focus on higher level operations as per a program's needs |
| An algorithm is written to return the first name beginning with " L " in a list of employee names . Which of the following is the algorithm's worst case scenario ? | No names in the list begin with " L " |
| In a linked list , each node stores a _____the next node . | pointer to |
| Which of the following is correct for a list ADT ? | An element can be found and removed from the end of the list . |
| An algorithm that uses a constant number k of integer variables to find a number list's minimum value has space complexity S ( N ) = ________ and auxiliary space complexity S ( N ) = | N,k |
| Which algorithm is best suited for a plagiarism check ? | Longest common substring |
| A stack abstract data type ( ADT ) is implemented using a ( n ) _____data structure . | linked list |
| An algorithm's is the scenario where the algorithm does the minimum possible number of operations . | best case |
| Which data type is best suited to store the names and grades of students ? | record |
| Which abstract data type ( ADT ) is suited to check whether a given string is a palindrome ? | A deque |
| Appending an element in an array involves increasing the array's | size |
| The process of providing only the essentials and hiding the details is known as | abstraction |
| What is the space complexity the algorithm ? ArithmeticSeries (list listSize ) { i = 0 arithmeticSum = 0 while ( i < listSize ) { arithmeticSum arithmeticSum + list [ i ] i = i + 1 } return arithmeticSum } | S ( N ) = N + k |
| Which XXX will complete the algorithm to separate numberList into two lists ( even and odd ) using an array ? | if ( numberList [ i ] % 2 == 0 ) |
| Which of the following is best represented by a graph ? | A telephone network . |
| Which is an abstract data type ( ADT ) ? | a list |
| A manufacturing plant has many ways to assemble a product . Which algorithm will be useful to find the quickest way ? | Dijkstra's shortest path |
| Which abstract data type ( ADT ) is best suited to store the names of all currently available smartphone models ? | A set |
| What values are stored in the list numList ? numberList ( ) { for ( i = 0 ; i < 10 ; i ++ ) { if ( i % 2 == 0 ) { numList [ i ] = i } } } | [0 , 2 , 4 , 6 , 8 ] |
| The worst - case runtime of an algorithm is ______ number of steps taken to execute a program . | the maximum |
| The Big O notation of the composite function 5 N 3 + 0 ( N2 ) is_ | 0 ( N3 ) |
| Which of the following is an example of a recursive function ? | MySalaryCalculator ( tempSal ) { if ( tempSal < = 500 ) return -1 else tempSal = tempSal + 1000 } |
| Which of the following is the main requirement for a binary search algorithm ? | The list must be sorted in ascending order |
| Which of the following is an example of constant time O ( 1 ) ? | Accessing an element of an array |
| Identify the correct sequence of performing a binary search . | 1st, it checks the mid element of the list. If the key is found it returns the matching location. If not found, the algorithm repeats the search on the remaining left sublist( if key < mid element) or the remaining right sublist( if key > mid element). |
| A ( n )_____ . is a function f ( N ) that is defined in terms of the same function and operates on a value less than N. | a recurrence relation |
| second recursive call ? Given a list ( 0 , 1 , 1 , 2 , 3 , 5 , 8 , 13 , 17 ) the binary search algorithm calls Binary Search ( list , 0 , 8 , 5 ) . What will the low and high argument values be for the | low =5 , high = 8 |
| Given the following code for generating the Fibonacci series for N numbers which XXX would replace the missing statement ? FibonacciNumber ( N ) { XXX return 0 else if ( N == 1 ) return 1 else return FibonacciNumber ( N - 1 ) + FibonacciNumber ( N - 2 ) } | if ( N == 0 ) |
| Which of the following statements is true with reference to an algorithm's runtime ? | A single algorithm can execute more quickly on a faster processor . |
| In a recursive function , the base case_____ the function . | terminates |
| ctr = 0 while ( ctr < N ) { myAge = ctr val = ctr + 1 while ( val < N ) { if( age OfPeople [ val ] <ageOfPeople [ myAge ] ) myAge = val ++ val } tempList ageOfPeople [ ctr ] ageOfPeople [ctr] = ageOfPeople [ myAge ] ageOfPeople [myAge] = tempList ++ ctr } | 0 ( N2 ) |
| A list of employees that has been sorted in descending order needs to be reversed .Which X completes the algorithm to sort the list in ascending order? AscendingList (empLis,begin,end){if(begin>=end) return .else (Swap empLis [begin] and empLis [end] X}} | AscendingList ( empList , begin + 1 , end - 1 ) |
| The upper bound of an algorithm with best case runtime T ( N ) = 3 N + 16 and worst case runtime T (N) = 4 N2 + 10 N + 5 is | 19 N 2 |
| Which XX base case completes the algorithm to count the num of occurrences of a val in a list of nums? CountOccur (num,numLen,val,startIn){XXif(num[startIn]==val)return1+CountOccur(num,numLen,val,startIn+1)else returnCountOccur(num,numLen,val startIn+1)} | If(startIndex>= numbersLength) return 0 |
| Which of the following algorithms is correct for applying linear search to find the element findEle in a list StudentlDs ? | LinearSearch ( StudentIDs , int listSize , int findEle ) { for ( ctr = 0 ; i < listSize ; ++ ctr ) { if ( StudentIDs [ findEle ] == ctr ) return findEle } } |
| The Big O notation of the algorithm 7+ 12 N +3 N 2 is | N. 2 |
| Which XXX completes the binary search algorithm ? BinarySearch (arr, arrSize, key ){ mid=0 low=0 high arrSize-1 XXX {mid=( high + low ) / 2 f ( arr [ mid ] < key ) { low = mid + 1 else if ( arr[ mid ] > key ) { high = mid - 1 else { return mid return -1} | While(high>=low) |
| Identify the notation for algorithm complexity that has a positive constant c for all T ( N ) 2 c f ( N ) . | T ( N ) = Q ( f ( N ) ) |
| The following algorithm is an example of def MyMath ( num ) if (num < = 1){ return num} return MyMath ( num - 2 ) + MyMath ( num - 1 ) | an exponential runtime complexity |