Topic 3

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall with Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/52

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No study sessions yet.

53 Terms

1
New cards

What is an algorithm?

A set of instructions which completes a task in a finite time and always terminates.

2
New cards

What is Graph Traversal?

The process of visiting each vertex in a graph

3
New cards

Name the two types of graph traversal.

Depth-first search and breadth-first search.

4
New cards

Which traversal is best for navigating a maze?

Depth-first search

5
New cards

What is Breadth-first traversal useful for?

Shortest path on an unweighted graph

6
New cards

What abstract data type is used for a breadth-first traversal?

Queue

7
New cards

What abstract data type is used in a depth-first traversal?

Stack

8
New cards

What type of graphs can be traversed?

Connected graphs

9
New cards

Can a tree undergo depth-first traversal?

Yes, although it might be more appropriate to use a tree-traversal

10
New cards

Can a graph traversal start from any node?

Yes.

11
New cards
<p>In what order would these nodes be discovered in a breadth-first search, starting from node A (edges: A-B, A-C, B-D, B-E)?</p>

In what order would these nodes be discovered in a breadth-first search, starting from node A (edges: A-B, A-C, B-D, B-E)?

A B C D E

12
New cards
<p>In what order would these nodes be discovered in a depth-first search, starting from node A (edges: A-B, A-C, B-D, B-E)?</p>

In what order would these nodes be discovered in a depth-first search, starting from node A (edges: A-B, A-C, B-D, B-E)?

A B D E C

13
New cards

What is tree-traversal?

The process of visiting/updating/outputting each node in a tree; it is an algorithm

14
New cards

What is an algorithm?

A set of instructions which completes a task in a finite time and always terminates.

15
New cards

Name the three types of tree-traversal.

Preorder, inorder and postorder.

16
New cards

Name a use of postorder traversal.

Emptying a tree; infix to RPN conversions; producing a postfix expression from an expression tree

17
New cards

Which traversal would be used for copying a tree?

Preorder traversal

18
New cards

Name a use of inorder traversal.

Outputting the contents of a binary search tree in ascending order

19
New cards

Can inorder traversal be performed on any tree?

No, only binary trees (including binary search trees)

20
New cards

Can preorder traversal be performed on any tree?

Yes

21
New cards

Can postorder traversal be performed on any tree?

Yes

22
New cards

Where does tree traversal start?

At the root

23
New cards

How do traversals work their way around the tree?

Anticlockwise

24
New cards
<p>What is the output when an inorder traversal is performed on this tree</p>

What is the output when an inorder traversal is performed on this tree

Lily, Enid, Susan, Beth, Imogen, Amy, Niamh

25
New cards
<p>What is the output when a postorder traversal is performed on this tree </p>

What is the output when a postorder traversal is performed on this tree

Lily, Susan, Enid, Imogen, Niamh, Amy, Beth

26
New cards
<p>What is the output when a preorder traversal is performed on this tree </p>

What is the output when a preorder traversal is performed on this tree

Beth, Enid, Lily, Susan, Amy, Imogen, Niamh

27
New cards

Which of the following is true of reverse Polish notation? (A: uses a queue, B: eliminates the need for brackets, C: based on graphs)

It eliminates the need for brackets

28
New cards

Convert the following infix expression to reverse Polish 14 + 6

14 6 +

29
New cards

Convert the following infix expression to reverse Polish (12 - 4) × (3 + 5)

12 4 - 3 5 + ×

30
New cards

Convert the following reverse Polish expression to infix 13 6 + 4 -

(13 + 6) - 4

31
New cards

Convert the following infix expression to reverse Polish 3(4 - 2) + 9

4 2 - 3 × 9 +

32
New cards

Convert the following reverse Polish expression to infix 4 6 7 + -

4 - (6 + 7)

33
New cards

Which of the following is not an example of where reverse Polish is used? (A: PreScript, B: Bytecode, C: PostScript)

PreScript

34
New cards

What is the result of this reverse Polish expression? 2 8 × 2 4 - ×

-32

35
New cards

What is the result of this reverse Polish expression? 4 6 8 - -

6

36
New cards

What is a searching algorithm used for?

A searching algorithm is used to find a specified data item within a set of data

37
New cards

Time complexity of linear search

O(N)

38
New cards

What must be true about a set of data if it is to be searched using the binary search algorithm?

The set of data must be sorted

39
New cards

Which is most efficient, binary search or linear search?

Binary search

40
New cards

Time complexity of binary search

O(LogN)

41
New cards

Calculation used to find the midpoint of a set of data

Add the first and last positions of the data, and divide by two

42
New cards

Time complexity of binary tree search

O(LogN)

43
New cards

What is a binary tree?

A rooted, ordered tree in which each node has no more than 2 children

44
New cards

Which sorting algorithm is most time efficient: bubble sort or merge sort?

Merge sort

45
New cards

Which sorting algorithm is an example of a "divide and conquer" algorithm?

Merge sort

46
New cards

What is the time complexity of the bubble sort algorithm?

O(n2)

47
New cards

What is the time complexity of the merge sort algorithm?

O(nlogn)

48
New cards

Sort this array into ascending order using the bubble sort algorithm: 4 3 5 7 6

4 3 5 7 6 -> 3 4 5 7 6 -> 3 4 5 7 6 -> 3 4 5 6 7

49
New cards

Sort this array into ascending order using the merge sort algorithm: Tom Sue Jack Bill Ada

Ada Bill Jack Sue Tom

50
New cards

What is the purpose of an optimisation algorithm?

To find the best possible solution to the problem posed

51
New cards

What is the purpose of Dijkstra's algorithm?

To find the shortest path between two nodes in a network

52
New cards

Which of the following is not an example of where Dijkstra's algorithm is used? (A: Satellite navigation, B: Binary tree search, C: Packet routing)

Binary tree search

53
New cards
<p>Which table shows Dijkstra's algorithm carried out on this graph</p>

Which table shows Dijkstra's algorithm carried out on this graph

C

Explore top flashcards