Algorithm UNIT Quiz

Quiz
•
Engineering
•
University
•
Hard
Dr. Vasanthi
Used 1+ times
FREE Resource
30 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the time complexity of a linear search algorithm?
O(n)
O(log n)
O(n log n)
O(1)
Answer explanation
The time complexity of a linear search algorithm is O(n) because it may need to check each element in the list once in the worst case, where n is the number of elements. Thus, the correct choice is O(n).
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which asymptotic notation gives the upper bound of an algorithm's time complexity?
Big-O
Big-Ω
Big-Θ
None
Answer explanation
Big-O notation provides the upper bound of an algorithm's time complexity, indicating the worst-case scenario for its growth rate. It helps in understanding the maximum time an algorithm can take as input size increases.
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the worst-case time complexity of a binary search algorithm?
O(n)
O(log n)
O(n log n)
O(1)
Answer explanation
The worst-case time complexity of a binary search algorithm is O(log n) because it repeatedly divides the search interval in half, leading to logarithmic growth relative to the number of elements.
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which algorithm has a time complexity of O(n^2)?
Bubble sort
Selection sort
Insertion sort
All of the above
Answer explanation
All the algorithms listed—Bubble sort, Selection sort, and Insertion sort—have a worst-case time complexity of O(n^2). Therefore, the correct answer is 'All of the above'.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the best-case time complexity of a heap sort algorithm?
O(n)
O(log n)
O(n log n)
O(1)
Answer explanation
The best-case time complexity of heap sort is O(n) during the heap construction phase. After that, the sorting phase takes O(n log n). However, the question specifically asks for the best-case scenario, which is O(n).
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which data structure is used in a heap sort algorithm?
Array
Linked list
Stack
Queue
Answer explanation
Heap sort uses an array to represent the binary heap structure. The array allows efficient access and manipulation of elements, making it suitable for the sorting process. Thus, the correct answer is Array.
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the time complexity of a naive string-matching algorithm?
O(n)
O(n^2)
O(n log n)
O(1)
Answer explanation
The naive string-matching algorithm checks each position in the text for a match with the pattern. In the worst case, this results in O(n) comparisons for each of the n characters, leading to a total time complexity of O(n^2).
Create a free account and access millions of resources
Similar Resources on Wayground
25 questions
TEMEL ELEKTRONİK

Quiz
•
University
33 questions
bài 1 ktđ

Quiz
•
University
30 questions
The Time Value of Money (Part II)

Quiz
•
University
32 questions
EMAGS

Quiz
•
University
26 questions
CECE SURVEYING SIMPLE CURVES

Quiz
•
University
25 questions
Search Algorithms Quiz

Quiz
•
University
35 questions
INS Class Activity -1

Quiz
•
University
25 questions
Course Exit Survey

Quiz
•
University
Popular Resources on Wayground
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
10 questions
Nouns, nouns, nouns

Quiz
•
3rd Grade
10 questions
9/11 Experience and Reflections

Interactive video
•
10th - 12th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
11 questions
All about me

Quiz
•
Professional Development
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
9 questions
Tips & Tricks

Lesson
•
6th - 8th Grade
Discover more resources for Engineering
21 questions
Spanish-Speaking Countries

Quiz
•
6th Grade - University
20 questions
Levels of Measurements

Quiz
•
11th Grade - University
7 questions
Common and Proper Nouns

Interactive video
•
4th Grade - University
12 questions
Los numeros en español.

Lesson
•
6th Grade - University
7 questions
PC: Unit 1 Quiz Review

Quiz
•
11th Grade - University
7 questions
Supporting the Main Idea –Informational

Interactive video
•
4th Grade - University
12 questions
Hurricane or Tornado

Quiz
•
3rd Grade - University
7 questions
Enzymes (Updated)

Interactive video
•
11th Grade - University