Data Structures Flashcards

1
Q

A data structure used to store homogeneous elements at contiguous locations. Size must be provided before storing data.

A

Array

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

Search Time: O(n) for Sequential search, O(log n) for Binary Search (if sorted)

A

Array

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

Accessing Time: O(1), because elements are stored at contiguous locations

A

Array

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

Insertion Time: O(n), the worst case occurs when insertion happens at the beginning of the structure which then requires shifting all of the other elements

A

Array

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

Deletion Time: O(n), the worst case occurs when deletion happens at the beginning of the structure which then requires shifting all of the elements

A

Array

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

A data structure where each element is a separate object. Each element is comprised of two items – the data and a reference to the next node.

A

Linked list

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

In this type of linked list, every node stores the address / reference of next node. The last node’s reference is NULL.

For example 1->2->3->4->NULL

A

Singly linked list

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

In this type of Linked list, there are two references associated with each node. One that points to the next node and one that points to the previous node.

For example NULL23->NULL

A

Doubly Linked List

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

Advantage of this linked list data structure is that we can traverse in both directions and for deletion we don’t need to have explicit access to previous node.

A

Doubly Linked List

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

A linked list where all nodes are connected in either a singly linked list or doubly linked list.

A

Circular linked list

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

Advantage of this linked list data structure is that any node can be the starting node.

A

Circular linked list

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

Accessing time: O(n)
Search time: O(n)
Insertion of an Element : O(1), if we are at the position where we have to insert an element
Deletion of an Element : O(1), if we know the address of the node previous the node to be that is to be deleted.

A

Linked list

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

Eliminates unused memory when compared to an Array as nodes are only added when a new element is introduced.

A

Linked list

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

Insertions and deletions are easier when compared to an array because there is not need to shift elements.

A

Linked list

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

One big drawback of this data structure is that random access is not allowed. Unlike arrays, where we can access the n’th element in O(1) time. In this data structure, it would take O(n) time.

A

Linked list

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

An abstract data type that serves as a collection of elements, with two principal operations: push, which adds an element to the collection, and pop, which removes the last element that was added. Both operations take place at the top end of the structure and it can be implemented by using both an array or a linked list.

A

Stack

17
Q

Insertion : O(1)
Deletion : O(1)
Access Time : O(n), worst case
Insertion and Deletion are only allowed on one end.

A

Stack or LIFO

18
Q

A data structure used for maintaining function calls (the last called function must finish execution first). We can always remove recursion with the help of a __________. They are also used in cases where we have to reverse a word or to implement back functionality in web browsers.

A

Stack

19
Q

An abstract data structure that serves as a collection of elements, with two principal operations: enqueue, the process of adding an element to the end of collection, and dequeue, the process of removing the first element in the collection. It can be implemented by using an array or a linked list.

A

Queue or FIFO

20
Q

A data structure that best handles any situation where resources are shared among multiple users and served on first come first server basis. Examples include CPU scheduling, Disk Scheduling.

A

Queue

21
Q

Arrays, Linked Lists, Stack and queues

A

Linear data structures

22
Q

Hierarchical data structures

A

Trees

23
Q

A data structure in which each node has at most two children, which are referred to as the left child and the right child. It is implemented mainly using Links.

A

Binary Tree

24
Q

A _______ is represented by a pointer to the topmost node. If the _______ is empty, then the value of root is NULL.

A _______ node contains the following parts:

  1. Data
  2. Pointer to left child
  3. Pointer to right child
A

Binary Tree

25
Q

A __________ can be traversed in two ways:

1) Depth First Traversal: Inorder (Left-Root-Right), Preorder (Root-Left-Right) and Postorder (Left-Right-Root)
2) Breadth First Traversal: Level Order Traversal

A

Binary Tree

26
Q

These data structures are useful for hierarchal objects or file structures where each file is located in a particular directory and there is a specific hierarchy associated with files and directories.

A

Binary Tree