Algorithm Design and Analysis Flashcards
6 cards from real B CompE Bachelor of Computer Engineering practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.
Read the first 6 Algorithm Design and Analysis flashcards as text
What does the term 'NP-complete' mean?
Answer: A problem that is both in NP and is NP-hard (every NP problem reduces to it)
An NP-complete problem is in NP (solutions verifiable in polynomial time) and is NP-hard (every NP problem can be polynomially reduced to it), making it among the hardest problems in NP.
Which traversal of a binary search tree visits nodes in sorted ascending order?
Answer: In-order
In-order traversal (left → root → right) of a binary search tree visits all nodes in non-decreasing sorted order because of the BST property.
What is the space complexity of a recursive algorithm with n recursive calls on the call stack?
Answer: O(n)
Each recursive call adds a new stack frame, so n nested calls consume O(n) stack space, making the space complexity O(n) in the worst case.
In the context of algorithms, what is a 'divide and conquer' strategy?
Answer: Break the problem into smaller subproblems, solve each recursively, and combine results
Divide and conquer recursively splits a problem into subproblems, solves them independently, and combines their solutions, as seen in merge sort and binary search.
What is the purpose of a hash function in a hash table?
Answer: Map keys to array indices for O(1) average-case lookup
A hash function maps a key to an index in an array, enabling average O(1) insert, delete, and lookup operations in a hash table.
Which algorithm finds all-pairs shortest paths in a weighted graph in O(V³) time?
Answer: Floyd-Warshall Algorithm
The Floyd-Warshall algorithm uses dynamic programming with three nested loops over V vertices to compute shortest paths between every pair of vertices in O(V³) time.
How this page was made: written with AI tools and published by Nathan Beja, founder of Practice Test Geeks, who is responsible for its content. We have not yet matched this exam's facts to an official source, so confirm fees, dates and rules with the exam body. Not reviewed by a subject-matter expert. Editorial policy