Difference between revisions of "2022 Paper 1 Revision Quiz"
(→Sorting Algorithms) |
(→Abstract Data Types & Dynamic vs Static) |
||
(50 intermediate revisions by the same user not shown) | |||
Line 100: | Line 100: | ||
=Arrays= | =Arrays= | ||
<quiz display=simple> | <quiz display=simple> | ||
− | { | + | |
+ | {When considering arrays, which of the following are correct | ||
+ | |type="[]"} | ||
+ | +You must declare a size when creating the array | ||
+ | ||Correct | ||
+ | -You don't need to specify a size when creating an array | ||
+ | ||Incorrect | ||
+ | +The memory for the entire structure is allocated when it is created | ||
+ | ||Correct | ||
+ | -Only the initial memory is allocated when creating, the rest is allocated when we add items | ||
+ | ||Incorrect | ||
+ | |||
+ | {When using arrays the square brackets [] : | ||
|type="()"} | |type="()"} | ||
− | + | + | -Are used to access the whole array |
+ | ||Incorrect | ||
+ | -Contain the data value to look up in the array | ||
+ | ||Incorrect | ||
+ | +Are used to access a specific element in the array | ||
||Correct | ||Correct | ||
− | - | + | -Contain the data value store in the array |
||Incorrect | ||Incorrect | ||
− | - | + | |
+ | {An array can be of any data type or class. | ||
+ | |type="()"} | ||
+ | +True | ||
+ | ||Correct | ||
+ | -False | ||
||Incorrect | ||Incorrect | ||
− | - | + | |
+ | {A 2D array can still only be of one data type or class. | ||
+ | |type="()"} | ||
+ | +True | ||
+ | ||Correct | ||
+ | -False | ||
+ | ||Incorrect | ||
+ | |||
+ | {An Array is a: | ||
+ | |type="()"} | ||
+ | -Abstract Data Structure | ||
+ | ||Incorrect | ||
+ | -Dynamic Data Structure | ||
+ | ||Incorrect | ||
+ | +Static Data Structure | ||
+ | ||Correct | ||
+ | -Strong Data Structure | ||
||Incorrect | ||Incorrect | ||
</quiz> | </quiz> | ||
Line 114: | Line 151: | ||
=Abstract Data Types & Dynamic vs Static= | =Abstract Data Types & Dynamic vs Static= | ||
<quiz display=simple> | <quiz display=simple> | ||
− | { | + | |
+ | {A Abstract Data type is: | ||
+ | |type="[]"} | ||
+ | -Defined by how it is implemented | ||
+ | ||Incorrect | ||
+ | +Not defined by how it is implemented | ||
+ | ||Correct | ||
+ | +Can be implemented in many ways | ||
+ | ||Correct | ||
+ | -Can only be implement in one way | ||
+ | ||Incorrect | ||
+ | |||
+ | {When considering dynamic structures, which of the following are correct | ||
+ | |type="[]"} | ||
+ | -You must declare a size when creating the structure | ||
+ | ||incorrect | ||
+ | -You don't need to specify a size when creating the structure | ||
+ | ||Correct | ||
+ | -The memory for the entire structure is allocated when it is created | ||
+ | ||Incorrect | ||
+ | +Only the initial memory is allocated when creating, the rest is allocated when we add items | ||
+ | ||Correct | ||
+ | |||
+ | {The benefits of static structures are: | ||
+ | |type="[]"} | ||
+ | -Makes the most efficient use of memory because it only allocates what is needed | ||
+ | ||Incorrect | ||
+ | +Memory allocation is fixed so adding and removing data items should be straight forward | ||
+ | ||Correct | ||
+ | +The size of the structure is known so you don't need to calculate the size of the structure | ||
+ | ||Correct | ||
+ | -Are very flexible and items can be added and removed without worrying about where they are in the structure | ||
+ | ||Incorrect | ||
+ | |||
+ | {The drawbacks of a static structure are: | ||
|type="()"} | |type="()"} | ||
− | + | + | -It is possible for the structure to overflow or underflow |
+ | ||Incorrect | ||
+ | +Can be very inefficient with memory because memory is allocated whether it is needed or not | ||
||Correct | ||Correct | ||
− | - | + | -The memory allocated will be fragmented so will take longer to read |
||Incorrect | ||Incorrect | ||
− | - | + | - You might need to code basic function to get the size or number of items stored |
||Incorrect | ||Incorrect | ||
− | - | + | |
+ | {The benefits of dynamic structures are: | ||
+ | |type="[]"} | ||
+ | +Makes the most efficient use of memory because it only allocates what is needed | ||
+ | ||Correct | ||
+ | -Memory allocation is fixed so adding and removing data items should be straight forward | ||
||Incorrect | ||Incorrect | ||
+ | -The size of the structure is known so you don't need to calculate the size of the structure | ||
+ | ||Incorrect | ||
+ | +Are very flexible and items can be added and removed without worrying about where they are in the structure | ||
+ | ||Correct | ||
+ | |||
+ | {The drawbacks of a dynamic structure are: | ||
+ | |type="[]"} | ||
+ | +It is possible for the structure to overflow or underflow | ||
+ | ||Correct | ||
+ | -Can be very inefficient with memory because memory is allocated whether it is needed or not | ||
+ | ||Incorrect | ||
+ | +The memory allocated will be fragmented so will take longer to read | ||
+ | ||Correct | ||
+ | + You might need to code basic function to get the size or number of items stored | ||
+ | ||Correct | ||
+ | |||
</quiz> | </quiz> | ||
+ | |||
=Queues= | =Queues= | ||
<quiz display=simple> | <quiz display=simple> | ||
− | { | + | {A queue is ? |
|type="()"} | |type="()"} | ||
− | + | + | - Last In First Out . |
+ | ||Incorrect | ||
+ | + First in First Out. | ||
||Correct | ||Correct | ||
− | - | + | |
+ | {Complete the following; | ||
+ | |type="{}"} | ||
+ | A new item must be added to the { back|rear|tail } of the queue. | ||
+ | You must remove the item at the { front|head } of the queue. | ||
+ | |||
+ | {In a Linear queue, the front of the queue will move further back as items are taken from the front of the queue. | ||
+ | |type="()"} | ||
+ | +True | ||
+ | ||Correct | ||
+ | -False | ||
||Incorrect | ||Incorrect | ||
− | - | + | |
+ | {In a Linear queue, when an item is removed from the front of the queue the remaining items are moved forward. | ||
+ | |type="()"} | ||
+ | -True | ||
||Incorrect | ||Incorrect | ||
− | - | + | +False |
+ | ||Correct | ||
+ | |||
+ | {A circular queue works by using pointers. The front pointer will point to: | ||
+ | |type="()"} | ||
+ | -The back of the queue | ||
||Incorrect | ||Incorrect | ||
+ | -The location for the next item onto the queue | ||
+ | ||Incorrect | ||
+ | +The first item in the queue | ||
+ | ||Correct | ||
+ | -The second item in the queue | ||
+ | ||Incorrect | ||
+ | |||
+ | {A circular queue works by using pointers. The rear pointer will point to: | ||
+ | |type="()"} | ||
+ | +The back of the queue | ||
+ | ||Correct | ||
+ | -The location for the next item onto the queue | ||
+ | ||Incorrect | ||
+ | -The first item in the queue | ||
+ | ||Incorrect | ||
+ | -The second item in the queue | ||
+ | ||Incorrect | ||
+ | |||
+ | {To make a circular queue you must reset either pointer back to 1 when: | ||
+ | |type="()"} | ||
+ | -Number of Items = Max Queue Size | ||
+ | ||Incorrect | ||
+ | -Number of Items = 0 | ||
+ | ||Incorrect | ||
+ | +When the Pointer Value = Max Queue Size | ||
+ | ||Correct | ||
+ | |||
+ | {in a circular queue you must test for empty by: | ||
+ | |type="()"} | ||
+ | -Number of Items = Max Queue Size | ||
+ | ||Incorrect | ||
+ | +Number of Items = 0 | ||
+ | ||Correct | ||
+ | -When the Pointer Value = Max Queue Size | ||
+ | ||Incorrect | ||
+ | |||
+ | {in a circular queue you must test for full by: | ||
+ | |type="()"} | ||
+ | +Number of Items = Max Queue Size | ||
+ | ||Correct | ||
+ | -Number of Items = 0 | ||
+ | ||Incorrect | ||
+ | -When the Pointer Value = Max Queue Size | ||
+ | ||Incorrect | ||
+ | |||
</quiz> | </quiz> | ||
=Stacks= | =Stacks= | ||
<quiz display=simple> | <quiz display=simple> | ||
− | { | + | {A stack is ? |
|type="()"} | |type="()"} | ||
− | + | + | + Last In First Out . |
||Correct | ||Correct | ||
− | - | + | - First in First Out. |
||Incorrect | ||Incorrect | ||
− | - | + | |
+ | {The stack pointer will point to? | ||
+ | |type="()"} | ||
+ | - The location to store the next item | ||
||Incorrect | ||Incorrect | ||
− | - | + | + Top of the stack. |
+ | ||Correct | ||
+ | - Bottom of the stack. | ||
+ | ||Incorrect | ||
+ | |||
+ | {To add an item to the stack you? | ||
+ | |type="()"} | ||
+ | - Pop. | ||
+ | ||Incorrect | ||
+ | + Push. | ||
+ | ||Correct | ||
+ | - Peek. | ||
+ | ||Incorrect | ||
+ | |||
+ | {To remove an item from the stack you? | ||
+ | |type="()"} | ||
+ | + Pop. | ||
+ | ||Correct | ||
+ | - Push. | ||
||Incorrect | ||Incorrect | ||
+ | - Peek. | ||
+ | ||Incorrect | ||
+ | |||
+ | {To look at the top of the stack without removing it you? | ||
+ | |type="()"} | ||
+ | - Pop. | ||
+ | ||Incorrect | ||
+ | - Push. | ||
+ | ||Incorrect | ||
+ | + Peek. | ||
+ | ||Correct | ||
</quiz> | </quiz> | ||
=Graphs= | =Graphs= | ||
<quiz display=simple> | <quiz display=simple> | ||
− | { | + | |
− | |type=" | + | {Look at this graph: |
− | + | + | |
+ | [[File:Graph-4.jpg|300px]] | ||
+ | |||
+ | select the appropriate options below: | ||
+ | |type="[]"} | ||
+ | - The degree of vertex A is 3 | ||
+ | ||Incorrect | ||
+ | - The degree of vertex D is 1 | ||
+ | ||Incorrect | ||
+ | + The degree of vertex B is 3 | ||
+ | ||Correct | ||
+ | + The degree of vertex E is 1 | ||
+ | ||Correct | ||
+ | |||
+ | {Look at this graph: | ||
+ | |||
+ | [[File:Graph-4.jpg|300px]] | ||
+ | |||
+ | select the appropriate options below: | ||
+ | |type="[]"} | ||
+ | - Directed | ||
+ | ||Incorrect | ||
+ | + Undirected | ||
+ | ||Correct | ||
+ | - Weighted | ||
+ | ||Incorrect | ||
+ | +Unweighted | ||
+ | ||Correct | ||
+ | |||
+ | {Look at this graph: | ||
+ | |||
+ | [[File:Graph1.png|300px]] | ||
+ | |||
+ | select the appropriate options below: | ||
+ | |type="[]"} | ||
+ | - Directed | ||
+ | ||Incorrect | ||
+ | + Undirected | ||
+ | ||Correct | ||
+ | + Weighted | ||
+ | ||Correct | ||
+ | - Unweighted | ||
+ | ||Incorrect | ||
+ | |||
+ | {Look at this graph: | ||
+ | |||
+ | [[File:Graph2.png|300px]] | ||
+ | |||
+ | select the appropriate options below: | ||
+ | |type="[]"} | ||
+ | + Directed | ||
||Correct | ||Correct | ||
− | - | + | - Undirected |
||Incorrect | ||Incorrect | ||
− | - | + | - Weighted |
||Incorrect | ||Incorrect | ||
− | - | + | + Unweighted |
+ | ||Correct | ||
+ | |||
+ | {Look at this graph: | ||
+ | |||
+ | [[File:Graph3.png|300px]] | ||
+ | |||
+ | Complete the adjacency matrix, use Y & N only: | ||
+ | |type="{}"} | ||
+ | <table style="border:1px solid black;"> | ||
+ | <tr> | ||
+ | <td> </td><td>0</td><td>1</td><td>2</td><td>3</td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <td>0</td><td>X</td><td>{ Y }</td><td>{ Y }</td><td>{ Y }</td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <td>1</td><td> { Y } </td><td>X</td><td> { Y } </td><td> { N } </td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <td>2</td><td>{ Y }</td><td>{ Y }</td><td>X</td><td>{ N }</td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <td>3</td><td>{ Y } </td><td> { N } </td><td> { N } </td><td>X</td> | ||
+ | </tr> | ||
+ | </table> | ||
+ | |||
+ | {Look at this graph: | ||
+ | |||
+ | [[File:Graph2.png|300px]] | ||
+ | |||
+ | Complete the adjacency matrix, use Y & N only: | ||
+ | |type="{}"} | ||
+ | <table style="border:1px solid black;"> | ||
+ | <tr> | ||
+ | <td> </td><td>A</td><td>B</td><td>C</td><td>D</td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <td>A</td><td>X</td><td>{ Y }</td><td>{ N }</td><td>{ Y }</td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <td>B</td><td> { N } </td><td>X</td><td> { Y } </td><td> { Y } </td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <td>C</td><td>{ N }</td><td>{ N }</td><td>X</td><td>{ N }</td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <td>D</td><td>{ N } </td><td> { N } </td><td> { N } </td><td>X</td> | ||
+ | </tr> | ||
+ | </table> | ||
+ | |||
+ | {Look at this graph: | ||
+ | |||
+ | [[File:Graph3.png|300px]] | ||
+ | |||
+ | Complete the adjacency list (separate with commas & no spaces): | ||
+ | |type="{}"} | ||
+ | <table style="border:1px solid black;"> | ||
+ | <tr> | ||
+ | <td> </td><td>Connected</td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <td>0</td><td>{ 1,2,3 }</td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <td>1</td><td> { 0,2|0.2 } </td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <td>2</td><td>{ 0,1|0.1 }</td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <td>3</td><td>{ <nowiki>0</nowiki> } </td> | ||
+ | </tr> | ||
+ | </table> | ||
+ | |||
+ | {Look at this graph: | ||
+ | |||
+ | [[File:Graph2.png|300px]] | ||
+ | |||
+ | Complete the adjacency list (separate with comma no spaces, use None if nothing is connected): | ||
+ | |type="{}"} | ||
+ | <table style="border:1px solid black;"> | ||
+ | <tr> | ||
+ | <td> </td><td>Connected</td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <td>A</td><td> { B,D }</td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <td>B</td><td> { C,D } </td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <td>C</td><td>{ None }</td> | ||
+ | </tr> | ||
+ | <tr> | ||
+ | <td>D</td><td>{ None } </td> | ||
+ | </tr> | ||
+ | </table> | ||
+ | |||
+ | {Complete the following | ||
+ | |type="{}"} | ||
+ | You should use an adjacency list when there are { few } edges. | ||
+ | |||
+ | You should use an adjacency matrix if there are { many } edges. | ||
+ | |||
+ | {Processing adjacency matrix is much simpler because you can have direct access to check if an edge exists | ||
+ | |type="()"} | ||
+ | +True | ||
+ | ||Correct | ||
+ | - False | ||
||Incorrect | ||Incorrect | ||
+ | |||
</quiz> | </quiz> | ||
Line 191: | Line 543: | ||
=Graph Traversal= | =Graph Traversal= | ||
<quiz display=simple> | <quiz display=simple> | ||
− | { | + | |
+ | {Depth First Traversal uses a: | ||
|type="()"} | |type="()"} | ||
− | + | + | -Queue |
+ | ||Incorrect | ||
+ | +Stack | ||
||Correct | ||Correct | ||
− | - | + | -List |
||Incorrect | ||Incorrect | ||
− | - | + | -Dictionary |
||Incorrect | ||Incorrect | ||
− | - | + | |
+ | {Breadth First Traversal uses a: | ||
+ | |type="()"} | ||
+ | +Queue | ||
+ | ||Correct | ||
+ | -Stack | ||
+ | ||Inorrect | ||
+ | -List | ||
||Incorrect | ||Incorrect | ||
+ | -Dictionary | ||
+ | ||Incorrect | ||
+ | |||
+ | {Complete the following: | ||
+ | |type="{}"} | ||
+ | For Depth First & Breadth First traversals it is important to know when a node has been { discovered }. | ||
+ | When you evaluate a node the { neighbours } of the current node will be add to the Stack or Queue. | ||
+ | It is important to also record when you have { fully|completely } explored the current node. | ||
</quiz> | </quiz> | ||
=Searching Algorithms= | =Searching Algorithms= | ||
<quiz display=simple> | <quiz display=simple> | ||
− | + | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</quiz> | </quiz> | ||
Line 268: | Line 629: | ||
=Optimisation Algorithms= | =Optimisation Algorithms= | ||
<quiz display=simple> | <quiz display=simple> | ||
− | + | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</quiz> | </quiz> | ||
Line 288: | Line 640: | ||
2) { Logarithmic } : O(log N) | 2) { Logarithmic } : O(log N) | ||
3) Linear : { O(N) } | 3) Linear : { O(N) } | ||
− | 4) Linearithmic : { O(N log N) } | + | 4) Linearithmic : { O(N log N) } |
− | 5) { Polynomial } : O (N<sup>2</sup>) | + | 5) { Polynomial } : O (N<sup>2</sup>) |
− | 6) { Exponential } : O(k<sup>N</sup>) | + | 6) { Exponential } : O(k<sup>N</sup>) |
− | 7) Factorial : { O(N!) } | + | 7) Factorial : { O(N!) } |
{Complete the Order of Complexity for the following examples: | {Complete the Order of Complexity for the following examples: | ||
Line 301: | Line 653: | ||
4) Merge Sort : { Linearithmic|O(N log N) } | 4) Merge Sort : { Linearithmic|O(N log N) } | ||
5) { Bubble Sort } : Polynomial or O (N<sup>2</sup>) | 5) { Bubble Sort } : Polynomial or O (N<sup>2</sup>) | ||
− | 6) { Chess Board Problem } : Exponential or O(k<sup>N</sup>) | + | 6) { Chess Board Problem } : Exponential or O(k<sup>N</sup>) |
7) { Travelling Salesman Problem }: Factorial or O(N!) | 7) { Travelling Salesman Problem }: Factorial or O(N!) | ||
</quiz> | </quiz> |
Latest revision as of 16:58, 3 June 2022
Contents
Recursion
Arrays
Abstract Data Types & Dynamic vs Static
Queues
Stacks
Graphs
Trees
Graph Traversal
Searching Algorithms
Sorting Algorithms
Optimisation Algorithms
Order of Complexity