Algorithms Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Stacks

A
  • first in, last out
  • uses a pointer that points to the element at the top of the list
    PEEK - to look at the top item without popping it off
    POP - removing the top item of the stack
    PUSH - to add an item to the top of the stack
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Queues

A
  • first in, first out
  • uses two pointers for the front and back. The front holds the first element, and the back stores the next available space
    ENQUEUE - adds to the end of the queue
    DEQUEUE - removes the first item
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Algorithm definition

A

A series of steps that completes a task

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Linked list

A

A dynamic/ data structure
Each node item consists of data and a pointer
the pointer gives the location of the next node

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Trees

A

Formed from nodes and edges that can be traversed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Breadth first search

A

(row by row)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Depth first search

A

(column by column)
v

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Pre-order Traversal

A

Marker is on the left

root, left leaf, right leaf

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

In-order traversal

A

the marker is below the node

left leaf, root, right leaf

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Post-order traversal

A

the marker is on the right

left node, root, right node

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Graphs

A

Set of vertices/ nodes, connected by edges/arcs
Directed graph: edges can be traversed in both directions
Weighted graph: each arc has a cost/ value attached to it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Binary Search

A

A O(log(n)) algorithm to search a sorted list for a particular item by repeatedly halving the sublist which contains the item

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Bubble sort

A

A O(n^2) sorting algorithm that iterates through a list comparing each element to its successor and swapping elements if the successor is greater than the current element. This is repeated until no more swaps can be made.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Linear search

A

A O(n) algorithm to search a list for a particular item by iterating through the list and checking each element until the required item is located, or the end of the list is reached.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Merge sort

A

A O(n log(n)) divide and conquer sorting algorithm that recursively halves the list into sublists until all sublists are length of 1 item. The sublists are then merged back together and sorted.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Quick sort

A

A O(n log(n)) sorting algorithm similar to merge sort, but relies on choosing a pivot element whenever the list is split. Elements greater than the pivot go into one sublist.