Data Structures Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Disadvantages of a LinkedList

A
  • We have to access elements sequentially

- Extra memory space for a pointer is required

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

What is a data structure?

A
  • is a data organization, management, and storage format
  • is a collection of data values, the relationships among them, and the functions or operations that can be applied to the data.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a DoubleLinkedList?

A

It’s a datastructure in which each node has a pointer to the previous and next node.

  1. Non contigous allocation
  2. The element previous to the head is null
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a HashMap?

A

It’s a data structure which consists of a pair of sets of a key and a value.

It takes advantage of the hashCode function to map a key into an specific index, where the value will be stored.

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

What is a linked list?

A

Data stucture of a linear collection of nodes

  1. They are stored in non-contiguous locations
  2. Instead each node has a pointer to the next node
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is an array?

A

Is a datastructure that consists of a collection of elements, each identified by an index.

  1. The most common form of arrays are one-dimensional.
  2. The elements are stored at contigous locations.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Advantages of a LinkedList

A
  1. Dynamic Size

2. Ease of insertion/deletion

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

What is a Stack?

A

It’s a collection of elements that implements the mechanism LIFO.

Methods

  1. pop() deletes the element from the top of the stack and returns it
  2. push() inserts an element on the top of the stack
  3. peek() returns the element at the top of the stack without deleting it
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a queue?

A

It’s a linear data structure which follows the FIFO order.

Methods

  1. enqueue() adds an item to the beginning of the end of the queue
  2. dequeue() removes the item at the beginning of the queue and returns it
  3. front() get the front item of the queue
  4. rear() get the last item from queue
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How does a HashMap inserts a set of key-value?

A
  1. It uses a method put which takes a key and a value as parameters
  2. It uses the hashCode function to map the key into an index
  3. If the index is empty it stores the value in a single element linked list.
    Else, it stores the value at the end of the linked list
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is Big O’ Notation

A

Big O notation is special notation that tells you how fast an algorithm is

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

What is the complexity of accessing an element in an array?

A

Array lookup is always O(1) (constant)

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

What is the complexity of adding a new element to an array?

A

Trick question. Adding a new element to an existing array it’s not possible

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

A use case for a double linked list

A

Undo Redo operations.

Surfing the internet and going to the previous website and then coming back.

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

What is a binary tree

A

A tree data structure in which each node has at most two children

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