Data Structures and Algorithms Mid-Term Study Flashcards

1
Q

The Queue ADT

A

-stores arbitrary objects- insertions and deletions follow the first-in, first-out scheme-insertions at the rear,removals at the front

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

enqueue()

A

inserts an element at the end of the queue

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

dequeue()

A

removes and returns the element at the front of the queue

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

object first() (Queue)

A

returns the element at the front without removing it

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

integer size() (Queue)

A

returns the number of elements stored

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

boolean isEmpty() (Queue)

A

indicates whether no elements are stored

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

Queue boundary cases

A

Attempting the execution of deqeueue() or first() on an empty queue returns null

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

Direct Applications for a Queue

A
  • Waiting lists, bureaucracy- Access to shared resources- Multiprogramming
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Indirect Applications for a Queue

A
  • Auxiliary data structure for algoritms- Component of other data structures
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Queue is limited to the __________ of the array.

A

size

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

Queue Performance runs in _________.

A

O(1)

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

enqueue() corresponds to what java.util.Queue?

A

add(e)offer(e)

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

dequeue() corresponds to what java.util.Queue?

A

remove()poll()

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

In a queue, first() corresponds to what java.util.Queue?

A

element()peek()

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

In a queue, size() corresponds to what java.util.Queue?

A

size()

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

In a queue, isEmpty() corresponds to what java.util.Queue?

A

isEmpty()

17
Q

How do you impliment a round robin scheduler using a queue?

A

repeat the following steps:- e = Q.dequeue()- Service element e- Q.enqueue(e)

18
Q

What method does a circular queue have that other queues don’t?

A

rotate()

19
Q

List the methods of the Double Ended Queue.

A

enqueueLast(object)enqueueFirst(object)dequeueFirst()dequeueLast()

20
Q

What does ADT stand for?

A

Abstract Data Type

21
Q

What’s an example of an ADT?

A

A simple stock trading system.order buy(stock, shares, price)order sell(stock, shares, price)void cancel(order)

22
Q

Stack

A

Follows Last in first out scheme.Think of the pez despenser!push(object)object pop()top()size()isEmpty()

23
Q

What built in utility does java use for the stack?

A

java.util.Stack

24
Q

Can the operations pop and top be performed even though the stack is empty?

A

Yes

25
Q

Direct Applications of using the stack.

A
  • Page-visited history in a web browser- undo sequence in a text editor- Chain of method calls in the Java Virtual Machine
26
Q

Indirect applications of the stack.

A

Auxiliary data structure for algorithmsComponent of other data structures

27
Q

Operator precedence

A
  • has precedence over +/-
28
Q

Recursive definition

A

f(n) = { 1 if n = 0n-f(n-1) else

29
Q

factorial function

A

n! = 123……..(n-1)n

30
Q

Base Cases

A

Values of the input variables for which we perform no recursive calls

31
Q

Recursive Calls

A
  • calls to the current method- Each recursive call should be defined so that it makes progress towards a base case.
32
Q

Application on using Recursion

A

Drawing ticks on an English Ruler

33
Q

reversing an array

A

reverseArray(A, i, j)if (i < j){Swap A[i] and A[j]reverseArray(A, i+1, j-1)}return

34
Q

Recursive power function

A

p(x,n) = { 1 if n=0x*p(x,n-1) else

35
Q

What is an Algorithm?

A

A step by step process that creates a result in a finite amount of time

36
Q

The Seven Important Functions

A

Constant = 1Logarithmic = log nLinear = nN-Log-N = n log nQuadratic = n^2Cubic = n^3Exponential = 2^n

37
Q

Big-Oh Notation

A

Characterizes functions according to their growth rates: different functions with the same growth rate may be represented using the same O notation.