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

  • 45Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Algorithm Basics

Which description best defines an algorithm?

45 questions

  1. 1

    Which description best defines an algorithm?

    1. A

      A physical device that stores input values

    2. B

      A mathematical result that requires no computation

    3. C

      A computational procedure for solving a problem

    4. D

      A collection of data that has already been computed

    Correct answer
    C

    A computational procedure for solving a problem

    Explanation

    An algorithm is a computational procedure: a step-by-step recipe for carrying out a computation or solving a problem.

  2. 2

    Which pattern captures the basic input-computation-output view of an algorithm?

    1. A

      It stores an output first and then determines its inputs

    2. B

      It accepts only text and always produces a numerical output

    3. C

      It describes a problem without specifying any computation

    4. D

      It receives inputs, performs computation, and produces an output

    Correct answer
    D

    It receives inputs, performs computation, and produces an output

    Explanation

    An algorithm can be viewed as a procedure that accepts inputs, performs computation, and produces an output.

  3. 3

    For an algorithm that multiplies two numbers, what is the stated input-output specification?

    1. A

      The inputs are two integers, and the output is their quotient

    2. B

      The inputs are two products, and the output is an integer factor

    3. C

      The inputs are two integers, and the output is their product

    4. D

      The inputs are two integers, and the output is their sum

    Correct answer
    C

    The inputs are two integers, and the output is their product

    Explanation

    For multiplication, the specified inputs are two integers, and the required output is their product.

  4. 4

    What makes the pair 121121121 and 234234234 an instance of the two-number multiplication problem?

    1. A

      A particular input, such as the pair 121 and 234

    2. B

      The product that results from multiplying any two integers

    3. C

      The step-by-step procedure for multiplying two numbers

    4. D

      The rule that multiplication must use carrying

    Correct answer
    A

    A particular input, such as the pair 121 and 234

    Explanation

    An instance is formed by plugging particular values into a problem's input specification. Here, 121 and 234 are the chosen inputs.

  5. 5

    After an instance of a problem is supplied, what does an algorithm provide?

    1. A

      A general description of the problem's historical importance

    2. B

      A list of possible outputs without instructions for obtaining one

    3. C

      A step-by-step procedure for computing the output from the inputs

    4. D

      A statement that identifies the input but leaves computation to intuition

    Correct answer
    C

    A step-by-step procedure for computing the output from the inputs

    Explanation

    Once the input values are specified, an algorithm gives a step-by-step procedure for computing the answer.

  6. 6

    What is characteristic of carrying out an algorithm once its input is fixed?

    1. A

      The procedure produces an answer without processing its inputs

    2. B

      The procedure is followed mechanically, step by step

    3. C

      The procedure requires a new creative decision at every step

    4. D

      The procedure works only if the input values are guessed

    Correct answer
    B

    The procedure is followed mechanically, step by step

    Explanation

    Executing an algorithm is described as following mechanical steps, rather than relying on creativity at each step.

  7. 7

    Which description best captures the grade-school procedure for multiplying multi-digit numbers?

    1. A

      The number of digits determines the answer without further arithmetic

    2. B

      The digits are added first, and the resulting sum is repeatedly divided

    3. C

      Partial products are shifted to reflect place value and then added

    4. D

      Each digit is processed independently, and the partial products are never combined

    Correct answer
    C

    Partial products are shifted to reflect place value and then added

    Explanation

    In the grade-school method, each digit produces a partial product; the rows are shifted according to place value and then added.

  8. 8

    Why does grade-school multiplication count as an algorithm?

    1. A

      It is not an algorithm because the answer is numerical

    2. B

      It is an algorithm only if it uses a place-value number system

    3. C

      It is an algorithm only when performed by a computer

    4. D

      It is an algorithm because it gives a step-by-step computation

    Correct answer
    D

    It is an algorithm because it gives a step-by-step computation

    Explanation

    The example illustrates that a familiar arithmetic routine—such as multiplication by digits, shifting partial products, and adding—is an algorithm because it specifies steps for computing an answer.

  9. 9

    Which statement about the history of algorithms is supported by the content?

    1. A

      Ancient societies used mathematics but had no computational procedures

    2. B

      Algorithms were first created after the invention of electronic computers

    3. C

      People developed computational procedures in ancient times

    4. D

      Algorithms became possible only after the invention of the internet

    Correct answer
    C

    People developed computational procedures in ancient times

    Explanation

    Algorithms existed long before modern computers; ancient societies developed procedures to carry out needed calculations.

  10. 10

    What was a common focus of some of the earliest known algorithms?

    1. A

      They often provided procedures for numerical calculations

    2. B

      They mainly described how to build computers

    3. C

      They mainly organized written records without performing calculations

    4. D

      They mainly assigned jobs in modern transportation systems

    Correct answer
    A

    They often provided procedures for numerical calculations

    Explanation

    Early algorithms were often numerical procedures, including multiplication and other calculations needed for practical or predictive purposes.

  11. 11

    Why might people have needed an algorithm for multiplying two numbers when measuring land?

    1. A

      Dividing one measured side by the other to find its perimeter

    2. B

      Comparing the side lengths to determine the plot's location

    3. C

      Multiplying the measured side lengths to calculate its area

    4. D

      Adding the side lengths to predict the plot's harvest

    Correct answer
    C

    Multiplying the measured side lengths to calculate its area

    Explanation

    Measuring the sides of a rectangular plot and multiplying them provides a way to calculate its area.

  12. 12

    Which practical need helped motivate early computational procedures?

    1. A

      To determine which number system should be used in trade

    2. B

      To calculate how many computers would be needed for a task

    3. C

      To decide which arithmetic operations could be taught in schools

    4. D

      To predict events such as eclipses, full moons, and tides

    Correct answer
    D

    To predict events such as eclipses, full moons, and tides

    Explanation

    Calculations were used to predict astronomical and natural events, including eclipses, full moons, and tides.

  13. 13

    Which example of an early calculation method is associated with Chinese mathematicians?

    1. A

      Chinese mathematicians used the abacus for calculations

    2. B

      Indian mathematicians used the abacus to define the Turing machine

    3. C

      Greek mathematicians invented the abacus for place-value arithmetic

    4. D

      Persian mathematicians used the abacus to calculate internet search results

    Correct answer
    A

    Chinese mathematicians used the abacus for calculations

    Explanation

    The content gives calculations carried out on the abacus by Chinese mathematicians as an example of early algorithms.

  14. 14

    What contribution to arithmetic is attributed to ancient Indian mathematicians?

    1. A

      They developed a place-value number system and associated arithmetic procedures

    2. B

      They developed the first computer and its operating system

    3. C

      They invented the Euclidean algorithm and the sieve for prime testing

    4. D

      They developed the Church–Turing thesis for physical computers

    Correct answer
    A

    They developed a place-value number system and associated arithmetic procedures

    Explanation

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

  15. 15

    What problem does the Euclidean algorithm address in the examples given?

    1. A

      It is a procedure for calculating greatest common divisors

    2. B

      It is a procedure for assigning planes to airport gates

    3. C

      It is a procedure for listing all possible prime factors of a polynomial

    4. D

      It is a procedure for finding the shortest route between two places

    Correct answer
    A

    It is a procedure for calculating greatest common divisors

    Explanation

    The Euclidean algorithm is presented as a Greek mathematical procedure for calculating greatest common divisors.

  16. 16

    What is the purpose of the sieve of Eratosthenes in the historical examples?

    1. A

      It finds a shortest path through a road network

    2. B

      It computes the area of a rectangular piece of land

    3. C

      It assigns residents to hospitals based on preferences

    4. D

      It helps identify prime numbers

    Correct answer
    D

    It helps identify prime numbers

    Explanation

    The sieve associated with Eratosthenes is given as an ancient algorithm for determining whether numbers are prime.

  17. 17

    How were algorithms sometimes regarded in mathematics before the advent of computers?

    1. A

      Every algorithm had to be published before its theorem was studied

    2. B

      Algorithms were sometimes treated as less important than theorems

    3. C

      Mathematicians could not invent procedures before computers existed

    4. D

      Algorithms were always considered more important than mathematical results

    Correct answer
    B

    Algorithms were sometimes treated as less important than theorems

    Explanation

    Before computers, algorithms were often treated as secondary to mathematical theorems, and some procedures were not considered worth publishing.

  18. 18

    What change did computers bring to the kinds of computations people wanted to perform?

    1. A

      They enabled very large computations impractical for people to perform reliably

    2. B

      They made all mathematical problems solvable without algorithms

    3. C

      They eliminated the need to consider computational efficiency

    4. D

      They made numerical calculations unnecessary in scientific work

    Correct answer
    A

    They enabled very large computations impractical for people to perform reliably

    Explanation

    Computers made it practical to pursue computations too large for people to carry out reliably, such as multiplying very long numbers or testing a million-digit number for primality.

  19. 19

    Why did the advent of computers help establish the study of algorithms as a serious field?

    1. A

      Computers reduced interest in procedures for solving problems

    2. B

      Computers made algorithms useful only for arithmetic education

    3. C

      Computers caused algorithm study to become separate from computer science

    4. D

      Computers increased demand for efficient algorithms and their systematic study

    Correct answer
    D

    Computers increased demand for efficient algorithms and their systematic study

    Explanation

    The demand to perform large computations efficiently led people to study algorithms as a distinct field rather than treating them as an afterthought.

  20. 20

    What makes the study of algorithms distinctively a computer science discipline in the account?

    1. A

      Algorithms are a branch of computer science because they avoid mathematical ideas

    2. B

      Algorithms are a computer science discipline because their procedures are meant to be implemented on computers

    3. C

      Algorithms are a computer science discipline because computers invent them automatically

    4. D

      Algorithms belong only to mathematics because they cannot be implemented

    Correct answer
    B

    Algorithms are a computer science discipline because their procedures are meant to be implemented on computers

    Explanation

    Algorithms draw on mathematics, but the content characterizes their study as a computer science discipline because the procedures are intended for implementation on computers.

  21. 21

    What important contribution is attributed to Alan Turing in the 1930s?

    1. A

      Don Knuth proposed a model of computation in the 1930s

    2. B

      Alan Turing proposed a model of computation in the 1930s

    3. C

      Eratosthenes proposed a model for modern electronic computers

    4. D

      Alonzo Church introduced the abacus in the 1930s

    Correct answer
    B

    Alan Turing proposed a model of computation in the 1930s

    Explanation

    In the 1930s, Alan Turing introduced a model of computation called the Turing machine.

  22. 22

    Why is the Turing machine important to the meaning of a computational procedure?

    1. A

      It is a model of computation that clarifies what a computational procedure is

    2. B

      It is a device for routing aircraft between airports

    3. C

      It is a numerical algorithm for multiplying large integers

    4. D

      It is an index that links search terms to geographic locations

    Correct answer
    A

    It is a model of computation that clarifies what a computational procedure is

    Explanation

    The Turing machine provides a formal model that helps define what counts as a computational procedure.

  23. 23

    What claim does the Church–Turing thesis make about physically realizable computers?

    1. A

      Any physically realizable computer is as powerful as a Turing machine

    2. B

      Any computer is more powerful than a Turing machine if it uses electronics

    3. C

      Only computers built from silicon can carry out a computational procedure

    4. D

      A Turing machine can perform only calculations that humans do mentally

    Correct answer
    A

    Any physically realizable computer is as powerful as a Turing machine

    Explanation

    The Church–Turing thesis states that any computer physically realizable under the laws of physics is as powerful as a Turing machine.

  24. 24

    How can the Turing machine be relevant to algorithm study even if its details are not taught?

    1. A

      It is a historical idea with no connection to computational procedures

    2. B

      It provides a formal model for computation, even when its details are not studied

    3. C

      It shows that algorithms cannot be described precisely

    4. D

      It is another name for a computer search index

    Correct answer
    B

    It provides a formal model for computation, even when its details are not studied

    Explanation

    The Turing machine supplies a formal foundation, even though the course described in the content does not require teaching its full definition.

  25. 25

    What role is Don Knuth said to have played in modern algorithm study?

    1. A

      His work established that no physical computer can be built

    2. B

      His work helped make algorithm study a serious discipline

    3. C

      He created the first airport scheduling algorithm

    4. D

      He invented the ancient Indian place-value number system

    Correct answer
    B

    His work helped make algorithm study a serious discipline

    Explanation

    The account credits Don Knuth's work with helping establish the systematic study of algorithms as a serious discipline.

  26. 26

    Why is a prebuilt index useful to a search engine?

    1. A

      It calculates restaurant reviews only after a user visits a restaurant

    2. B

      It builds an index beforehand to support rapid searches

    3. C

      It waits for each search and manually creates a new map

    4. D

      It asks the user to provide every relevant webpage directly

    Correct answer
    B

    It builds an index beforehand to support rapid searches

    Explanation

    A search engine can build an index in advance so it can quickly retrieve relevant locations and information when a query arrives.

  27. 27

    How can a search engine find Greek restaurants near a user rather than in an unrelated region?

    1. A

      It combines approximate location information with the search query

    2. B

      It selects results randomly from locations around the world

    3. C

      It uses the search terms but cannot consider geographic location

    4. D

      It uses the user's location but ignores the search terms

    Correct answer
    A

    It combines approximate location information with the search query

    Explanation

    A local search can use the user's approximate GPS location together with the query to find relevant nearby results.

  28. 28

    Which relationships are described as part of the search index and related services?

    1. A

      It connects each search term only to the computer that entered it

    2. B

      It connects geographic locations to search terms and restaurants to reviews

    3. C

      It connects each review directly to a route's traffic conditions

    4. D

      It connects each user's name directly to a list of travel times

    Correct answer
    B

    It connects geographic locations to search terms and restaurants to reviews

    Explanation

    The described index connects geographic locations to search terms, such as Greek restaurants, and connects restaurants with their reviews.

  29. 29

    How does the described local restaurant search turn a query into useful results?

    1. A

      It uses reviews alone to infer the user's location and query

    2. B

      It creates a new restaurant database from scratch for every search

    3. C

      It returns every restaurant worldwide and leaves location filtering to the user

    4. D

      It uses location and the query to retrieve nearby relevant restaurants and their information

    Correct answer
    D

    It uses location and the query to retrieve nearby relevant restaurants and their information

    Explanation

    The search system uses the user's location to identify relevant nearby places, then retrieves results for the requested kind of restaurant and associated information.

  30. 30

    Why does a search engine need to perform its search quickly?

    1. A

      They must finish before the user enters a query

    2. B

      They need to return results in milliseconds to seconds

    3. C

      They are required to wait until every restaurant submits a new review

    4. D

      They can take several days because the index is built beforehand

    Correct answer
    B

    They need to return results in milliseconds to seconds

    Explanation

    Search algorithms need to return results rapidly—on the order of milliseconds to seconds—so that the service does not feel too slow.

  31. 31

    What central problem does a navigation app solve when finding a route from address A to address B?

    1. A

      It locates both addresses on a map and solves a shortest-path problem

    2. B

      It assigns an airplane to each address on the route

    3. C

      It chooses a route without representing roads or locations

    4. D

      It finds a route by sorting addresses alphabetically

    Correct answer
    A

    It locates both addresses on a map and solves a shortest-path problem

    Explanation

    A navigation service represents addresses on a physical map and computes a shortest path between them.

  32. 32

    Besides a shortest path, what may a route-finding service provide?

    1. A

      It provides only routes that pass through the same location

    2. B

      It replaces the shortest path with a randomly selected route

    3. C

      It can compute alternative paths in addition to a shortest path

    4. D

      It avoids showing routes until traffic information is unavailable

    Correct answer
    C

    It can compute alternative paths in addition to a shortest path

    Explanation

    The service may provide alternative routes as well as a shortest path, giving the traveler other options.

  33. 33

    How does current traffic information contribute to route guidance?

    1. A

      It ignores traffic and reports only the physical distance

    2. B

      It uses the number of alternative routes as the only time estimate

    3. C

      It uses current traffic information to estimate travel time

    4. D

      It uses restaurant reviews to estimate travel time

    Correct answer
    C

    It uses current traffic information to estimate travel time

    Explanation

    Current traffic information helps a navigation service estimate how long each path will take, rather than relying only on route distance.

  34. 34

    Why do airports face scheduling problems involving runways and taxiways?

    1. A

      Runways are assigned permanently to individual aircraft

    2. B

      Airports have unlimited runways, so scheduling is unnecessary

    3. C

      Limited runways and taxiways create resource-scheduling problems

    4. D

      Taxiways are used only to calculate passenger preferences

    Correct answer
    C

    Limited runways and taxiways create resource-scheduling problems

    Explanation

    Airports have limited runways and taxiways, so the use of these resources must be scheduled as planes arrive or prepare to depart.

  35. 35

    What kind of problem is assigning a gate to a plane that has landed?

    1. A

      It is an example of an assignment problem

    2. B

      It is an example of a shortest-path problem

    3. C

      It is an example of a place-value calculation

    4. D

      It is an example of a primality-testing problem

    Correct answer
    A

    It is an example of an assignment problem

    Explanation

    Assigning a gate to a plane after it lands is an example of an assignment problem.

  36. 36

    What kind of problem arises when planes waiting to take off must use a runway?

    1. A

      It is an example of a restaurant-indexing problem

    2. B

      It is an example of a scheduling problem

    3. C

      It is an example of an integer-multiplication problem

    4. D

      It is an example of a resident-matching problem

    Correct answer
    B

    It is an example of a scheduling problem

    Explanation

    The runway must be scheduled for planes waiting to take off, making departure order a scheduling problem.

  37. 37

    How does an airline typically allocate aircraft to routes?

    1. A

      They schedule available aircraft among the routes they need to fly

    2. B

      They assign aircraft only after every passenger has landed

    3. C

      They permanently reserve one aircraft for every route

    4. D

      They choose aircraft without considering their available fleet

    Correct answer
    A

    They schedule available aircraft among the routes they need to fly

    Explanation

    Airlines generally schedule the aircraft they have available across the routes they need to fly rather than reserving one particular plane for each route.

  38. 38

    What might an airline do if an aircraft is delayed or develops a technical fault?

    1. A

      A different aircraft may be brought in to serve the route

    2. B

      The same aircraft is assigned to every other route

    3. C

      The route is converted into a shortest-path problem for passengers

    4. D

      The affected route is always canceled without replacement

    Correct answer
    A

    A different aircraft may be brought in to serve the route

    Explanation

    When a plane is delayed or has a technical problem, another aircraft may be brought into service, which illustrates vehicle assignment or routing challenges.

  39. 39

    What transportation task might a package-delivery company use algorithms to handle?

    1. A

      It assigns a permanent delivery truck to every package

    2. B

      It computes a prime number for every package

    3. C

      It finds restaurant reviews near each shipment

    4. D

      It schedules packages on appropriate planes or other transportation

    Correct answer
    D

    It schedules packages on appropriate planes or other transportation

    Explanation

    A shipping company must schedule packages onto suitable planes or other transport to move them between locations.

  40. 40

    Which delivery task matches the traveling salesperson problem described in the content?

    1. A

      Finding a single shortest road between two addresses

    2. B

      Scheduling aircraft to land on limited runways

    3. C

      Visiting multiple delivery addresses and returning to the starting depot

    4. D

      Assigning one package to one aircraft without considering other packages

    Correct answer
    C

    Visiting multiple delivery addresses and returning to the starting depot

    Explanation

    The described delivery truck must visit multiple addresses and then return to its starting depot, matching the traveling salesperson problem setup.

  41. 41

    Why might improving solutions to the traveling salesperson problem matter to a delivery company?

    1. A

      It is difficult because a truck cannot return to its starting depot

    2. B

      It is easy, and solving it has little practical economic effect

    3. C

      It is difficult, and efficient solutions could produce large cost savings

    4. D

      It applies only to airplane takeoffs and cannot affect delivery costs

    Correct answer
    C

    It is difficult, and efficient solutions could produce large cost savings

    Explanation

    The traveling salesperson problem is described as difficult to solve, but improvements in solving it efficiently could save companies substantial money.

  42. 42

    Which type of algorithm is described as supporting the residency matching program?

    1. A

      It uses a stable marriage algorithm to match students with residency positions

    2. B

      It uses the sieve of Eratosthenes to select residency applicants

    3. C

      It uses the Euclidean algorithm to assign hospitals to locations

    4. D

      It uses a shortest-path algorithm to rank medical schools

    Correct answer
    A

    It uses a stable marriage algorithm to match students with residency positions

    Explanation

    The residency match program is described as using a stable marriage algorithm to match medical students with residency positions.

  43. 43

    What allocation problem does the residency match program address?

    1. A

      It finds the shortest route between hospitals and medical schools

    2. B

      It matches residents seeking positions with hospitals seeking trainees

    3. C

      It assigns each medical student to a different delivery route

    4. D

      It calculates how many aircraft each hospital should receive

    Correct answer
    B

    It matches residents seeking positions with hospitals seeking trainees

    Explanation

    The matching program helps connect residents seeking training positions with hospitals seeking trainees, filling positions on both sides.

  44. 44

    Which additional application of matching algorithms is mentioned?

    1. A

      Matching aircraft with mathematical theorems

    2. B

      Matching airport runways with restaurant search terms

    3. C

      Matching kidney donors with kidney patients

    4. D

      Matching delivery trucks with prime numbers

    Correct answer
    C

    Matching kidney donors with kidney patients

    Explanation

    The content also identifies matching kidney donors with kidney patients as an application of algorithms.

  45. 45

    What broad practical benefit do the logistics examples illustrate?

    1. A

      They help schedule and assign resources efficiently and reduce waste

    2. B

      They eliminate the need for people to make every operational decision

    3. C

      They ensure that every problem has only one possible solution

    4. D

      They replace all physical resources with computational procedures

    Correct answer
    A

    They help schedule and assign resources efficiently and reduce waste

    Explanation

    Across the examples, algorithms help schedule scarce resources, make assignments, and reduce wasted time or resources.

Question 1 of 45
Question 1 of 45

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent