Week 1 Flashcards

1
Q

Solve the following summation:
n
∑ i ?
i=0

A

n
∑ i = 0 + 1 + 2 … + n = (n(n+1))/2
i=0

Roughly: (1/2)n^2

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

Define an Abstract Data Type (ADT)

A

The collection of common operations that are accessed through an interface and its characteristics.

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

Name two Data Structures of an integer.

A

Bit vector

Hexadecimal vector

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

Name all 8 ‘fundamental’ ADTs

A
Set
Sequence
Map
Stack
Queue
Priority queue
Graph
Tree
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Define a Set as well as its attributes

A

A collection of members or elements

Finite or infinite
Orderless
Members are not unique and if appear multiple times called a bag/multiset

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

Define a Sequence/List and it’s attributes

A

A collection of objects in which insertion order must be maintained.

Multiset with order
Operations include add remove search

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

Define a Stack and it’s attributes

A

A collection with two defining operations, push pop.

Push adds new element at top of stack
Pop removes element from top of stack

Stack ADT implements Last In First Out. (LIFO)

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

Define a Queue and it’s attributes

A

A collection with two defining operations, enqueue and dequeue

Enqueue adds new element to back
Dequeue removes element at front

First in First Out

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

Define a Priority Queue and it’s attributes

A

A collection with the same operations as Queue however an additional priority is associated with each element.

Enqueue add new element to back of queue
Dequeue remove element with the highest priority

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

Define a dictionary/map and it’s attributes

A

A collection of key pair values

Each key must be unique

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

Define a graph and it’s attributes

A

A finite set of vertices that are connected via edges representing relationships.

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

Define a tree and it’s attributes

A

A collection of vertex that is acyclic.

Contains a root at the top and leaves at the bottom

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

Define two data structures that can be used for a list, set or dictionary ADT

A

Array or Linked List

Array:

  • collection of elements stored in a continuous manner
  • fast random access
  • needs to be resized manually

LinkedList:

  • each node stores data and contains a pointer to the next node
  • there’s a header pointer at the beginning of the list
  • tail pointer that points to the end of the list
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Define and solve GCD(60,24) using the Euclidean Algorithm

A

GCD stands for Greatest Common Divisor.

Euclidean Algo = GCD(a,b), a=b(q) + r

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