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

  • 63Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Algorithm Foundations

What is an algorithm?

63 questions

  1. 1

    What is an algorithm?

    Model answer

    An algorithm is a step-by-step computational procedure for solving a problem.

    Explanation

    An algorithm is a computational procedure: a defined sequence of steps for carrying out a computation.

  2. 2

    Describe the basic input-output model of an algorithm.

    Model answer

    An algorithm takes input, performs a computation, and produces output.

    Explanation

    The input-output view describes what information a procedure receives and what result it produces.

  3. 3

    Give the input and output specification for an algorithm that multiplies two numbers.

    Model answer

    For multiplication, the inputs are integers nnn and mmm, and the required output is their product, mnmnmn.

    Explanation

    The specification says what the procedure must accomplish, independently of the particular steps used.

  4. 4

    What is an instance of a problem? Give the multiplication example from the lesson.

    Model answer

    An instance is a particular set of input values; for example, n=121n=121n=121 and m=234m=234m=234 is an instance of multiplication.

    Explanation

    An instance is one concrete case obtained by assigning actual values to the problem's inputs.

  5. 5

    For the instance n=121n=121n=121 and m=234m=234m=234, what is the algorithm, as distinct from the instance?

    Model answer

    The algorithm is the step-by-step procedure that computes the product for the given numbers.

    Explanation

    The algorithm is the procedure applied to an instance; the instance itself consists of the chosen inputs.

  6. 6

    Summarize the grade-school algorithm for multiplying two multi-digit numbers.

    Model answer

    Multiply by each digit of one number, shift each partial product according to its place, then add the partial products.

    Explanation

    Grade-school multiplication follows a repeatable procedure: multiply by each digit, shift the partial products according to place value, and add them.

  7. 7

    Why is executing an algorithm described as a mechanical process?

    Model answer

    Executing an algorithm is a mechanical, step-by-step process; it does not require creativity while it is being run.

    Explanation

    Once an algorithm is specified, carrying it out involves following its instructions rather than inventing new steps for each input.

  8. 8

    How do algorithms connect a problem's inputs to its answer?

    Model answer

    An algorithm is a computational recipe that transforms input into an answer to a problem.

    Explanation

    Algorithms are abstract recipes for computations, with inputs and outputs, that can be carried out systematically.

  9. 9

    Were algorithms invented with modern computers? Explain briefly.

    Model answer

    Algorithms are ancient computational procedures, not inventions that began with modern computers.

    Explanation

    Algorithms existed long before modern computers; people in many cultures developed procedures to perform needed calculations.

  10. 10

    What kind of problems did many early algorithms address?

    Model answer

    Many of the earliest known algorithms were numerical procedures for carrying out calculations.

    Explanation

    Early algorithms were often numerical because people needed reliable ways to calculate quantities and solve practical problems.

  11. 11

    How could multiplication algorithms help people calculate the area of land?

    Model answer

    People could find a rectangular plot's area by measuring its sides and multiplying the measurements.

    Explanation

    Measuring the sides of a rectangular plot and multiplying them gives its area, making multiplication a useful practical algorithm.

  12. 12

    Name several events for which early people used calculations and algorithms to make predictions.

    Model answer

    Algorithms supported calculations used to predict events such as eclipses, full moons, and tides.

    Explanation

    Predicting celestial and natural cycles required calculations, including calculations involving eclipses, full moons, and tides.

  13. 13

    What example of algorithmic calculation is associated with Chinese mathematicians in the lesson?

    Model answer

    Chinese mathematicians used algorithms to carry out calculations on the abacus.

    Explanation

    The lesson gives calculations on the abacus as an example of algorithms used by Chinese mathematicians.

  14. 14

    What two related contributions does the lesson attribute to ancient Indian mathematicians?

    Model answer

    Ancient Indian mathematicians developed the place-value number system and arithmetic algorithms that worked with it.

    Explanation

    Place value represents numbers according to the positions of their digits; the lesson credits ancient Indian mathematicians with developing it and related arithmetic procedures.

  15. 15

    What does the Euclidean algorithm compute?

    Model answer

    The Euclidean algorithm is a procedure for finding the greatest common divisor, or GCD, of numbers.

    Explanation

    The lesson identifies Euclid's algorithm as a Greek example for computing greatest common divisors.

  16. 16

    What is the purpose of the Sieve of Eratosthenes?

    Model answer

    The Sieve of Eratosthenes is an algorithm for identifying prime numbers.

    Explanation

    The sieve described in the lesson is used to determine which numbers are prime.

  17. 17

    What is one other historical application of algorithms mentioned in the lesson?

    Model answer

    People used algorithms to perform calendrical calculations.

    Explanation

    Calendrical calculations were another historical use of algorithms, alongside practical arithmetic and astronomical prediction.

  18. 18

    According to the lesson, where does the word “algorithm” come from?

    Model answer

    The word “algorithm” derives from the name al-Khwarizmi, a mathematician associated with a place in what is now Persia.

    Explanation

    The term is traced to the name of the mathematician al-Khwarizmi, whose name was associated with a place in the region of present-day Persia.

  19. 19

    Why are the numerals called Arabic numerals in the West, according to the lesson?

    Model answer

    The numerals called Arabic numerals in the West were invented by Indian mathematicians and passed on through Arab traders.

    Explanation

    The lesson explains that numerals known in the West as Arabic numerals originated with Indian mathematicians and were transmitted through Arab traders.

  20. 20

    Why were some historically important algorithms not published by their inventors?

    Model answer

    Algorithms were sometimes treated as secondary to mathematical theorems, and some important procedures were consequently left unpublished.

    Explanation

    The lesson notes that mathematicians often valued the theorem more than the procedure, so some important algorithms were not published by their inventors.

  21. 21

    How did computers change the demand for algorithms?

    Model answer

    The advent of computers increased demand for efficient algorithms to handle very large calculations reliably.

    Explanation

    Computers created demand for fast procedures that could handle calculations too large or error-prone for people to perform practically by hand.

  22. 22

    Give two examples of large computations that motivated the use of computers and efficient algorithms.

    Model answer

    Examples include multiplying numbers with thousands of digits and checking whether a million-digit number is prime.

    Explanation

    The lesson cites multiplying numbers with thousands or hundreds of thousands of digits and testing a million-digit number for primality as examples of computationally demanding tasks.

  23. 23

    Why did the study of algorithms become a distinct, important field after computers appeared?

    Model answer

    Computers made efficient procedures important enough that algorithms became a first-class field of study.

    Explanation

    The lesson presents the advent of computers as the point when algorithms began to be studied as a discipline in their own right, rather than merely as an afterthought to mathematics.

  24. 24

    What role did al-Khwarizmi's book play in the history described in the lesson?

    Model answer

    Al-Khwarizmi wrote a notable book on arithmetic and solving equations; its Latin translation helped spread his work among Western scholars.

    Explanation

    The lesson says the word is connected to al-Khwarizmi's book on arithmetic and solving equations, which was translated into Latin and studied in the West.

  25. 25

    What makes the study of algorithms a computer science discipline, as described in the lesson?

    Model answer

    Modern algorithms are abstract computational procedures designed to be implemented on computers.

    Explanation

    The lesson describes algorithms as abstract procedures intended to be implemented and run on computers, which helps distinguish modern algorithmics as a computer science discipline.

  26. 26

    What model of computation did Alan Turing introduce, and when?

    Model answer

    In the 1930s, Alan Turing proposed the Turing machine as a model of computation.

    Explanation

    Turing introduced a formal model of computation in the 1930s, providing a way to define what counts as a computational procedure.

  27. 27

    How does the Turing machine clarify the meaning of a computational procedure?

    Model answer

    A Turing machine is a formal model of computation that helps define what counts as a computational procedure.

    Explanation

    The Turing machine provides the formal computational model used in the lesson to clarify what a computational procedure is.

  28. 28

    State the Church–Turing thesis as presented in the lesson.

    Model answer

    The Church–Turing thesis says that any physically realizable computer is as powerful as a Turing machine.

    Explanation

    The Church–Turing thesis, associated with Alonzo Church and Alan Turing, states that any computer physically realizable in our world has the computational power of a Turing machine.

  29. 29

    Does the lesson require a detailed study of Turing machines to discuss algorithms? Explain.

    Model answer

    The lesson treats computational procedures as formally definable but does not require a detailed study of Turing machines.

    Explanation

    The lesson distinguishes knowing that a formal definition exists from studying its full details; the course does not require students to learn the Turing-machine definition in depth.

  30. 30

    What contribution to algorithm study does the lesson attribute to Don Knuth?

    Model answer

    Don Knuth was highly influential in the study of modern algorithms.

    Explanation

    The lesson identifies Don Knuth as an influential figure in making the study of modern algorithms a serious discipline.

  31. 31

    How does the lesson characterize The Art of Computer Programming?

    Model answer

    It is a comprehensive reference for algorithms and computational procedures, rather than a standard textbook.

    Explanation

    The lesson characterizes Knuth's The Art of Computer Programming as a broad reference work for finding and studying algorithms, rather than as a conventional textbook.

  32. 32

    How can a search engine use a person's location when searching for nearby restaurants?

    Model answer

    A search engine can use the query and the user's approximate location to find relevant nearby restaurants and their reviews.

    Explanation

    Searching for local restaurant recommendations combines a search query with location information and information about businesses and reviews.

  33. 33

    What is the purpose of the prebuilt index in the restaurant-search example?

    Model answer

    A prebuilt index maps geographical locations to search terms and helps retrieve relevant places efficiently.

    Explanation

    The lesson describes a prebuilt index that connects geographical locations with search terms, allowing relevant places to be retrieved quickly.

  34. 34

    Describe the information relationships used in the lesson's local restaurant-search example.

    Model answer

    The index connects locations to search terms, search terms to restaurant locations, and restaurants to reviews.

    Explanation

    The described data relationships include locations linked to search terms, terms linked to places, and restaurants linked to reviews.

  35. 35

    Outline how the restaurant search turns a query into a results page.

    Model answer

    The search uses the user's location to find nearby restaurants, narrows them by the query, and gathers review information for the results.

    Explanation

    With the location and query understood, the search can retrieve nearby restaurants matching the requested kind and assemble results with their reviews.

  36. 36

    Why is the search index built before a user submits a query?

    Model answer

    Building the index beforehand allows the search engine to retrieve relevant information quickly when a query arrives.

    Explanation

    The lesson says the index is built beforehand and used for fast retrieval, so the search need not construct all the information from scratch each time.

  37. 37

    Why must a search engine retrieve and assemble results quickly?

    Model answer

    The search and page assembly must happen within milliseconds to seconds so the results feel responsive.

    Explanation

    Search results must arrive quickly enough that the page does not feel slow to load; the lesson gives milliseconds to seconds as the expected scale.

  38. 38

    What information must a navigation app establish before solving a route problem?

    Model answer

    It must determine the physical map locations of both the starting address and the destination.

    Explanation

    A navigation service must locate both addresses on a physical map before it can calculate routes between them.

  39. 39

    What problem does a navigation app solve when asked for a route from address AAA to address BBB?

    Model answer

    It computes a shortest path between the locations of addresses AAA and BBB.

    Explanation

    A shortest-path algorithm identifies a route from the origin to the destination that minimizes path length according to the route network.

  40. 40

    Why might a navigation app provide alternative paths in addition to a shortest path?

    Model answer

    It can compute alternative routes as well as a shortest path so the user can compare options.

    Explanation

    Showing alternatives gives the user more than one possible route instead of presenting only the single shortest path.

  41. 41

    How does current traffic information contribute to route planning?

    Model answer

    It considers current traffic on the routes to estimate the journey time from AAA to BBB.

    Explanation

    Current traffic conditions affect how long a route is expected to take, so the app uses traffic information when estimating travel time.

  42. 42

    Why does the lesson describe route planning as relying on a combination of algorithms?

    Model answer

    Route planning combines multiple algorithms for locating places, finding paths, considering traffic, and estimating travel time.

    Explanation

    The route, alternatives, and travel-time estimate are produced by combining multiple algorithms rather than relying on a single procedure.

  43. 43

    What resource constraint creates scheduling challenges at airports?

    Model answer

    Runways and taxiways are limited resources that must serve many aircraft.

    Explanation

    Airports have limited infrastructure, such as runways and taxiways, while many aircraft may need to use it.

  44. 44

    Who schedules planes waiting to land, and is this usually automated according to the lesson?

    Model answer

    Air traffic managers schedule aircraft waiting to land, often through manual decisions.

    Explanation

    The lesson says air traffic managers schedule planes waiting to land, and that this is often done manually rather than automatically.

  45. 45

    Why is assigning landed planes to gates an example of an assignment problem?

    Model answer

    Assigning landed planes to gates is an assignment problem.

    Explanation

    Assigning an aircraft to a gate is an assignment problem because aircraft must be matched with available gates.

  46. 46

    What type of problem is involved in scheduling planes to land or use taxiways?

    Model answer

    Scheduling planes to land or use taxiways is a scheduling problem.

    Explanation

    The lesson classifies decisions about the order or timing of aircraft landing on taxiways as scheduling problems.

  47. 47

    What scheduling problem arises when several planes are ready to take off?

    Model answer

    The runway must be scheduled among the planes waiting to take off.

    Explanation

    A runway must serve multiple planes waiting to depart, so deciding which planes use it and when is a scheduling task.

  48. 48

    Name several kinds of algorithmic logistics that can arise during airport operations.

    Model answer

    Airport logistics combine multiple operational problems, including landing and takeoff schedules, gate assignments, and baggage handling.

    Explanation

    The lesson emphasizes that airport operations involve several linked decisions, including landing, gate assignment, takeoff, and baggage logistics.

  49. 49

    How do airlines generally assign aircraft to routes?

    Model answer

    Airlines typically schedule the aircraft they have available across the routes they need to operate.

    Explanation

    Airlines generally allocate available aircraft to the routes they need to fly instead of permanently reserving one aircraft for each route.

  50. 50

    Why might an airline substitute a different plane for a scheduled flight?

    Model answer

    An airline may bring a different aircraft into service when a plane is delayed or has a technical problem.

    Explanation

    When an aircraft is delayed or has a technical fault, another available plane may be assigned, requiring adjustments to the vehicle plan.

  51. 51

    What names does the lesson give to problems of assigning or routing aircraft to routes?

    Model answer

    They are examples of vehicle assignment or vehicle routing problems.

    Explanation

    The lesson calls the problems of assigning or routing aircraft to routes vehicle assignment or vehicle routing problems.

  52. 52

    What transport-planning task does a delivery company perform for a package?

    Model answer

    The company schedules each package onto suitable planes or other transport to move it from origin to destination.

    Explanation

    A delivery company must choose how to move each package through its transport network from its origin toward its destination.

  53. 53

    What is the traveling salesperson problem in the package-delivery example?

    Model answer

    Planning a truck tour that visits the delivery addresses and returns to its depot is a traveling salesperson problem, or TSP.

    Explanation

    A delivery truck must visit multiple addresses and return to its starting depot; the lesson identifies this as the traveling salesperson problem.

  54. 54

    How does the lesson characterize the difficulty of the TSP?

    Model answer

    The TSP is a very difficult problem to solve efficiently.

    Explanation

    The TSP is described as very difficult to solve, making efficient solutions a challenging algorithmic goal.

  55. 55

    Why could improving the efficiency of TSP solutions have a major impact on delivery companies?

    Model answer

    More efficient TSP solutions can save delivery companies substantial amounts of money.

    Explanation

    Because delivery companies operate many routes, even modest improvements in solving routing problems can reduce their costs substantially.

  56. 56

    What practical effect can routing algorithms have on package delivery?

    Model answer

    Routing algorithms can reduce delivery costs and improve the efficiency of real-world logistics.

    Explanation

    The lesson uses vehicle routing and delivery tours to show that algorithms can improve practical operations, not merely perform abstract calculations.

  57. 57

    What factors can algorithms consider when routing aircraft?

    Model answer

    Algorithms can route planes along fuel-efficient paths while taking wind conditions into account.

    Explanation

    The lesson mentions that a plane's route may also be chosen to account for wind and fuel efficiency.

  58. 58

    How does the residency match use a stable-matching algorithm?

    Model answer

    The residency match assigns medical students to residency positions using a stable-matching algorithm.

    Explanation

    The residency matching program assigns medical students to training positions at hospitals; the lesson identifies it as an application of the stable marriage algorithm.

  59. 59

    Which two groups are matched in the residency program, and what does each seek?

    Model answer

    It matches students seeking training with hospitals that have residency positions to fill.

    Explanation

    Matching addresses preferences on both sides: students seek suitable training positions, while hospitals seek residents for available positions.

  60. 60

    What practical benefits does the residency match provide to students and hospitals?

    Model answer

    It helps students obtain training positions and helps hospitals fill vacancies.

    Explanation

    The match helps fill available hospital training positions while helping students obtain residency placements.

  61. 61

    Give another real-world matching application mentioned in the lesson besides residency placement.

    Model answer

    Matching algorithms can help pair kidney donors with kidney patients.

    Explanation

    The lesson gives matching kidney donors to kidney patients as another application of algorithms for allocation.

  62. 62

    What broader purpose do matching algorithms serve in the examples from the lesson?

    Model answer

    Matching algorithms help allocate opportunities or resources, such as residency positions or donor kidneys, to compatible participants.

    Explanation

    The lesson highlights that matching algorithms can allocate scarce opportunities or resources to people who need them.

  63. 63

    What general conclusion does the lesson draw from its examples of algorithms in daily life?

    Model answer

    Algorithms help society coordinate logistics, schedules, routes, and allocations in many everyday activities.

    Explanation

    Together, the examples show algorithms coordinating decisions and allocations in everyday systems, often behind the scenes.

1 of 63
Question 1 of 63

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent