0% found this document useful (0 votes)
101 views6 pages

Algo Final Exam

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
101 views6 pages

Algo Final Exam

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

CONCEPCION HOLY CROSS COLLEGE, INC.

SCHOOL OF COMPUTER STUDIES


Minane, Concepcion, Tarlac
2nd Semester | A.Y. 2023 – 2024

F3 FRIasdasdasdasdasFCS1
8:30-10:00AM BSCS 2B – MB303 L. PINEDA
CSP104-Algorithms and Complexity
Final Examination

Student No. Date:


Name: Instructor Name: Lemer Pineda

GENERAL INSTRUCTION: Read carefully and answer the following questions. Any form of ERASURES
and TAMPERING in papers are considered wrong.

I. Multiple Choice: Choose the best answer and write the correct letter on the space provided.
___ 1. What is an algorithm?
a. A sequence of ambiguous instructions
b. A finite sequence of ambiguous instructions
c. A finite sequence of unambiguous instructions
d. A sequence of unambiguous instructions
___ 2. Which of the following is NOT a characteristic of an algorithm?
a. Definiteness b. Finiteness c. Ambiguity d. Efficiency
___ 3. Who was the mathematician after whom the term "algorithm" is named?
a. Abu Jafar Mohammed c. Al Khowarizmi
b. Algorithmus d. Persia Ibn Musa
___ 4. Which design technique involves exhausting all possibilities?
a. Greedy Algorithms c. Brute-force or exhaustive search
b. Dynamic Programming d. Divide and Conquer
___ 5. What is the purpose of algorithm validation?
a. To create algorithms automatically
b. To test the efficiency of algorithms
c. To find errors and ensure correct output
d. To analyze algorithm behavior
___ 6. When is profiling used in algorithm development?
a. During debugging c. Prior to algorithm creation
b. post-implementation d. During algorithm validation
___ 7. How are algorithms usually specified in modern times?
a. Natural language c. Flowchart
b. Pseudocode d. Mathematical symbols
___ 8. Which operator is used for assignment in pseudocode?
a. = b. <-- c. => d. :=
___ 9. What is the purpose of the 'if-then-else' statement in pseudocode?
a. Looping c. Value comparison
b. Decision-making d. Output display
___ 10. Which of the following is a common method of expressing an algorithm?
a. Naïve language c. Pseudocode
b. Logical charting d. Cryptic symbols
___ 11. What is the primary purpose of a flowchart in algorithm design?
a. To represent an algorithm visually
b. To debug code
c. To calculate time complexity
d. To utilize natural language
___ 12. How are arrays typically accessed in algorithms?
a. By referring to the array's position c. By counting from 0
b. By using logical operators d. By incrementing values
___ 13. When using a 'for' loop in pseudocode, what statement is used to exit the loop?
a. Stop b. Esc c. Break d. Halt
___ 14. Which statement type in pseudocode allows for repetitive execution based on a
condition?
a. If-Then b. Case c. While d. Repeat-Until
___ 15. What is space complexity in algorithm analysis concerned with?
a. Optimizing code size c. Enhancing program compatibility
b. Improving algorithm speed d. Evaluating memory usage
___ 16. What is an algorithm?
a. A random set of instructions
b. A set of instructions to be followed to solve a problem
c. A single solution to a problem
d. A set of instructions that are never correct
___ 17. What is one requirement for an algorithm to be considered correct?
a. It must have multiple solutions
b. It should be implemented in C++
c. It should correctly solve the problem
d. It should run on all platforms
___ 18. What are the two main aspects of algorithmic performance?
a. Speed and cost c. Color and size
b. Time and space d. Input and output
___ 19. How should we compare the efficiency of two algorithms that solve the same
problem?
a. By comparing their implementations
b. Based on the computer used
c. Independently of specific implementations, computers, or data
d. By testing them on different platforms
___ 20. What do we use to analyze algorithms independently of specific implementations,
computers, or data?
a. Running times c. Coding tricks
b. Mathematical techniques d. Specific data
___ 21. What is the cost of an operation in an algorithm?
a. The number of steps it takes
b. The space it occupies
c. The time it takes
d. The complexity it introduces
___ 22. What does the running time of a loop depend on?
a. The number of instructions inside the loop
b. The total number of loops
c. The size of the data structure
d. The number of iterations
___ 23. In algorithm growth rates, what does it mean if an algorithm requires time
proportional to f(n)?
a. It requires a fixed amount of time
b. It grows linearly with n
c. It grows quadratically with n
d. It grows exponentially with n
___ 24. What does Big O notation indicate about an algorithm's time complexity?
a. The best-case time c. The upper bound on time
b. The average-case time d. The worst-case time
___ 25. What does it mean for an algorithm to be O(n^2)?
a. It requires time proportional to n c. It requires constant time
b. It requires time proportional to n^2 d. It requires logarithmic time
___ 26. What does Best-Case Analysis of an algorithm focus on?
a. The maximum time required c. The average time required
b. The minimum time required d. The time in between worst and best cases
___ 27. What is important to consider when selecting the implementation of an Abstract
Data Type (ADT)?
a. Only time complexity
b. Frequency of ADT operations in the application
c. Memory requirements
d. Coding style
___ 28. What is the time complexity of an array-based list retrieve operation?
a. O(1) b. O(log n) c. O(n) d. O(n^2)
___ 29. In Sequential Search, what is the Worst-Case time complexity?
FINAL EXAM - 2 | P a g e
a. O(1) b. O(n) c. O(log n) d. O(n^2)
___ 30. How many iterations are required in Binary Search for an unsuccessful search?
a. Log2(n) b. Log10(n) c. Log(1/n) d. Square root of n
___ 31. What does Big O Notation help us measure in algorithms?
a. Exact time taken by an algorithm
b. Exact space used by an algorithm
c. Performance and resources utilized by an algorithm
d. Best-case scenario of an algorithm
___ 32. Which scenario does Omega Notation "Ω" represent?
a. Best-case scenario c. Worst-case scenario
b. Average-case scenario d. Linear scenario
___ 33. What does Theta Notation "Θ" characterize in terms of time complexity?
a. Best-case scenario c. Worst-case scenario
b. Average-case scenario d. Constant time operations
___ 34. Why is Big-O Notation important in coding interviews?
a. It provides the exact time complexity of an algorithm
b. It focuses on the best-case scenario
c. It helps measure the worst-case scenario time complexity
d. It is rarely used in coding interviews
___ 35. Which of the following best describes the space complexity of the Bubble sort
algorithm?
a. O(1) b. O(log n) c. O(n) d. O(n!)
___ 36. What is the time complexity denoted by O(1) in algorithm analysis?
a. Linear time complexity c. Logarithmic time complexity
b. Constant time complexity d. Quadratic time complexity
___ 37. In terms of time complexity, what does accessing an array by index represent?
a. Logarithmic time complexity c. Constant time complexity
b. Linear time complexity d. Quadratic time complexity
___ 38. Which time complexity is commonly associated with the binary search algorithm?
a. O(n) b. O(log n) c. O(n log n) d. O(n!)
___ 39. Which sorting algorithms typically have a time complexity of O(n log n)?
a. Bubble Sort and Selection Sort c. Insertion Sort and Heap Sort
b. Merge Sort and Quick Sort d. Linear Search and Binary Search
___ 40. What type of time complexity is present in algorithms with two nested loops
iterating over an array?
a. Log-linear (O(n log n)) c. Cubic (O(n^3))
b. Quadratic (O(n^2)) d. Exponential (O(c^n))
___ 41. How would you describe the time complexity denoted by O(n!)?
a. Linear b. Quadratic c. Exponential d. Factorial
___ 42. Which real-world example best represents a scenario with exponential time
complexity?
a. Reading a book c. Breaking a password with only numbers
b. Looking up a word in a dictionary d. Finding a specific item in a sorted list
___ 43. What is the time complexity of algorithms that utilize the divide-and-conquer
strategy?
a. O(n) b. O(log n) c. O(n log n) d. O(n^2)
___ 44. Which time complexity is characteristic of low-performant sorting algorithms like
Bubble Sort?
a. O(n) b. O(n log n) c. O(n^2) d. O(n!)
___ 45. In algorithm analysis, what does the constant "c" represent in the exponential time
complexity O(c^n)?
a. Number of variables c. Base number
b. Exponent number d. Number of iterations
___ 46. What is Linear Search?
a. A method for finding a target value within a list by dividing the list into halves
b. An algorithm that requires the list to be sorted before searching
c. A technique that sequentially checks each element of the list for the target value
d. An approach that compares elements at random within the list
___ 47. Which of the following describes the process of Linear Search?
a. It involves sorting the list before searching
b. Matches elements using divide and conquer strategy
c. Checks each element until a match is found or all elements are searched
d. Picks random elements to compare
FINAL EXAM - 3 | P a g e
___ 48. What is the time complexity of Linear Search in the best case scenario?
a. O(1) b. O(logn) c. O(n) d. O(n^2)
___ 49. Which is not a step in the implementation of Linear Search?
a. Traverse array elements using a for loop
b. Compare the search element with the current array element
c. Return the index of the corresponding array element if a match is found
d. Sort the list before starting the search
___ 50. What is the space complexity of Linear Search?
a. O(1) b. O(n) c. O(logn) d. O(n^2)
___ 51. What is the programming language used in the provided Linear Search program?
a. Python b. Java c. C++ d. JavaScript
___ 52. Which case has the highest time complexity for Linear Search?
a. Best Case c. Worst Case
b. Average Case d. All cases have the same time complexity
___ 53. In Linear Search, when does the worst-case time complexity occur?
a. When the element to be found is at the middle of the list
b. When the element to be found is not in the list
c. When the element to be found is at the end of the list
d. Linear Search does not have a worst-case scenario
___ 54. What does the Linear_Search algorithm return if the search element is not found
in the list?
a. -1 b. 0 c. The element itself d. NULL
___ 55. Which search method is known for its simplicity and suitability for unordered
lists?
a. Binary Search c. Jump Search
b. Quick Search d. Linear Search
___ 56. What technique does Binary Search follow?
a. Randomly comparing list elements
b. Divide and conquer approach
c. Sorting the list in ascending order
d. Starting the search from the middle of the list
___ 57. What is the space complexity of Binary Search?
a. O(n) b. O(logn) c. O(1) d. O(n^2)
___ 58. When does the best-case time complexity occur in Binary Search?
a. When the element to be found is at the first position
b. When the list is sorted in descending order
c. When the list contains duplicates
d. Binary Search does not have a best-case scenario
___ 59. Which method is used to calculate the middle in the Binary Search algorithm?
a. (beg + end) c. (beg * end)
b. (end - beg) / 2 d. (beg + end) / 2
___ 60. What is compared with the middle element in the binary search technique?
a. Last element of the list c. Target value
b. First element of the list d. Sum of all elements

II. PROBLEM SOLVING: Determine the time & space complexities for each of the following functions.
1.)
function isEven(value){
if (value % 2 == 0){
return true;
}
else
return false;
}
2.)
function areYouHere(arr1, arr2) {
for (let i=0; i<arr1.length; i++) {
const el1 = arr1[i];
for (let j=0; j<arr2.length; j++) {
const el2 = arr2[j];
if (el1 === el2) return true;
}
}

FINAL EXAM - 4 | P a g e
return false;
}
3.)
function factorialOf(n) {
switch (n) {
case 0:
case 1:
return 1;
default: return n * factorialOf(n - 1);
}
}

4.) Using Binary Search Algorithm, Let the element to search is, K = 15. Show the solution and
give the time & space complexities.

9 12 15 24 30 32 36 39 41

Mr. Lemer S. Pineda Instructor


FINAL EXAM - 5 | P a g e
Mr. Joe Mariel M. Mejia
SCS Program Chair

FINAL EXAM - 6 | P a g e

You might also like