Mobile CSP Unit 5

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

bucket vs bubble sort

Most often, unless you are sorting a really small set of items, a bucket sort is more efficient than a bubble sort.

Bucket sort

NON COMPARISON sort, LINEAR _________ is actually an example of a more general non-comparison sort called radix _________________ puts each number into their correct categories, such as all of the 2's together, then 3's and so on and then sort them into the correct order.

Linear search pseudocode

FOR EACH item in List { IF (item = target) DISPLAY "Found target!" }

spider

Google sends out what's affectionately known as a ________' to 'crawl' the web, going from link to link creating a web and cataloging, or 'indexing' what it sees. If you wanted to mimic the actions of the Google ___________, start at a big site, like Wikipedia, and click every link you see. Then go to those pages, and click every link and so on. Once you've clicked a few hundred billion pages, you'll be somewhere close.

radix means

base

For searching an unordered list, which search algorithm is the better choice? Linear search Binary search

Binary search

canvas

Which of the following type of components must be always be used with a Ball?

Binary search (advantages)

______________ is more complex than linear search but it is much faster. However, the list MUST BE IN A SORTED ORDER TO WORK. _________________________ is good since it is the simple process of elimination and the simple process of halving. This is good when you are dealing with average numbers such as 100 or 50 or 20 etc...

Binary search

______________works with a sorted list. You split the numbers by 2. If you have a number between 1-100, you continue to divide by 2 and then guess higher or lowest. In a ______________________________ it would take 7 passes to guess the correct answer.

procedure

a group of code that can be called over and over again and use variables. It is a named block of code that perform a specific task

linear search

a method for finding a target value within a list. It sequentially checks each element of the list for the target value until a match is found or until all the elements have been searched. _______________ is slower but WORKS WITH ANY LIST IN ANY ORDER

decidable problem

a problem for which an algorithm can be written to answer "yes" or "no" for all possible inputs.

undecidable problem

a problem that is impossible to solve

intractable

a problem that is practically impossible to solve. They can be solved but are too inefficient to solve when the number of inputs grows large. There are only inefficient algorithms.

Halting Problem

a theory by Alan Turing that there are undecidable problems that cannot be solved

tractable

can be solved within a reasonable time

Merge sort

comparison sort Merge sort is when you keep dividing up the numbers and then you start '_______' them together step by step. When you are splitting up the numbers you do not have to order them only when you are '_________' them.

Bubble sort

comparison sort ____________________ is a quadratic algorithm, which means that the amount of time it takes to sort a data set grows like a quadratic (x2) curve as the number of items to be sorted grows. ___________ is better when the list is small. You start at the start of the list COMPARING the number adjacent to each other keeping the highest number. Continue to do this until all numbers are sorted.

semantic

error occurs when a programmer inadvertently puts code that is syntactically correct, but does not do what the programmer intended it to do.

syntax

error occurs when a programming language's rules are broken. This type of error can be detected by the compiler which will provide an error message.

efficiency

how well an algorithm uses time and memory/space resources, CPU and RAM how long it takes to arrange the values in order

Binary search pseudocode

low ← 0 high ← N middle ← item (low+high)/2 (compute the middle of the list, rounded down) REPEAT UNTIL (middle = target OR low > high) { IF (middle < target) high ← middle - 1 (This cuts off the top half of the list) IF (middle > target) low ← middle + 1 (This cuts off the bottom half of the list) middle ← item (low+high)/2 (compute new middle) } IF (middle = target) DISPLAY "Found target!" ELSE DISPLAY "Target not in list"

decidable problems

problems in which an algorithm can be constructed to answer 'yes' or 'no' for all inputs (e.g., 'is the number even?').

heuristic

produces a fast and often correct solution to a problem. Used when a problem cannot be solve in a reasonable time and an approximated solution is acceptable.

brute force

solve by trial and error; trying every possible option

Artificial Intelligence

traditionally tackles problems that humans are good at but computers are not (yet) good at

repeat

used to loop

sequential search

used to search an un ordered list by going through each item

Radix sort

you sort them by a significant digit and then sort by another digit and continue until all sorted.

In the bubble sort demo, 13 cards are being sorted. How many passes does this version of the algorithm require to sort the cards?

13 Right. For a deck of 13 cards, this version of bubble sorts makes 13 passes through the deck. On the last pass, there was only 1 card left in the unsorted deck, but we can still consider that a pass. There are different versions of bubble sort, some of which would say that N-1 passes are made through the deck to sort N cards.

general

As a rule of thumb, the more ________________ a procedure (or abstraction) the better.

8

If using a binary sort, how many guesses would it take to guess a number between 1-250?

bug

In computer programming, a _________ is an error or defect that prevents the app from working the way it is supposed to.

Bubble sort (advantages)

It is very simple and easy to do, especially when dealing with short lists. The answer __________s to the top.

For searching an unordered list, which search algorithm is the better choice? Linear search Binary search

Linear search

For which of the problems would the binary search algorithm be useful? Choose all that apply. Arranging a deck of cards from the lowest to the highest value cards. Looking up a phone number in the phone book given the person's full (unique) name. Looking up a word in a dictionary. Looking up a person's name in the phone book given the person's phone number. Finding the smallest number in a list of numbers arranged randomly.

Looking up a phone number in the phone book given the person's full (unique) name. Looking up a word in a dictionary.

For which of the problems COULD the linear search algorithm be used? Choose all that apply. Arranging a deck of cards from the lowest to the highest value cards. Looking up a phone number in the phone book given the person's full (unique) name. Looking up a word in a dictionary. Looking up a person's name in the phone book given the person's phone number. Guessing a secret number between 1 and 100.

Looking up a phone number in the phone book given the person's full (unique) name. Looking up a word in a dictionary. Looking up a person's name in the phone book given the person's phone number. Guessing a secret number between 1 and 100. NOTE THOUGH: True. A linear search can be used to look up someone's phone number in the phone book. However, a sequential search would not be the most efficient search algorithm to use. Since the phone book is arranged in order by last name, you could solve this problem more efficiently using a binary search. True. A linear search can be used to look up a word in the dictionary. However, a linear search would not be the most efficient search algorithm to use. Since a dictionary is in alphabetical order, you could solve this problem more efficiently using a binary search. True. A phone book is arranged in order by last name, not by phone number. Therefore, you would need to start at one end of the phone book and check each phone number individually, in order, until you find the phone number you were given and then you can find the last name associated with the phone number. True. A linear search can be used to guess a secret number between 1 and 100. However, a linear search would not be the most efficient search algorithm to use. Since the numbers 1 to 100 are ordered numerically, you could solve this problem more efficiently using a binary search.

sequential search (disadvantages)

This search is not the best because it is one of the slowest searches because it goes through every item such as looking for a phone number is a phone book if you don't know the person's name

17

Suppose you are sorting the following list of numbers in ascending order using bubble sort: [16, 5, -1, 4, 12, 17, 3, 10, 5, 9]. After the first pass through the numbers, what value would appear on the right of the list?

zucchini

Suppose you are sorting the following list of words into alphabetical order using bubble sort: [apple, orange, banana, , zucchini, papaya, lemon, pumpkin, squash, tomato]. After the first pass through the list, what word would appear on the right of the list?

Which picture is prettier

This is an example of an undecidable problem

If/Then

Use this type of block to check is something is true or false


Set pelajaran terkait

Anatomy 2146: Respiratory System

View Set

Human Relations Chapter 10 motivation

View Set

EMT Trauma Practice Questions Part 1

View Set

Anatomy & Physiology 2 Exam 3 Review

View Set

History Of Ancient Greece- Final

View Set

PF Ch. 2 Mult. Choice Semester 1

View Set