Abstract Data Types

0.0(0)
studied byStudied by 1 person
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/22

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

23 Terms

1
New cards

Abstract Data Types

A specification for a group of values and the operations on those values that is defined conceptually and independently of any programming language

2
New cards

Defining ADT in an interface

Make an interface with the abstract methods as the operations that can be done to that ADT

3
New cards

ADT Stack

This ADT organizes its entries according to the order in which they were added (the newest entry is at the top, the oldest entry is at the bottom). You typically cannot search for a particular entry in a stack. LAST-IN-FIRST-OUT

4
New cards

Top entry in a stack

The newest item among the items currently in a stack

5
New cards

Operation "push"

The operation that adds an entry to a stack

6
New cards

Operation "pop" (pull)

The operation that removes an entry from the stack

7
New cards

Operation "peek" (getTop) for stack

The operation that retrieves the top entry of the stack without removing it

8
New cards

Implementation of a stack in an array

The last occupied element in the array should be the top entry in the stack because this makes it easier to pop an element from the stack (no need to shift elements). Once your remove an element from the array, you can set it to be null.

9
New cards

ADT Set

A collection of entries that does not have to be in any particular order but cannot have duplicates

10
New cards

ADT Queue

Basically a waiting line. FIRST-IN-FIRST-OUT. The item added most recently is at the back of a queue (or at the back of the waiting line). The queue has no search operation

11
New cards

Removing entries from Stack and Queue

STACK: the entries will be in REVERSE chronological order (beginning with the most recent and ending with the first item added to the stack)
QUEUE: the entries will be in chronological order, beginning with the first item added to the queue

12
New cards

Operation "enqueue" (put)

The operation that adds an entry to a queue

13
New cards

Operation "dequeue" (get)

The operation that removes an entry from a queue

14
New cards

Operation "getFront"

The operation that retrieves the queue's front entry without changing the queue in any way

15
New cards

Implementation of a queue in an array

The front element is the first element in the array. When adding an element, add it to the index to the right of the previous back element. When removing, remove the front element. When adding and removing, don't move the other elements. When the queue section is at the end, wrap around the array as if it was a circular array.

16
New cards

ADT Priority Queue

Organizes objects according to their priorities. You can make anything be a symbol for the priority (like integers). Perhaps use compareTo to compare the priorities of different objects

17
New cards

Operation "add(T newEntry)"

The operation that adds the newEntry into the priority queue

18
New cards

Operation "remove"

The operation that removes and retrieves the item with the highest priority

19
New cards

Operation "peek" for priority queue

The operation that retrieves the item with the highest priority

20
New cards

Implementation of a priority queue in an array

The entry with the highest priority should occur at the end of the array, so removing it would leave the other entries in their present places

21
New cards

ADT Map

A Map is an interface that represents a collection of entries that consists of keys and their values, where each key is associated with a single value.

22
New cards

ADT Heap

A COMPLETE binary tree in which every node's value is smaller than its children's' values (This means that the root has always the smallest value)

23
New cards

Implementation of a heap in an array

Leave index zero empty. In index 1, place the root. Keep on going through the heap from left to right and going to the level beneath when you went through the rightmost node in the level