3-Data Structures (Arrays Lists Stacks Queues) Flashcards

1
Q

Properties of a linear data structure

A

There is a UNIQUE first element
There is a UNIQUE last element
Every component has a unique predecessor (except the first)
Every component has a unique success (except the last).
If any are false, it’s nonlinear.

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

What are the 2 methods for accessing data stored in a linear structure

A

Sequential access - by accessing all elements preceding N,

Direct access, any element can be accessed directly.

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

What are homogeneous structures?

A

All the same type

Direct- array

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

What are heterogeneous structures?

A

All different types

Direct- record

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

General sequential access structure?

A

List

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

LIFO sequential access structure?

A

Stack

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

FIFO sequential access structure?

A

Queue

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

Example of a non linear strucutre

A

Set

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

Domain of an array (contents)

A

A collection of fixed number of components of the same type

A set of indexes used to access the data stored. One to one relationship.

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

Advantages of linked lists

A
  • Fair use of memory
  • Size of the structure does not need to be declared in advance
  • Insertions and deletions are cheaper
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Disadvantages of linked lists

A

Algorithms are more complex, harder to read and harder to debug
Allocation and de-allocation of memory space impose some overhead to the performance of the algorithm

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

What is the SIEVE OF ERATOSTHENES

A

Gives all prime numbers between 2 and N

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

What are linked lists

A

It consists of a collection of records called nodes each containing at least one member that gives the location
of the next node in the list.

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

What is a list?

A

It is a linear structure that provides only sequential access to its elements
• It normally has two “special” named elements called head and tail.
Main advantage over arrays is easy insertion and deletion of nodes
• Mostly when implemented using dynamic allocation

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

When examining a list, what cases do we have to consider?

A

• When examining a list, we most often have to consider three separate cases
• The node is the first node of the list
• The node is an “interior” node
• The node is the last node of the list
The above is the reason why some programs choose to use sentinels in their
linked lists.

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

What is a sentinel?

A

Empty node that points to the last and first nodes of a list.

17
Q

What is a multilist

A

A multilist is a linked list whose nodes contain multiple link fields that form independent linked lists
• For instance a doubly linked list is a multilist with the invariant that x.left.right and x.right.left are both equal to x.

18
Q

Applications of stacks

A

A few examples include:
• Expression Evaluation
• Runtime Memory Management
• A Call Stack is used to hold information about function calls
• Search problems
• Most solutions require a “memory” to know which part of the search space has not been explored
• Reversing linear orders