Back to 课程

Computer Science GCES EDEXCEL

0% Complete
0/0 Steps
  1. Decomposition And Abstraction Edexcel
    2 主题
  2. Algorithms Edexcel
    11 主题
  3. Truth Tables Edexcel
    3 主题
  4. Binary Edexcel
    6 主题
  5. Data Representation Edexcel
    4 主题
  6. Data Storage And Compression Edexcel
    2 主题
  7. Hardware Edexcel
    5 主题
  8. Software Edexcel
    3 主题
  9. Programming Languages Edexcel
    2 主题
  10. Networks Edexcel
    7 主题
  11. Network Security Edexcel
    2 主题
  12. Environmental Issues Edexcel
    1 主题
  13. Ethical And Legal Issues Edexcel
    3 主题
  14. Cybersecurity Edexcel
    2 主题
  15. Develop Code Edexcel
    6 主题
  16. Constructs Edexcel
    4 主题
  17. Data Types And Data Structures Edexcel
    5 主题
  18. Operators Edexcel
    1 主题
  19. Subprograms Edexcel
    2 主题
课 Progress
0% Complete

Exam code:1CP2

Algorithm Efficiency

What is algorithm efficiency?

  • Algorithm efficiency is how much time and memory it takes to complete an algorithm

  • In programming, there is often more than one algorithm which can solve a problem

  • An example of this is a linear search and binary search as both find a value in a list, however, depending on the circumstances, one may be much faster than the other

  • For the example comparison, we will use the following dataset

11 

16 

27 

  • The best case for a linear search is that the item being looked for is the first item in the list

  • The worst case is that the item is the last element in the data set or that it is not present at all

  • As a result of a linear search checking each item from the first item and incrementing to the next item, a list of 1000 items would require 1000 searches if the data item was the last in the list

  • The negative of a linear search is that it has to pass through the entire data set to search each item until the item is found

  • The best case for a binary search is that the item being looked at is found after one comparison

  • The worst case is that the item is the last comparison, and in the list above of 7 items would be after 3 searches

  • As a result of a binary search being performed through divide and conquer, the main positive is that even if the data item was the last to be looked at the last position in a list of 1000 items, it would require 10 searches because it does not need to check each data item

  • In this instance, a binary search is significantly more effective and efficient at finding the target data

  • Remember that the precondition for a binary search is that the data must be sorted before performing the search, the data set above would have to appear like below

2

3

7

11

16

27

What is the best case and worst case for a bubble sort?

  • The best case for a bubble sort is that the data is already in order or almost in order

  • The worst case for a bubble sort is that the data is in the opposite order to its sorted version

    • For example, a user wants the data sorted in ascending order but the data is in descending order before the sort begins

What is the best case and worst case for a merge sort?

  • The best case for a merge sort is that the data is already in order or almost in order

  • The worst case for a merge sort gets a little more complicated due to the way the algorithm works

  • The merge sort is an out-of-place algorithm, meaning that extra memory is required to move the data round

  • The amount of memory necessary depends on the size of the data

  • The reason for this is because it splits the data before merging it back in a sorted manner

  • Beyond this explanation the content strays outside of the GCSE exam and towards A Level content around Big O notation

Responses

您的邮箱地址不会被公开。 必填项已用 * 标注