Data Structures Flashcards

1
Q

What is an Array?

A
  • Linear Data Structure
  • Elements are stored in contiguous memory locations
  • Can access elements using index
  • Stores homogeneous elements
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the applications of Arrays?

A

Storing Information in a linear fashion. Suitable for applications that require frequent searching.

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

What is an 1DA?

A

1 Dimensional Array, can be seen as a row.
- Needs contiguous memory
- Elements in a linear sequence
- Only same type elements (Homogeneous)
- Only one index is used.

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

How to declare an 1DA?

A

Datatype varname[size];

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

How to initialize an 1DA?

A

Datatype varname[] = {ele1, ele2, ele3, ele4}

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

What is a 2DA?

A

2 Dimensional Array, can be seen as a table.

  • Store elements in sequence.
  • It is an Array containing 1DAs, therefore gaining one more dimention.
  • Two indices are used, one for row and one for column.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How to declare a 2DA?

A

Datatype varname[rows][cols];

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

Advantages of arrays?

A
  • Random access elements
  • Easy sorting and iteration.
  • Replacement of multiple variables.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Disadvantages of arrays?

A
  • Fixed size, surplus will be “wasted”
  • Difficult to insert and delete
  • Need contiguous memory
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Define a Linked List?

A
  • A linear data structure
  • Elements can be stored by memory availability (not contiguous)
  • Only same type elements (homogeneous)
  • Dynamic size
  • Easy insertion and deletion
  • 1st element is called Root/Head, if lost, all the Linked list will be lost, as it points to the next elements.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are the applications of a Linked List?

A
  • When Memory is Limited
  • When requires frequent insertion and deletion
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the types of Linked List?

A
  • Single Linked List
  • Double Linked List
  • Circular Linked List
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a Single linked List?

A

The simple Linked List.

  • There will be a Head/root Pointer that will link to the first node.
  • Each node contains data and a link to the next one.
  • The last node will point to null.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a Double Linked List?

A

A linked list in wich each node points to both neighbours (previous and next), so we can move forwards and backwards.

  • There will be a head/root pointer to the first node.
  • The first node will point to the next (second node), and to the previous address (null).
  • All middle nodes have two pointers and data.
  • The last node will point to null.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is a Circular Linked List?

A

A linked list in wich the last node points to the first one.

  • There will be a head/root pointer to the first node.
  • Each node points forwards
  • The last node will point to the first node.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q
A