Lecture 5 Flashcards

1
Q

What is List?

A

A list is a sequence of zero or more data items

Size can grow or shrink

Items can be accessed, inserted, or deleted at any position in a list

The total number of items is said to be the length of the list

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

What are the two types of Lists?

A

Array and LinkList

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

What is an Array?

A

An Array is a structure of fixed-size that can hold a collection of similar items

Elements are indexed (from 0)

Maintain insertion order of elements

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

What is an Arraylist?

A

ArrayList is a variable-length Collection class. They can increase or decrease the size dynamically

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

What is a Linked List?

A

Maintain the insertion order of elements

Elements are not indexed – when searching, start with the head and work your way through

O(n)

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

What is a Stack?

A

Its items are added and deleted on a last-in-first-out (LIFO) basis

To add an item to a stack, you push an item onto the top

To remove an item from the top you pop it

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

What are Queues?

A

Items inserted at one end (the rear)
Items deleted at the other end (the front)

A queue is a FIFO type data structure
The items are deleted in the same order as they were added
On a first-in-first-out basis

ENQUEUE (insertion)
DEQUEUE (deletion)

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

What are hash tables?

A

A Hash table or Hash Map is a data structure that maps a Key to a Value
A special function called a Hash Function performs this mapping
This function usually maps the key to an index in an array
Key and value could be any type of data structure!

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

How to implement Hash Tables

A

1) An initial set of space is allocated in the array
2) The hash function maps the key to an array index
3) The function should map within the array bounds

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

What is A collision in has tables?

A

Collision: Two things with different hash codes could be mapped to the same index

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

name 1 real ife application of Lists
Stacks
Queues
Hash Tables

A

Lists-Often used to implement other data structures e.g. queues and stacks

Stacks- reverse a string

Queues-printer queues

Hash Tables-address table

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

Examples of Graph data structure?

A

Road Maps

Relationships- Family trees

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

What is a Graph?

A

A graph is a collection of nodes (vertices) which
maybe connected in pairs by line segments called
edges

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

How do you define a Graph?

A

A graph G = (V,E) is composed of:
V: a set of vertices or nodes
E: a set of edges or lines connecting the vertices in V
An edge e=(u,v) is a connection between the vertices u and v

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

Define a binary Tree

A

A binary tree is a special type of tree where the maximum number of children is two

Trees are usually ordered from the top to the bottom and left to right

Trees are very fast to search
E.g. Binary search

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