Data Types, Data Structures and Algorithms Flashcards

(41 cards)

1
Q

What is an array?

A

An array is an ordered, finite set of elements of a single type, where the elements are stored contiguously in memory. Each item has a common identifier and can be accessed by their index position in the array.

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

What is a record?

A

A row in a file made up of fields.

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

What are 2 key features of records?

A

It is mutable and can store multiple data types.

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

What is 2 key feature of list?

A

It is mutable, store multiple data type.

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

3 difference of list and array?

A

1.In list data is not stored next to each other in memory.
2.In list you can add data and change data while can only change data in array.
3.In list can have multiple data type but array only have 1,

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

What is 3 feature of tuple?

A

1.Immutable
2.Static data type
3.Dont need to have same data type.

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

What is a linked list?

A

1.A dynamic data structure
2.Each node consist of data and a pointer
3.Pointer gives location of next node.

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

What is clustering?

A

Several position being filled around common collision values.

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

What are all the solution of resolving collisions(3 solutions)

A

1.To repeatedly check the next available space in the hash table until an empty space is found(Open addressing)
2. Finding an alternative position of item in the hash table known as rehashing.
3.Chaining the items are in the same position but in different element of the 2D array.
4.Use a overflow table or linked list which can be searched sequently

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

What is the benefit of Hash table over Linked list when we have a lot of data and incoming data?

A

1.Linked list will require each node to be checked.
2.A linked list will take longer to search as more data is added.
3.Hash tables enable direct access to the location of record.
4.It takes no longer to search as more
records are added

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

What is linear probing in hash table?

A

Linear probing is a technique where the hashing function provides a start position, and a linear search is then applied from that point until the item is found.

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

What is a graph?

A

A data structure containing nodes/vertices and pointer/edge.

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

What are the 2 types of graph and how are they different?

A

Can be directed and undirected. Undirected means there is no specified direction but directed means point in one direction.

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

What else can each edge/pointer be given?

A

Can be weighted with each edge given a value representing a relationship between nodes/vertices.

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

How else can we store graphs?

A

Using an array. Known as an adjacency matrix.

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

In an adjacency matrix how can we represent a link between 2 nodes if has no weight?

A

With 1 and 0s

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

What is a stack known as?

A

Last in first out

18
Q

What are some operation that can be used on a stack.

A

Pop-Which pops the data at the top of the stack
Peek-Peek at the top item
Push-Push an item on a stack

19
Q

What are the 2 errors that can happen in a stack.

A

Stack overflow-When an item is pushed on a full stack
Stack underflow-When an item is popped on a empty stack

20
Q

What are application of stack?

A

Undo operation

21
Q

What do stack use and how they are normally implemented?

A

Implemented using an array and stack has pointers. A stack has a stack pointer that always point to the node at the top.

22
Q

What type of data structure is a queue.

A

First in first out

23
Q

How would we add data and remove data in a queue.

A

Using enqueue and dequeue.

24
Q

What else can we do to a queue?

A

Use a peek operation with show the first item withought deleting it.

25
What else 2 type of queue is there?
Circular queue and priority queue.
26
What pointers does a queue have?
A back/tail pointer pointing to the last item A front/head pointer pointing to first item
27
What 2 error can happen in a queue?
Queue underflow-When empty queue is dequeued. Queue overflow-When full queue is enqueued,
28
What is the problem with a normal Queue and how can we fix it?
Since front and back pointer moving in same direction as item added , the array will quickly run out of space. Can fix it using circular queue.
29
How do we use a circular queue?
We do rear+1 mode length to get position of next item
30
What is a tree?
Fundamental data type consisting of nodes and pointers.
31
What are the 3 types of nodes in a tree?
Root node, Child node and Leaf node.
32
How are nodes connected in trees?
With pointer/edges.
33
What is a use of a rooted tree?
Storing and managing file and folder structure
34
What is a binary tree?
Each node can only have max 2 pointer.
35
What can binary tree be stored at?
Array and Dictionaries.
36
When a Binary tree is in an array what does it contain?
Left pointer, Right pointer, the Data and index position
37
How does a normal hash table work?
Convert Value into numbers, add the numbers up and mod by table size to get memory address.
38
What are the 3 types of tree traversals?
Pre order Post order In Order
39
What is In order
Left-node-right(Under)
40
What is post order
left-right-root(Right)
41
What is preorder -
Root-Left-Right(Left)