Algorithms are Instructions

Ace your homework & exams now with Quizwiz!

Two Dice: You want to simulate rolling two six sided dice. You are interesting in how often you see a sum of 7 on the two dice. Which of the following would simulate counting the number of times one would see a sum of 7 on two dice rolls when rolling the dice 25 times.

A D

factorial in flowcharts: A factorial is a mathematical function that returns the product of the given counting number and all the counting numbers leading up to it. Counting numbers are integers greater than zero. A factorial is often indicated with a ! In math class you may have defined 0! = 1 however, we are not worried about that situation in this problem. Which of the following properly defines a factorial function for a counting number n?

A D

WarTor: Alex has written code implementing a prey-predator relationship. He has coded a class for the sharks (predator), the fish (prey), and a graphical view to show these creatures on a grid moving about in an ocean of blue. Though the code appears to work correctly, Alex finds that the implementation is terrible slow. If he has more than 25 or so creatures in his ocean, the computer slows to a crawl and it takes hours to run his simulation. He would like to have the simulation running with thousands of creatures in the ocean. What would you recommend to Alex to improve the implementation of his simulation?

A: Consider implementing his code in a different language - some languages are better suited to running simulations with a large number of objects than others. C: Consider his graphical implementation - perhaps there is a way to speed up the simulation

Why do we learn sorting routines? When learning to program, computer scientists often learn a number of different algorithms for sorting a list. Some of these algorithms are known by names such as insertion, selection, bubble, shell, and merge. You may have learned some of these in your own computer science courses. Yet most modern computer languages have a command built in that looks something like: Given that many modern languages have built in sort routines, why do we still make students learn a variety of different sorting algorithms

A: One can build upon a variety of known algorithms to build new algorithms D:starting with known, correct algorithms can help ensure that new algorithms based upon the known algorithms are correct

PEMDAS Aaban and Manha are trying to simplify the following mathematical expression: 11-6/2x3/1 They are debating if they should start with the subtraction, division, multiplication, or addition operation. The discussion they are having is about which of the following issues?

A: sequencing

Selecting a language: The Following quotes are from wikipedia regarding different computer languages. Which would you introduce to a 6th grade who wants an introduction to computer programming?

B: Alice C: Scratch

making a list, checking it twice: Wyatt was tasked with writing a program to manage a list. His boss required that the program display the current list and add items to the list at a later time. Which of the following are necessary components in his code?

B: II & IV only

Boolean expression: Consider the following code: Which line of the code above includes a Boolean expression?

B: Line 2

Understanding algorithms: Which of the following are better to help people understand algorithms?

B: Pseudocode C: natural language

Tracking Big Numbers: Consider the code below: Line 5 is best described as

B: selection

factorial in simple language: A factorial is a mathematical function that returns the product of the given counting number and all the counting numbers leading up to it. Counting numbers are integers greater than zero. A factorial is often indicated with a ! In math class you may have defined 0! = 1 however, we are not worried about that situation in this problem.

C D

Sorting Namecards Assume you have note cards with 20 student names on them. You want to sort them, and your friends suggest two different methods of sorting the cards. Alice suggests the following: 1. put all cards on the table 2. find the one what is first in alphabetical order, and place it in a pile 3. find the next one in alphabetical order, and place it in the pile. Repeat until done. Elizabeth suggests; 1. put one card on the table 2. look at the next card. Place it in front of or behind the first card 3. look at the next card. Place it in the correct location relative to the cards currently on the table. Repeat until done Which of the following best describes the situation outline above?

C: Either Elizabeth's or Alice's algorithm could be used to sort the names.

Implementing Algorithms: Which of the following could be used if you want a computer to implement an algorithm that you have created?

C: Visual programming language D: textual programming language

Big Numbers One: Consider the code below... Line 3 is best described as

C: iteration

Recycling Conundrum: A student notices that students and teaches at her school are throwing recyclable items into trash cans instead of the blue recycling containers. She decides to create a mobile application to help her school determine whether or not an item is recyclable. The app would allow a user to photograph an item and it would then indicate whether or not the item is recyclable, based upon an algorithm developed with the help of her community's local recycling center. Her school environmental club advisor thinks it would be great to offer the app to other schools if the app works as intended. As she creates her program, she finds that recycling programs might have different procedures in different communities. In addition, she sees patterns in images that help her determine if the item can be recycled.

C:Developing a new algorithm to solve a problem can yield insight into the problem.

Practice with Abstraction using algorithms: Using the algorithm below, the decimal number 13 has been converted to its binary equivalent. The first two iterations of this algorithm are as follows: 13/2=6, remainder 1 6/2 = 3 remainder 0 Which of the following is the correct binary number?

D: 1101

All about computer modeling: Which best describes how we use abstraction in computer modeling?

D: a process that decides which aspects of the real world are most important to the model's current purpose.

Iteration: Which of the following blocks of code are examples of iteration?

B C


Related study sets

Patho Test 5 NCLEX's Q's Renal Drugs 2 of 2

View Set

Parli Pro Oral Question - Previous Question

View Set

PRACTICE EXAM OF TEXAS LIFE & HEALTH INSURANCE. "SECTION 1- TEXAS COMMON LAW"

View Set

Chapter 16: Cardiovascular Emergencies

View Set