Data Structures and Data Manipulation Flashcards

1
Q

Data Structure

A

Is a group of related data items.

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

Static Data Structure

A

Are those where the size is fixed when the structure is created (the size cannot change during processing).

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

Dynamic Data Structure

A

Are those where the size of the data structure changes as data is added and removed.

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

Static vs Dynamic

A

Static - amount of storage required known so easier to program. Dynamic - amount of storage not known more complex code.

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

Stack

A

LIFO. A stack is a list in which insertion and deletion take place at the same end (TOP). One pointer – top.

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

Stack - uses

A

Storing return addresses (during subroutine calls), Passing parameters, Storing contents of registers while processing interrupt
Reversing the order of a set of data.

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

Stack overflow/underflow

A

Overflow error when try to push an item onto a full stack and Underflow when try to pop item off empty stack.

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

Stack – insert algorithm

Push item onto stack

A

If Stack is full Then Error and stop Else Increment StackPointer. Add data item at position StackPointer End if.

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

Stack – retrieve/delete alg

Pop item off stack

A

If Stack is empty Then Error and stop Else Return the data item at position StackPointer. Decrement StackPointer End if.

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

Queue

A

FIFO. A queue is a list. Insertion is done at one end, while deletion is performed at the other end. Front and back pointers.

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

Q overflow/underflow

A

Overflow error when try to enqueue an item onto a full queue and Underflow when try to dequeue item off empty queue.

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

Queue - uses

A

Jobs waiting for a printer in a spool queue, Job queue batch processing system, Keyboard buffer.

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

Shuffle queue

A

Front index always fixed (items shuffle up to front when an item is dequeued.

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

Circular queue

A

When enqueuing next index moves forward. When dequeuing the front index moves forward. Circular as next pointer wraps to beginning once last index is reached.

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

Queue – insert algorithm / add item to circular queue

A

(Enqueue). If Queue is full Then Error and stop Else Add data item at position NextPointer. Increment NextPointer. If NextPointer > MaxIndex Then Assign the value of 1 to NextPointer End if.

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

Queue – retrieve/delete

from circular queue

A

(Dequeue). If Queue is empty Then Error and stop Else Return the data item at position FrontPointer. Increment FrontPointer. If FrontPointer > MaxIndex Then Assign the value of 1 to FrontPointer End If End If.

17
Q

Tree

A

Tree is represents the relationship between data items. (Stack and queue don’t imply relationship between data items).

18
Q

Tree - uses

A

Binary search tree - storing data in such a way that it makes it easy and fast to search. Representing sorted lists of data.
Most databases use this tree concept as the basis of storing, searching and sorting it’s records.

19
Q

Tree – insert algorithm

add item to a tree

A

Start at root. REPEAT IF new data

20
Q

Tree – retrieve algorithm

A

Start at root. WHILE pointer is not Null DO IF current data = required data THEN RETURN current data ELSE IF required data

21
Q

Tree – delete algorithm

A

Deletion is more tricky as simply deleting a node could detach child nodes from the tree. Deletion could be done in the following ways: Mark the node deleted but leave in tree to maintain structure. OR Re-attach any child nodes to the tree

22
Q

Binary Search

A

The binary search is more efficient than the linear search, but requires the data to be in order.

23
Q

Binary Search Alg

A

1) Look at the item at the midpoint of the list (the current item). 2) If the current item is the item sought, then it has been found. 3) If the current item is not the item sought, discard the half of the list that can’t contain the item sought and repeat the same method with the other half of the list. 4) Keep repeating these steps until the item is found or the list contains no items.

24
Q

Binary Search Adv

A

Usually faster because half of the data is discarded at each step and fewer items checked. This is more efficient for large files.

25
Q

Binary Search Disadv

A

One disadvantage of a binary search is that items must be in an order to allow appropriate items to be discarded.

26
Q

Serial Search (Linear)

A

The search starts at the beginning of the list. Each element in turn is compared with the required value until a match is found or the end of the list is reached.

27
Q

Serial Search Alg

A

ThisElement = 1. Found = False. REPEAT IF List[ThisElement] = ElementSought THEN Found = True ELSE ThisElement = ThisElement + 1 UNTIL Found = True OR ThisElement > Max.

28
Q

Serial Search Adv

A

A serial search can be used on unordered sets of data.

29
Q

Serial Search Disadv

A

Generally slower because all data must be checked until the item is found or the end of the list is reached.

30
Q

Merging Data Files

A

Note when merging data files duplicates are not kept (just one appears in the new file).

31
Q

Merging Data Files Alg

A

OPEN existing files. CREATE a new file. CHECK existing files are not empty. Use pointers to identify records for comparison. REPEAT compare records indicated by pointers. COPY earlier value record to new file. MOVE correct pointer UNTIL end of one file. COPY the remaining records from the other file. CLOSE the files.

32
Q

Insertion Sort

A

Insert one number at a time into correct position… so list of sorted numbers is built up.

33
Q

Insertion Sort Adv

A

simple sorting algorithm and relatively efficient for small sets of data and mostly-sorted lists. It’s relatively fast for adding a small number of new items periodically.

34
Q

Insertion Sort Disadv

A

Inefficient for large sets of data.

35
Q

Quicksort

A

If the first pointer is less than the last pointer (if there are elements in the list) then:
1. Select an item at random to act as the ‘pivot’. 2. Create two new lists 3.…one with all items less than pivot 4…other with all items greater than pivot 5. Repeat these four steps until all lists only have one item.

36
Q

Quicksort Adv

A

Very quick for large sets of data.

37
Q

Quicksort Disadv

A

Initial arrangement of data affects the time taken. Harder to code.