1. Home
  2. Explore
  3. Computer Science
  4. Introduction to Algorithms

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Introduction to Algorithms

  • 76Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Origins and Definitions

What is the modern meaning of the word algorithm, and what older meaning of the word is now archaic?

76 questions

  1. 1

    What is the modern meaning of the word algorithm, and what older meaning of the word is now archaic?

    Model answer

    An algorithm is a procedure or set of rules for doing something. An older, now archaic meaning referred to an Arabic system of numbering.

    Explanation

    The modern definition focuses on procedures, while the numbering definition reflects an earlier use of the word.

  2. 2

    How is the word “algorithm” historically connected to Muhammad al-Khwarizmi?

    Model answer

    Al-Khwarizmi’s name was Latinized as “Algoritmi,” from which the word “algorithm” developed.

    Explanation

    The word’s history is linked to the Latinized form of his name.

  3. 3

    What contributions of al-Khwarizmi are associated with the historical development of algorithms?

    Model answer

    He presented Indian numbering under the name Arabic numbering and introduced methods for working in algebra.

    Explanation

    The lecture connects his work on calculation and algebra with the early history of algorithmic methods.

  4. 4

    What does it mean for an algorithm to be an effective method?

    Model answer

    It is a finite set of exact instructions for a class of problems that, when followed rigorously, always halts after finitely many steps and produces the correct answer.

    Explanation

    Finiteness, exactness, termination, and correctness are central features of the effective-method definition.

  5. 5

    According to the effective-method definition, what resources should a person need to carry out the instructions?

    Model answer

    In principle, any person should be able to follow them using no special aids beyond writing materials.

    Explanation

    The method should work through rigorous instruction-following rather than requiring specialized equipment.

  6. 6

    Why are algorithms closely connected to formal mathematical methods and proofs?

    Model answer

    Both use precise procedures for manipulating expressions or solving problems, and formal methods for solving equations helped shape ideas about algorithms.

    Explanation

    The lecture emphasizes that procedures for calculation and methods for proving results share a reliance on explicit rules.

  7. 7

    How does unambiguous differ from deterministic when describing an algorithm?

    Model answer

    An unambiguous algorithm has instructions that can be followed clearly, while a deterministic algorithm produces the same result every time it runs.

    Explanation

    An algorithm may be unambiguous without always taking the same route or producing the same result under different inputs or conditions.

  8. 8

    Why can a route-finding procedure be non-deterministic while still being an algorithm?

    Model answer

    Its route may vary with conditions or inputs, but it can still follow the same basic procedure and reach the intended destination.

    Explanation

    The example of driving to a destination illustrates variation in the route without making the procedure ambiguous.

  9. 9

    Who performed many computations before electronic computers, and what was the historical meaning of “computer”?

    Model answer

    Skilled human mathematicians performed computations, and “computer” could refer to a person who carried them out.

    Explanation

    Human computing teams worked on tasks such as scientific and military projects before electronic computing became widespread.

  10. 10

    Why are standard algorithms valuable, and how does their reuse differ from plugging together standard electronic components?

    Model answer

    Standard algorithms prevent problems from having to be solved from scratch, but they are generally less modular than standard electronic components and often require customization.

    Explanation

    The lecture notes that algorithm reuse is useful, though adapting algorithms can introduce errors and extra work.

  11. 11

    What is iteration in an algorithm?

    Model answer

    Iteration is repeating a computational action or set of actions.

    Explanation

    Computers often carry out the same steps again and again as part of a procedure.

  12. 12

    What is recursion in its modern technical sense?

    Model answer

    Recursion is a structure in which an algorithm calls itself, typically with different parameters.

    Explanation

    The lecture distinguishes this technical meaning from older uses of the word.

  13. 13

    How can factorial be defined recursively?

    Model answer

    For positive nnn, factorial can be defined as n!=n(n−1)!n! = n(n-1)!n!=n(n−1)!, with a base case such as 0!=10! = 10!=1.

    Explanation

    This expresses each factorial in terms of a smaller one; the base case completes the definition.

  14. 14

    What are flowcharts used to represent, and what historical work helped develop them?

    Model answer

    Flowcharts represent the steps and control flow of a process. Frank and Lillian Gilbreth used them to model human activities in time-and-motion studies.

    Explanation

    The lecture traces early flowchart development to the modeling of work processes.

  15. 15

    What evidence did the lecture give for the development of a flowchart resembling a modern one?

    Model answer

    It cited a flowchart in Grace Hopper’s papers, created by programmer Margery K. League to compare three numbers.

    Explanation

    The example illustrates an early flowchart with a form similar to those used today.

  16. 16

    Why did flowcharts fall out of favor, according to the lecturer’s explanation?

    Model answer

    One proposed reason is that drawing them on early computers was difficult, and programmers also found manual drafting cumbersome.

    Explanation

    The lecture presents this as a theory rather than a definitive explanation.

  17. 17

    What is pseudocode, and what is a limitation of using it to describe algorithms?

    Model answer

    Pseudocode describes an algorithm as a sequence of instructions, often in structured English. Its notation is not consistently defined or universally used.

    Explanation

    Unlike flowcharts with standard symbols, pseudocode can vary between writers.

  18. 18

    What two forms of algorithm description did the lecture contrast?

    Model answer

    It contrasted flowcharts, which use defined graphical symbols, with pseudocode or structured English, which expresses instructions in words.

    Explanation

    Each form communicates procedural steps, but they differ in how standardized their representation is.

  19. 19

    What is time complexity, and why is it often described in terms of steps rather than clock time?

    Model answer

    Time complexity describes how the number of computational steps grows as the input grows. Step counts are more comparable across computers than elapsed time.

    Explanation

    The same algorithm may take different amounts of clock time on different machines.

  20. 20

    What is space complexity?

    Model answer

    Space complexity describes how much storage an algorithm requires as the problem size grows.

    Explanation

    It measures memory use, as opposed to the growth in computational steps measured by time complexity.

  21. 21

    What does Big-O notation communicate about an algorithm?

    Model answer

    It describes how the algorithm’s resource use, commonly its number of steps, scales as the input size grows.

    Explanation

    Big-O emphasizes growth rather than the time taken on a particular computer.

  22. 22

    How does bubble sort work?

    Model answer

    It repeatedly compares adjacent items and swaps them when they are in the wrong order.

    Explanation

    Repeated pairwise comparisons move items toward their correct positions in the list.

  23. 23

    What is bubble sort’s best-case step complexity when its input is already sorted and the algorithm stops after a no-swap pass?

    Model answer

    It is O(N)O(N)O(N), because the algorithm needs to inspect the list once to confirm that no swaps are needed.

    Explanation

    A single pass checks the adjacent pairs without performing swaps.

  24. 24

    Why does bubble sort have a worst-case complexity of O(N2)O(N^2)O(N2)?

    Model answer

    In reverse order, items may need to move through many positions over repeated passes, and there can be NNN passes of about NNN comparisons each.

    Explanation

    Multiplying the number of passes by the work per pass gives quadratic growth.

  25. 25

    Why is bubble sort considered unsuitable for sorting very large lists?

    Model answer

    Its quadratic worst-case growth makes the amount of work increase rapidly as the list becomes larger.

    Explanation

    For large inputs, algorithms with better scaling are generally preferable.

  26. 26

    How does merge sort organize its work?

    Model answer

    It splits the data into smaller lists, sorts those lists, and merges the sorted sublists into a larger sorted list.

    Explanation

    Breaking a large sorting problem into smaller parts avoids some of the repeated movement associated with bubble sort.

  27. 27

    What is Timsort, and where is it used according to the lecture?

    Model answer

    Timsort is a sorting algorithm used in systems and languages including Android, Python, Octane, Swift, and Rust.

    Explanation

    The lecture describes it as a widely used alternative to simple quadratic sorting methods.

  28. 28

    What broad hierarchy of growth rates did the lecture use to compare algorithmic efficiency?

    Model answer

    It described linear growth as excellent, logarithmic and Nlog⁡NN\log NNlogN growth as common for good algorithms, and polynomial growth as potentially costly as it increases.

    Explanation

    The larger the growth rate, the more quickly computational work can become expensive as input size rises.

  29. 29

    Why does complexity analysis help avoid unfair comparisons between computers?

    Model answer

    It compares how an algorithm scales with input size rather than how fast it runs on a particular machine.

    Explanation

    This focuses comparison on the algorithm’s growth behavior instead of hardware speed.

  30. 30

    What does the Cobham–Edmonds thesis use as a practical rule for distinguishing tractable problems?

    Model answer

    It treats problems solvable in polynomial time as generally tractable and places them in the class PPP.

    Explanation

    This is a rule of thumb based on scaling, not a guarantee that every polynomial-time algorithm is fast in practice.

  31. 31

    What important limitations of the Cobham–Edmonds rule did the lecture identify?

    Model answer

    It ignores the computer, constant factors, and input size, so an algorithm with a large constant or a small input may behave differently in practice.

    Explanation

    For instance, polynomial growth can still be impractical, while an algorithm with worse asymptotic growth may perform better on small inputs.

  32. 32

    What is the traveling salesperson problem (TSP)?

    Model answer

    It asks for a shortest circuit that visits every specified location once and returns to the starting location.

    Explanation

    The circular version requires visiting all sites without repeated visits before returning to the start.

  33. 33

    How can a TSP be represented mathematically for algorithmic analysis?

    Model answer

    It can be represented as a graph whose vertices are locations and whose edges represent travel distances between them.

    Explanation

    A graph provides a structured way to reason about possible routes and their lengths.

  34. 34

    How many possible visit orders are considered in a brute-force search for a circular TSP with a fixed starting point and nnn locations?

    Model answer

    There are (n−1)!(n-1)!(n−1)! possible orders when the starting location is fixed.

    Explanation

    After fixing the start, the remaining locations can be arranged in all possible permutations.

  35. 35

    Why does brute-force search become impractical for larger TSP instances?

    Model answer

    The number of possible tours grows factorially, so the search space becomes enormous even when the number of locations increases by a moderate amount.

    Explanation

    The lecture’s example showed a small instance being manageable while a much larger one would take an impractical length of time.

  36. 36

    What is the nearest-neighbor algorithm for TSP?

    Model answer

    Starting from a location, it repeatedly travels to the nearest location that has not yet been visited.

    Explanation

    The process is simple and fast, but the route it produces is not necessarily optimal.

  37. 37

    Why can trying different starting locations improve a nearest-neighbor TSP route?

    Model answer

    The greedy choices made by nearest neighbor depend on the starting point, so different starts can produce routes of different lengths.

    Explanation

    Comparing routes from multiple starting locations can identify a better approximate solution.

  38. 38

    In a minimization problem such as TSP, why is a known route length an upper bound on the optimal length?

    Model answer

    The optimum cannot be longer than a valid route already found, so the found route’s length is an upper bound.

    Explanation

    The optimal route is the shortest possible; any feasible solution is at least as long as the optimum.

  39. 39

    What does a lower bound on a TSP solution tell us?

    Model answer

    It tells us that no valid solution can be shorter than that bound.

    Explanation

    Lower and upper bounds help indicate how close a computed route may be to the optimum.

  40. 40

    What is the main difference between an exact TSP algorithm and an approximate one?

    Model answer

    An exact algorithm finds the optimum, while an approximate algorithm may return a non-optimal route but can be more practical to compute.

    Explanation

    Approximation is useful when obtaining the exact answer would require too much computation.

  41. 41

    What is the significance of the Held–Karp algorithm for TSP?

    Model answer

    It is an exact algorithm with complexity proportional to N22NN^2 2^NN22N, making it useful for smaller instances but difficult to scale.

    Explanation

    Its exponential factor means that computation grows rapidly as the number of locations increases.

  42. 42

    What guarantee does the Christofides algorithm provide for metric TSP?

    Model answer

    It produces a route no longer than 32\frac{3}{2}23​ times the optimal route length.

    Explanation

    This approximation guarantee bounds how far its solution can be from the optimum.

  43. 43

    Why can an approximation algorithm with a known guarantee be useful even when it does not find the optimum?

    Model answer

    It can provide a practical solution while also giving a bound on how far that solution may be from optimal.

    Explanation

    A guarantee makes the quality of an approximate result more informative than simply knowing that it is non-optimal.

  44. 44

    What does it mean to analyze an algorithm’s best case and worst case?

    Model answer

    Best-case analysis considers the most favorable inputs, while worst-case analysis considers the inputs that require the most work.

    Explanation

    The same algorithm can require different amounts of work depending on the input.

  45. 45

    What is a decision problem?

    Model answer

    It is a problem whose answer is yes or no.

    Explanation

    A question about whether a particular condition holds can be expressed as a decision problem.

  46. 46

    How can an equation such as z=x+yz=x+yz=x+y be converted into a decision problem?

    Model answer

    Ask whether z=x+yz=x+yz=x+y is true, with the answer being yes or no.

    Explanation

    This converts a statement about values into a question with a binary answer.

  47. 47

    How can the TSP be expressed as a decision problem?

    Model answer

    Ask whether there is a tour shorter than a specified distance.

    Explanation

    The decision version asks a yes-or-no question about whether a route meets a length threshold.

  48. 48

    What mathematical problem was Turing investigating when he developed the Turing-machine model?

    Model answer

    He was investigating the Entscheidungsproblem: whether one can determine if a formula follows from a given set of axioms.

    Explanation

    The problem asks whether formal derivability can be decided by a general procedure.

  49. 49

    What role did lambda calculus play in the development of formal models of computation?

    Model answer

    Lambda calculus provided an algebraic way to represent functions and became useful for reasoning about algorithms and computation.

    Explanation

    The lecture describes it as an algebra for expressing functions and operations on them.

  50. 50

    What is a Turing machine in theoretical computer science?

    Model answer

    It is an abstract model of computation that follows rules to read, write, and move along a tape of symbols.

    Explanation

    Its simple structure allows researchers to reason about what computers can compute.

  51. 51

    What does the Church–Turing thesis claim about algorithms and Turing machines?

    Model answer

    It claims that every algorithm can be simulated by a Turing machine and that a Turing machine’s computation can be represented as an algorithm.

    Explanation

    The thesis connects the informal idea of an algorithm with a precise model of computation.

  52. 52

    Why are Turing machines useful even though they are not practical computers?

    Model answer

    They provide a simple theoretical model for reasoning about what computation is possible and for analyzing algorithms.

    Explanation

    Their value is conceptual rather than practical: real computers can be modeled in terms of their computational capabilities.

  53. 53

    What is the class PPP?

    Model answer

    PPP is the set of decision problems solvable by a deterministic Turing machine in polynomial time.

    Explanation

    The class formalizes the idea of problems considered tractable under the polynomial-time rule of thumb.

  54. 54

    What is the class NPNPNP?

    Model answer

    NPNPNP is the set of decision problems for which a proposed solution can be verified in polynomial time.

    Explanation

    Verifying a candidate solution may be easier than finding one.

  55. 55

    Why is a completed Sudoku grid easier to verify than an unsolved Sudoku grid is to solve?

    Model answer

    A completed grid can be checked for valid digits and repeats, while finding a valid completion may require much more search.

    Explanation

    Verification checks a proposed solution; solving requires discovering one.

  56. 56

    Why is every problem in PPP also in NPNPNP?

    Model answer

    If a problem can be solved in polynomial time, its solution can also be verified in polynomial time.

    Explanation

    Solving the problem efficiently provides at least as much information as checking a proposed answer.

  57. 57

    Give examples of problems or applications discussed as belonging to PPP.

    Model answer

    Examples include sorting, linear programming, LZW compression, and the discrete Fourier transform.

    Explanation

    These were presented as practical tasks with polynomial-time solutions.

  58. 58

    Why is an efficient algorithm especially important for computing the discrete Fourier transform in devices?

    Model answer

    It is used repeatedly in applications such as mobile phones and high-definition television, so it must be computed efficiently.

    Explanation

    The lecture notes that these devices perform many such computations every second.

  59. 59

    What is an NP-complete problem, as described in the lecture?

    Model answer

    It is an NP problem whose essential difficulty can be related to that of other NP problems through reductions.

    Explanation

    Reductions show that solving one problem can be transformed into solving another, linking their computational difficulty.

  60. 60

    What does a reduction between problems reveal?

    Model answer

    It shows how an instance of one problem can be transformed into an instance of another, helping compare their difficulty.

    Explanation

    If one problem can be efficiently transformed into another, an efficient solution to the latter can help solve the former.

  61. 61

    What is the unresolved PPP versus NPNPNP question?

    Model answer

    It asks whether every problem whose proposed solution can be verified in polynomial time can also be solved in polynomial time.

    Explanation

    In symbols, the question is whether P=NPP=NPP=NP.

  62. 62

    What is the prevailing view about whether P=NPP=NPP=NP, according to the lecture?

    Model answer

    Most complexity theorists suspect that P≠NPP\ne NPP=NP, but the question remains unresolved.

    Explanation

    The lecture presents this as a widely held expectation, not a proven result.

  63. 63

    Why could a proof that P=NPP=NPP=NP affect public-key cryptography?

    Model answer

    Some cryptographic systems rely on a gap between efficiently verifying a solution and finding it; if P=NPP=NPP=NP, that gap might disappear.

    Explanation

    The lecture cautions that the precise consequences would depend on how such a proof worked.

  64. 64

    How does the asymmetry between finding and verifying a solution support public-key cryptography?

    Model answer

    A legitimate user may be able to verify or use an encoded solution efficiently while an attacker faces a much harder search problem.

    Explanation

    The difference in computational difficulty can help protect information from an eavesdropper.

  65. 65

    What is the class NP-hard used to describe?

    Model answer

    It describes problems at least as hard as NP-complete problems, including problems that may lie outside NPNPNP.

    Explanation

    The lecture uses NP-hard for a broader collection of especially difficult problems.

  66. 66

    How was co-NP characterized in the lecture?

    Model answer

    It is a class of problems for which it is easy to exclude wrong answers, rather than easy to verify right answers.

    Explanation

    Whether co-NP is the same as NP is not known from the account given.

  67. 67

    What distinguishes PSPACE from a class defined by a time limit?

    Model answer

    PSPACE contains problems solvable using a polynomial amount of memory, even if the computation may take unlimited time.

    Explanation

    Its defining resource is space rather than a polynomial time bound.

  68. 68

    What do the classes BPP and BQP represent?

    Model answer

    BPP concerns problems solvable probabilistically in polynomial time, while BQP is the corresponding class associated with quantum computing.

    Explanation

    The lecture notes that the relationships between these classes and other classes are not all settled.

  69. 69

    What is the halting problem?

    Model answer

    It asks whether, given a Turing machine and a program, one can determine if the machine will eventually stop.

    Explanation

    Although it sounds straightforward, the lecture identifies it as a problem that cannot be decided by a general algorithm.

  70. 70

    What does it mean to say that a problem is undecidable?

    Model answer

    It means there is no algorithm that can correctly decide the answer for every possible instance of the problem.

    Explanation

    The halting problem is an example of a problem known to be undecidable.

  71. 71

    How can an algorithm be biased even if the algorithm itself has no intentions?

    Model answer

    Its design or data can produce systematically unfair decisions, for example when a proxy such as location is correlated with ethnicity.

    Explanation

    The lecture’s fraud-screening example used credit scores correlated with location, which was itself correlated with ethnicity.

  72. 72

    What is one approach to reducing bias in algorithms?

    Model answer

    Examine and improve the training data and assess whether the system’s decisions create unfair impacts.

    Explanation

    The lecture emphasizes that bias-free algorithms require attention to the data and design choices behind them.

  73. 73

    Why can an algorithm running on a device become different from the system originally specified?

    Model answer

    It may receive software updates and learn from new data or experience, changing its behavior after purchase.

    Explanation

    This creates questions about whether the system still matches its original specification.

  74. 74

    What questions arise when algorithms change through updates or learning?

    Model answer

    It becomes important to ask whether their behavior can still be verified and tested against what they are supposed to do.

    Explanation

    Changing software and data can make it harder to establish that a system reliably produces the intended outputs.

  75. 75

    What was the central problem with the algorithm used to award A-level results when exams were canceled?

    Model answer

    Although the algorithm was tested and its effects were documented, decision-makers did not foresee the wider impact of severely disadvantaging many students.

    Explanation

    The consequences affected a much larger share of students when multiple exam results per person were considered.

  76. 76

    What does the A-level results example show about responsibility for algorithmic harm?

    Model answer

    The failure may lie not only in the algorithm but also in decision-makers’ failure to anticipate human consequences and fairness concerns.

    Explanation

    The lecture argues that the system failed to account adequately for the priorities and expectations of the students affected.

1 of 76
Question 1 of 76

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent