Week 1 Flashcards
Solve the following summation:
n
∑ i ?
i=0
n
∑ i = 0 + 1 + 2 … + n = (n(n+1))/2
i=0
Roughly: (1/2)n^2
Define an Abstract Data Type (ADT)
The collection of common operations that are accessed through an interface and its characteristics.
Name two Data Structures of an integer.
Bit vector
Hexadecimal vector
Name all 8 ‘fundamental’ ADTs
Set Sequence Map Stack Queue Priority queue Graph Tree
Define a Set as well as its attributes
A collection of members or elements
Finite or infinite
Orderless
Members are not unique and if appear multiple times called a bag/multiset
Define a Sequence/List and it’s attributes
A collection of objects in which insertion order must be maintained.
Multiset with order
Operations include add remove search
Define a Stack and it’s attributes
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)
Define a Queue and it’s attributes
A collection with two defining operations, enqueue and dequeue
Enqueue adds new element to back
Dequeue removes element at front
First in First Out
Define a Priority Queue and it’s attributes
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
Define a dictionary/map and it’s attributes
A collection of key pair values
Each key must be unique
Define a graph and it’s attributes
A finite set of vertices that are connected via edges representing relationships.
Define a tree and it’s attributes
A collection of vertex that is acyclic.
Contains a root at the top and leaves at the bottom
Define two data structures that can be used for a list, set or dictionary ADT
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
Define and solve GCD(60,24) using the Euclidean Algorithm
GCD stands for Greatest Common Divisor.
Euclidean Algo = GCD(a,b), a=b(q) + r