Loading [MathJax]/jax/output/HTML-CSS/fonts/TeX/fontdata.js

Computing revision - Linear and Binary searches

Description

Flashcards
Dean Owen
Flashcards by Dean Owen, updated more than 1 year ago
Dean Owen
Created by Dean Owen over 2 years ago
7
0
1 2 3 4 5 (0)

Resource summary

Question Answer
How does a linear search check for a selected item? A linear search checks each item of the list in order to see if it is the item it's looking for.
What is an advantage of using a linear search? It is much simpler than a binary search.
What are the disadvantages of a linear search? - Due to its inefficiency, the linear search is usually only used on small lists. - If it is a large list of items, the item you are looking for can take a long period of time to be found.
If I had Chocolate, Butterscotch, Vanilla and Strawberry, and I wanted to find Strawberry using a linear search, what would the program look like? It would look like: Chocolate ≠ Strawberry Butterscotch ≠ Strawberry Vanilla ≠ Strawberry Strawberry = Strawberry ITEM FOUND
What does a Binary Search look for items in? They look for items in ordered lists.
What is an advantage of a binary search? A binary search is much more efficient than a linear search; it takes fewer steps to search for an item.
If I had 9 items in a list, what would the first step be? The first step would be to find the middle term.
How do you do the first step? To find the middle item in the list of 9 items, you would: - Do 9 + 1 (= 10) - Divide that number (10) by 2 (10/2) = 5 - The answer to the sum above (5) will be the middle term (this means that the 5th term is the middle term in this case).
What's the second step? If it's the item that is being looked for, stop the search because you've found it. If not, carry on to step 3.
What's the third step? If the item is not the middle term, compare it to the middle term; if it is above the middle term, remove the first half of the list, but if it's below the middle term, remove the second half of the list.
What's the fourth step? The list will be half the size of the original list, so you can repeat steps 1 and 3 until you find the item that is being searched for.
What is a disadvantage of binary searches? They are more complex than linear searches.
Show full summary Hide full summary

0 comments

There are no comments, be the first and leave one below:

Similar

Describe - Practice questions and answers for AS Physics A
nikeishabk
Yr 12 Biology Mid-Year Exam Notes Part 1
gbridgland
TOEFL Practice
aliking
Of Mice and Men - Themes
Hafsa A
HRCI Glossary of Terms O-Z
Sandra Reed
The structure of the Heart, AS Biology
mill-bill
Grade 10 Coordinated Science Quiz
Imani :D
Literary Devices
vanillalove
DNA Basics
Sarah Juliette B
PSBD New Edition
Aafnai Sathi