Unit 6

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Dijkstra's algorithm is an algorithm to determine the shortest distance between two nodes. Dijkstra's algorithm can be used with an infinite number of configurations of nodes and will always find the shortest path. Finding the shortest distance between two nodes is which type of problem? A Undecidable. B Decidable. C Unsolvable. D Solvable.

B

In order to determine whether code can run in a reasonable amount of time, it is important to get a feel for the runtimes of different code segments. Let's assume that runtime is measured as the number of passes through a loop. In the following choices, this is represented by the variable count. Assume that every element in the list named licenses is a unique license number, and that searchNum is a valid license number that exists in licenses. Which of the following segments of code would generally have the shortest runtime according to this definition of runtime? A count <-- 0 FOR EACH licenseNum IN licenses { count <-- count + 1 } B count <-- 0 i <-- 0 REPEAT UNTIL ( licenses[i] = searchNum ) { count <-- count + 1 i <-- i + 1 } C count <-- 0 FOR EACH licenseNum IN licenses { IF ( licenseNum = searchNum ) { DISPLAY (licenseNum) } count <-- count + 1 } D Variable n in the following code represents the number of elements in licenses. count <-- 0 REPEAT n TIMES { count <-- count + 1 }

B

Which of the following statements are true about an undecidable problem? I. There is no algorithm that would solve all cases of an undecidable problem.II. An undecidable problem may have cases where an algorithm could solve the problem.III. All cases of an undecidable problem can be solved with an algorithm but it would take a very long time to solve them.

1 and 3

Consider the following lists. I. list1 ← [2, 4, 5, 7, 11, 33]II. list2 ← [-2, -1, 0, 1, 2, 3, 4, 5, ...., 900, 901, 902]III. list3 ←[18, 20, 22, 24, 26, 28, 30, 2, 4, 6, 8, 10, 12, 14, 16] For which of the following lists would a binary search be significantly more efficient than a linear search? A II only. B III only. C II and III only. D I, II, and III.

A

Consider the following short program: 1. pi ← 3.14159 2. r ← INPUT() 3. a ← pi * r * r 4. DISPLAY (a) In the short program above, which is best thought of as a constant? A pi B r C a D pi * r * r

A

Suppose you are told that num is a positive integer, and you are asked the following question:Is num a factor of 10? In other words, when num is divided by 10, is there a non-zero remainder? Which of the following statements is most accurate when describing this problem? A The problem is a decidable problem, since an algorithm can be created to answer the question with either "yes" or "no" for any possible positive integer value of num. B The problem is a decidable problem, since an algorithm can be created to answer the question with either "yes" or "no" for most positive integer values of num. C The problem is an undecidable problem, since there are an infinite number of possible values for num and no algorithm can be created to answer the question for all possible positive integer values of num. D The problem is an undecidable problem, since no algorithm can be created to answer the question with either "yes" or "no" for all possible positive integer values of num.

A

Brandon is writing a program that allows users to keep a database of recipes. Each recipe includes a name, a list of ingredients, and instructions. He is currently writing the search procedure that will allow users to find recipes in the database by looking up ingredients. Brandon realizes that if there are too many recipes in the database, searching for one will be very difficult. Which of the following describes a heuristic approach to solving this issue? Select BOTH correct answers. A The procedure could start by checking the recipes that have been searched for recently. B The procedure could check the recipes in alphabetical order. C The procedure could start by checking the recipes that have been entered into the database most recently. D The procedure could start by checking the recipes that the user normally searches for at that time of day.

A and D

The "Traveling Salesperson Problem" poses this question: A salesperson is given a list of cities and the distances between them. The salesperson has to visit each city exactly once and then return to the first city. What is the shortest possible route the salesperson could take? Assume an actual salesperson is trying to determine the shortest route she can take to visit 18 cities. She could use a computer program to calculate the distance of every possible route and then select the shortest one. Alternatively, she could use a heuristic to find a route. Which of the following reasons would justify the use of a heuristic? A She has to pay for her own gas. B She has to leave in an hour. C She could potentially get a raise for being more efficient on her sales route than her coworkers. D She doesn't want to put too many miles on her car.

B

The "Traveling Salesperson Problem" poses this question: A salesperson is given a list of cities and the distances between them. The salesperson has to visit each city exactly once and then return to the first city. What is the shortest possible route the salesperson could take? To find the exact answer, a computer program would have to create every possible route, calculate the lengths of all of them, and then find the shortest route. This clearly isn't efficient when there are many cities the salesperson must visit. Alternatively, a computer program could use this algorithm: Select a city to start. Select the closest unvisited city. Repeat step 2 until all cities have been visited. Return to first city. This algorithm won't always return the shortest route, but the route it returns can be considered "short enough." What is this algorithm an example of? A An abstraction. B A heuristic. C An unsolvable problem. D An unreasonable problem.

B

Algorithms can have runtimes that are either reasonable or unreasonable. Let's assume that n represents the number of input items that have to be considered and f(n)f(n) represents the number of things that the computer must do to solve the problem for n number of inputs. Which of the following represents an unreasonable run time? Select TWO answers. A f(n)=2∗nf(n)=2∗n B f(n)=3nf(n)=3n C f(n)=n!f(n)=n! D f(n)=n2f(n)=n2

B and C

Which of the following are true statements about run time? Select TWO answers. A There is always a way to solve a problem in a reasonable amount of time. B Reasonable run time is determined by counting the number of steps an algorithm takes to solve a problem. C Two algorithms can solve the same problem using very different run times. D Reasonable run time can be defined by individuals writing or using a program, and thus might vary from person to person.

B and C

By using a password that contains a mixture of 8 letters and numbers, a hacker could crack your password in a little over 16 minutes. However, by adding two more letters or numbers, it increases the time to about 15 days! By adding an "@" symbol to your password, the time is increased to almost 1628 years! Which of the following is TRUE regarding passwords and the length of time it takes to crack them? A As you increase the number of characters in your password the ability to crack the password is solvable. B As you increase the number of characters in your password the ability to crack the password is unsolvable. C As you increase the number of characters in your password the ability to crack the password becomes more unreasonable to solve. D As you increase the number of characters in your password the ability to crack the password becomes more reasonable to solve.

C

Consider the following algorithms. Assume that you have a deck of cards with numbers on them, and you are looking for a card with a particular number: Algorithm 1: look at the middle card in your deck. if correct, done! You have found what you are searching for! if you are looking for a larger number, discard the lower half of the deck else, discard the upper half of the deck return to step 1 Algorithm 2: look at the first card in your deck. if this is what you are looking for, great! You have found what you are searching for! discard the first card in your deck return to step 1 Which of the following statements is TRUE? A Both algorithms will find the value you are looking for in any list. B Neither algorithm will find the value that you are looking for in any list. C Algorithm 1 requires the list be already sorted in ascending order. Algorithm 2 will always work. D Algorithm 2 requires the list be already sorted in ascending order. Algorithm 1 will always work.

C

Rowan is playing an app on his phone based on the game 20 questions20 questions. The app asks the user to think of something and then asks 2020 yes/no questions to determine the thing. Rowan has played 1010 times in a row where the phone was able to 'guess' the item. Which of the following is the best answer to, should the app be thought of as decidable? A Yes, it got the solution 1010 times in a row. B Yes, twenty yes/no questions allow for a very large data set of solutions. C No, a decidable problem must cover all solutions and 1010 trials is not enough. D No, a decidable problem can only accept one input and cannot be applied to twenty inputs.

C

Which of the following BEST describes what the purpose of a heuristic in programming? A To provide an answer to a problem that can be solved in a reasonable time and an approximate solution is acceptable. B To provide an answer to a problem that can be solved in a reasonable time and an exact solution is needed. C To provide an answer to a problem that cannot be solved in a reasonable time and an approximate solution is acceptable. D To provide an answer to a problem that cannot be solved in a reasonable time and an exact solution is needed.

C

Which of the following is NOT an example of a heuristic? A Meredith estimates that each floor tile is 10 inches by 10 inches. She counts floor tiles to determine the size of a room. B Avaya begins reading a positive, well written review for a product online. Based on the quality of the writing, she assumes that the product must be good without reading the rest of the review. C Martha is instructed to inventory all of the items in three aisles of a grocery store. She counts everything item by item and writes down the totals. D Sarah, a college junior, goes to the campus center to give a tour to a high school student. She sees a crowd of people and assumes that the person wearing the high school letter jacket is the prospective student.

C

A constant is a special type of variable sometimes used to represent a piece of information in a computer program. Which of the following choices is the best situation for using a constant in a program? A To represent a player's current score in a computer game. B To represent the number of times a loop has executed. C To represent the name of the leader in a bowling app. D To represent the maximum number of lives a player can have in a game.

D

A programmer is working on a problem that requires an algorithm to solve. She writes an algorithm that works for one example, but doesn't work for another example. What type of problem is this? A Unpredictable. B Unsolvable. C Unreasonable. D Undecidable.

D

Consider the following algorithms. Assume that you have a deck of cards with numbers on them and you are looking for a card with a particular number: Algorithm 1: look at the middle card in your deck. if correct, done! You have found what you are searching for! if you are looking for a larger number, discard the lower half of the deck else, discard the upper half of the deck return to step 1 Algorithm 2: look at the first card in your deck. if this is what you are looking for, great! You found what are searching for! else, discard the first value in your deck return to step 1 Which of the following statements is TRUE? A Algorithm 1 is an example of linear search. It will work for any list.Algorithm 2 is an example of binary search. For it to work, the list must already be sorted. B Algorithm 1 is an example of linear search. For it to work, the list must already be sorted.Algorithm 2 is an example of binary search. It will work for any list. C Algorithm 1 is an example of binary search. It will work for any list.Algorithm 2 is an example of linear search. For it to work, the list must already be sorted. D Algorithm 1 is an example of binary search. For it to work, the list must already be sorted.Algorithm 2 is an example of linear search. It will work for any list.

D

Consider the following code which uses variables x, y, and z. x ← 3 y ← 7 z ← 21 x ← y y ← z DISPLAY (x) DISPLAY (y) Which of the following will be displayed after the code is run? A 3 7 B 3 3 C 21 21 D 7 21

D

The Entscheidungsproblem was a problem posed by David Hibert. The Entscheidungsproblem looks for an algorithm that will determine if any mathematical statement is provable from known axioms. The problem looks for a simple "yes" or "no" answer, however, just eight years after the problem was posed it was proved that there is no one algorithm that can be constructed that always lead to a correct "yes" or "no" answer. What do we call these types of problems? A Unpredictable. B Unsolvable. C Unreasonable. D Undecidable.

D


Kaugnay na mga set ng pag-aaral

Scientific Revolution Vocabulary

View Set

Ch 14: Nervous System: Spinal Cord and Spinal Nerves

View Set

The 7 Ideas that Shook the Universe Final Exam Part 2 of 3

View Set

CHEMISTRY- exam (old test questions)

View Set

Chap 1 problem set August 2016 Xu Microecon GCSU

View Set

Real Estate Exam Prep Chapter 3: Property valuation and financial analysis

View Set