Computer Science Chapter 5
For which of the problems would the binary search algorithm be useful
- Looking up a phone number in the phone book given the persons full name - looking up a word in the Webster's dictionary
for which of the problems could the linear search algorithm be used?
- Looking up a phone number in the phone book given the persons full name - looking up a word in the Webster's dictionary - looking up a persons name in the phone book given the persons number - guessing a secret between 1 and 100
Which of the following characteristics is true of bubble sort? Choose all that apply.
- a comparison based algorithm - an N^2 algorithm
For which of the problems would the bubble sort algorithm provide an appropriate solution
- arranging a deck of cards from the lowest to the highest value cards - sorting stacks of paper money in denomination, 1, 5, 10 - arranging books on a bookshelf by authors last name
Which of the following characteristics is true of bucket sort? Choose all that apply.
- more efficient than bubble sot - a liner algorithm
Consider an algorithm to solve a problem that takes 160 seconds to run on 1 processor. This algorithm can be divided among two processors to solve the same problem in 100 seconds. What is the speedup for this parallel algorithm
1.6
A sorted list of numbers contains 500 elements. Which of the following is closest to the maximum number of list elements that will be examined when performing a binary search for a value in the list?
10
According to the following table, how many lookups would be required in the worst case to find a number in list of 10000 elements using linear search? Type your answer in the text box.
10000 it would have to search through each element in the list
According to the following table, how many lookups would be required in the worst case to find a number in a sorted list of 10000 elements using binary search? Type your answer in the text box.
14 a sorted list of 10000 elements could be divided in half at most 14 times
you are sorting the following lost of numbers in ascending order using bubble sport [16, 5, -1, 4, 12, 17, 3, 10, 5, 9] after the first pass through the umbers what value would appear on the right of the list
17 would bubble up to the right of the list during the first pass
What is the formula for determining how many degrees are in a polygon?
180(n-2) N= the number of sides
If you were using binary search to find the number 14 in the following list [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], how many iterations would be required to find 14 in the list?
3
what is a captcha
A check for human or bot search, using a picture or checkbox.
Explain pseudocode.
A shortened version of code, doesn't work on its own, way to look at or understand a smaller chunk of code. (Can be programming language, but not necessary)
for searching a sorted list, which search algorithm is the better choice
Binary
Explain the difference between Bubble, Merge, and Bucket Sort
Bubble: example of a comparison sort. It repeatedly compares two cards, placing the smaller one on the left pile. this makes several passes through the cards? Merge: merge sort starts with the cards in piles of 1 card each. Then on each pass, it merges them into piles of 2 cards, then 4 cards, then 8 cards, and so on, until all the cards are merged into one sorted pile. You probably also noticed that it was quite a bit faster than bubble sort. Bucket: does not compare one card with another. Rather, it uses the card's value to place it into the appropriate bucket. Once all the cards are in their buckets, they are collected together in order. This sort is the fastest of the three examples we've considered.
How do you think mobile computing might have influenced web searches
Difference in what you search on your computer vs phone
What does the following code do? list ← 1, 0, 4, 2x ← -1FOR EACH item IN listIF item > x x ← itemDISPLAY x
Displays 4 which is the maximum (largest) value in the list. Check Answer
True or False: An algorithm can be found for any computational problem whatsoever.
False
True or false: All intractable problems (that cannot be solved in a reasonable time) are bad.
False
Which code below could be placed in the following loop to print out the item in a list that has the lowest (minimum) value? list ← [1, 0, 4, 2] x ← 99 FOR EACH item IN list { <MISSING CODE> } DISPLAY(x)
IF (item < x) x ← item
Is the following problem tractable (solvable in a reasonable amount of time) or intractable (cannot be solved in a reasonable amount of time)? For any length string of letters using any combination of the letters 'a' through 'z', write down all possible strings.
Intractable
What is the different between index of a list and the length of a list?
List A: Bears Beets Boots Bears: index 1 Length of the list: 3
What are some similarities and differences between procedure and a procedure with parameters?
Similarities: both purple blocks / both student developed code and commands. Differences: a procedure runs through the same code each time you use it, depending on where it is called in the code. A procedure with parameters is when you send specific variables to be used within the procedure; can be sending different variables from different parts of code.
Find the bug. When Button1 is clicked, Label1 is supposed to be set to a name that is selectedfrom the names list by the displayName procedure. But the label's Text never changes. Why?
The displayName procedure is not being called when the button is clicked.
What is binary search, and when would you use it?
This cuts searching in half, if the list of items are linear/sorted. - Guess a number: higher or lowers Trying to find a work in the dictionary - Trying to find the median in a pack of grade tests
define undecidable and intractable problems, what is the difference. Give examples
Undecidable: no good way to solve, hard to use and algorithm (how to choose a husband) Intractable: can use an algorithm but would be hard to implement (deciding student schedules)
How does Googles search engine work
Used factors to find what it thinks is the most relevant results (GPS location, your history, and interpretation of age, gender, ethnicity
What is the process of troubleshooting errors in code? where do you start?
You start with output, work your way backwards - check variables - check label updates - check get/set
When do you use parameters and what are they used for?
You use parameters for when you want to run the same calculation but with different inputs / they are used as input either numbers or string to generate an output.
What are the values in the list after executing the following code: list ← [ 0, 3, 5 ] APPEND( list, 4 ) INSERT( list, 2, 1 ) REMOVE( list, 1 )
[1, 3, 5, 4]
The Halting Problemis an example of
an undecidable problem.
Suppose you are sorting the following list of words in alphabetical order using bubble sort: [apple, banana, lemon, tomato, orange, squash, papaya, pumpkin]. Which of the following gives the correct order of the list after two passes through the list?
apple, banana, lemon, orange, papaya, pumpkin, squash, tomato]
To say that bucket sort is more efficient than bubble sort means that ______________
as the size of the list grows, bucket sort will be faster than bubble sort.
What is a linear search, and when you use it?
going through each item in a list one by one. The items in the list are unsorted. - Collecting a stack of papers and trying to find one in particular - one specific card in a deck of cards.
In talking about sorting algorithms in general, a sort algorithm's efficiency refers to ______________________
how long it takes to arrange the values in order.
For searching an unordered list, which search algorithm is the better choice
linear
When would you need to use a heuristic solution, give example
making a decision with many inputs, many possible outputs, and the solution may never sleep like the best possible options, such as mapping out a garage sale stop map.
Should a researcher place absolute trust in a search engine, explain
no: they can be skewed or bias on your previous searched. Many results will fit your narrative but may not provide accurate representation of the other side.
Why might it be important to talk about the social implications of searching on the internet?
people may not realize their info is being skewed.
Suppose you are sorting the following list of words into alphabetical order using bubble sort: [apple, orange, banana, papaya, lemon, pumpkin, squash, tomato]. After the first pass through the list, what word would appear on the right of the list?
tomato