CS2004_Algorithmic_Concepts_Flashcards

(15 cards)

1
Q

What is an algorithm?

A

An algorithm is a finite, well-defined sequence of instructions used to solve a specific problem or perform a computation.

✅ Example: The steps to perform Bubble Sort are an algorithm that arranges a list in ascending order.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a program?

A

A program is the implementation of an algorithm in a specific programming language so that it can be executed by a computer.

✅ Example: Writing the Bubble Sort algorithm in Python makes it a program.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the difference between an algorithm and a program?

A

An algorithm is the abstract plan or logic, while a program is the concrete implementation of that logic in code.

✅ Example: The logic of finding a minimum in a list is the algorithm; writing it in Java makes it a program.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a decision problem?

A

A decision problem is a problem that has a yes/no (true/false) output for a given input.

✅ Example: Is a number prime? (Input: 17 → Output: Yes)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a computable problem?

A

A computable problem is one for which an algorithm exists that will solve the problem in a finite number of steps.

✅ Example: Sorting a list of numbers using Merge Sort is a computable problem.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is an incomputable problem?

A

An incomputable (undecidable) problem is one for which no algorithm can solve all instances of the problem.

✅ Example: The Halting Problem — determining if a program halts on a given input — is incomputable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the Halting Problem?

A

The Halting Problem is the problem of deciding whether a given program will finish running or continue forever for a specific input.

✅ Example: There is no general-purpose algorithm that can answer this for all programs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is P in computational complexity?

A

P is the class of decision problems that can be solved in polynomial time by a deterministic Turing machine.

✅ Example: Binary Search runs in O(log n), which is polynomial → in class P.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is NP?

A

NP (nondeterministic polynomial time) is the class of decision problems where a solution can be verified in polynomial time.

✅ Example: Verifying a completed Sudoku board can be done quickly, so it’s in NP.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is an NP-Complete problem?

A

An NP-Complete problem is both in NP and as hard as any problem in NP. If any NP-Complete problem is solved in polynomial time, then all NP problems can be.

✅ Example: Boolean Satisfiability (SAT) is NP-Complete.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is an NP-Hard problem?

A

An NP-Hard problem is at least as hard as the hardest problems in NP but does not have to be in NP (it may not be verifiable in polynomial time).

✅ Example: The optimisation version of the Travelling Salesperson Problem is NP-Hard.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is an example of a problem in P?

A

Problems that can be solved in polynomial time by a deterministic machine.

✅ Example: Matrix multiplication or Binary Search.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is an example of a problem in NP?

A

Problems whose solutions can be verified in polynomial time.

✅ Example: Verifying a solution to the Knapsack Problem.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is an example of an NP-Complete problem?

A

An NP-Complete problem is both in NP and NP-Hard.

✅ Example: The Travelling Salesperson Problem (decision version) and 3-SAT.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the purpose of problem classification in complexity theory?

A

It helps to determine whether a problem can be solved efficiently and guides which algorithms are applicable.

✅ Example: Classifying a problem as NP-Hard tells us that we likely need a heuristic or approximation algorithm.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly