Unit 2- Part 2 Flashcards

(51 cards)

1
Q

What does an ADT represent?

A

the ways of organizing data in a computing environment

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

What does an ADT provide?

A

provides a specification of:
-a set of data that is stored
-a set of operations that can be performed on the data

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

How are data structures realized?

A

-by implementing ADTs within a programming language

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

What ADT mean?

A

Abstract Data Type

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

What is Hashing?

A

-A technique that determines a storage index or location for storing an item in a data structure

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

What does a hash function do?

A

-Receives the search key and returns the index of an array where the search key is stored

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

What would a perfect hash function do?

A

maps each search key into an index of the hash table

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

The Set interface extends what?

A

extends the Collection interface

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

define Collection

A

An ADT that contains a group of objects/items

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

define Container

A

a class that implements the collection

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

List the different types of ADTs

A

-Bag
-List
-Stack
-Queue
-Dictionary
-Tree
-Graph

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

What is the Bag ADT?

A

-Unordered collection, may contain duplicates

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

What is the List ADT?

A

-A collection that numbers (first, second so on) its items

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

What is the Stack ADT?

A

Orders items sequentially
-Last In, First Out

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

What is the Queue ADT?

A

-Orders items sequentially
-First In, First Out

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

What is the Dictionary ADT?

A

Pairs of items (key and value)
-Can be sorted or not

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

What is the Tree ADT?

A

Arranged in a hierarchy

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

What is the Graph ADT?

A

Generalization of a tree

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

What are the three types of collections that Java Collections Framework supports?

A

-Sets
-Lists
-Queue

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

What does the Set interface require?

A

that an instance of Set contains no duplicate elements
-No two elements e1 and e2 can be in a set such that e1.equals(e2) is true

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

What is the AbstractSet class?

A

-abstract class that extends AbstractCollection, implements toString() method, and implements Set

22
Q

what does the AbstractSet class provide?

A

-concrete implementations for the equals() and the hashCode() methods

23
Q

What is the hash code of a set?

A

the sum of the hash codes of all the elements in the set

24
Q

what is the HashSet class?

A

a concrete class that implements Set

25
What needs to be to the HashSet class for better efficiency?
-objects added to a hash set need to implement the hashCode() method in a manner that properly disperses the hash code
26
What is the order of the elements inside a HashSet?
There is no specific order of the elements in a hash set -Need to use LinkedHashSet class
27
What is SortedSet and what does it do?
Is a sub-interface of Set -guarantees that the elements in the set are sorted
28
What is a TreeSet?
A concrete class that implements the SortedSet interface
29
30
How can one add objects into a TreeSet
if they can be compared with each other -Using wrapper classes and classes like String, Date, and Calendar that already implement the Comparable interface -Implementing Comparable or Comparator into your class
31
What is the reason behind using the term "tree" in a TreeSet and TreeMap classes in Java?
They implement the balanced search tree called "red and black tree" -This tree ensures O(logn) lookup which leads to the elements being sorted
32
public int compare(Object element1, Object element2) returns what when the element 1 is less than element2?
A negative value
33
public int compare(Object element1, Object element2) returns what when the element 1 is greater than element2?
A positive value
34
public int compare(Object element1, Object element2) returns what when the element 1 is equal to element2?
Zero
35
What does the List interface allow?
-duplicate elements to be stored in a collection -allows the user to specify where the duplicate element is stored
36
How can the user access the element of a list?
By Index
37
What are the ArrayList and LinkedList classes?
Concrete implementations of the List interface
38
Can a list grow or shrink dynamically?
Yes
39
If the application requires the insertions or deletions of elements at or from any place in the list, which one is better? (LinkedList or ArrayList)
LinkedList
40
What does ArrayList() do?
Creates an empty list with default initial capacity(10)
41
How is the Vector class different from the ArrayList class?
It contains synchronized methods for accessing and modifying the vector
42
How does priority queue order its elements? How does it work?
orders it elements according to the natural ordering using Comparable -the element with the least value is assigned with the highest priority
43
What does PriorityQueue() do?
creates a default priority queue with initial capacity 11
44
In simple terms, what is an iterator?
A program component that steps through a collection of data
45
How can the iterator be manipulated?
-Asked to advanced to the next entry -Give a reference to current entry -Modify the list as it passes through
46
What interfaces does the package java.util in the Java Class Library contain?
-Iterator -ListIterator
47
What are the methods of Iterator interface?
hasNext() next() remove()
48
What has to be called before remove() for there not to be an Exception? What Exception?
next() has to be called before -or you will get IllegalStateException
49
Where is the iterator normally positioned without the next()?
positioned before the first entry or between two entries or after the last entry
50
What does the ListIterator allow?
-traversal in either direction -Modification of list during iteration
51
List the methods that ListIterator contains
hasPrevious Previous nextIndex previousIndex add set