DSA MIDTERMS

5.0(1)
studied byStudied by 0 people
5.0(1)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/126

flashcard set

Earn XP

Description and Tags

DSA Midterms Lessons PUP

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

127 Terms

1
New cards

DATA

“raw facts”,  information, in a form of numbers, text, images, figures, or any other format, structure or unstructured.

2
New cards

STRUCTURE

something arranged in a definite pattern of organization

3
New cards

Data Structures

A specific way of organizing data in a specialized format on a computer so that the information can be organized, processed, stored, and retrieved quickly and effectively.

4
New cards
LINEAR
data elements are arranged sequentially or linearly, where each element is attached to its previous and next adjacent elements. E.g. array, stack, queue, linked list, etc.
5
New cards

NON LINEAR

data elements are not placed sequentially or linearly. In this data structure, we can’t traverse all the elements in a single run only. E.g. data structures are trees and graphs, etc.

6
New cards
STATIC

Static data structure has a fixed memory size. It is easier to access the elements in a static data structure. An example of this data structure is an array.

7
New cards

DYNAMIC

in this data structure, the size is not fixed. It can be randomly updated during the runtime which may be considered efficient concerning the memory (space) complexity of the code. Examples of this data structure are queue, stack, etc

8
New cards
HOMOGENOUS

this data structures consist of the same data element type, like element collections found in an array.

9
New cards

NON HOMOGENOUS

the data don’t have to be the same type, such as Linked List.

10
New cards
DATA TYPE
is a classification, or attribute of data which tells the compiler or interpreter how the programmer intends to use the data
11
New cards
Importance of Data Structures
EFFICIENCY, FLEXIBILITY, SCALABILITY
12
New cards

Arrays

is a collection of items of same data type stored at contiguous memory locations.

13
New cards
Array Index
In an array, elements are identified by their indexes. Array index starts from 0.
14
New cards

Array element

are items stored in an array and can be accessed by their index.

15
New cards

Array Length

is determined by the number of elements it can contain.

16
New cards

One dimensional array

You can imagine a 1d array as a row, where elements are stored one after another.

17
New cards

Two-dimensional array

Multidimensional arrays can be considered as an array of arrays or as a matrix consisting of rows and columns.

18
New cards

Three dimensional array

  A Multidimensional array    contains          three dimensions, so it can be considered an array of two-dimensional arrays.

19
New cards
Types of Array Operations
Traversal, Insertion, Deletion, Searching, Sorting
20
New cards
Linked List
is a linear data structure, in which elements are not stored at a contiguous location, rather they are linked using pointers.
21
New cards
Node Structure
data & next pointer
22
New cards
Head and Tail
The linked list is accessed through the head node, which points to the first node in the list. The last node in the list points to NULL or nullpointer, indicating the end of the list. This node is known as the tail node.
23
New cards
Types of Linked List
Singly linked list, Double Linked List, Circular Linked List
24
New cards

Single linked list

each node contains a reference to the next node in the sequence. Traversing a ____ linked list is done in a forward direction.

25
New cards
Double Linked List
each node contains references to both the next and previous nodes. This allows for traversal in both forward and backward directions, but it requires additional memory for the backward reference.
26
New cards
Circular Linked List
the last node points back to the head node, creating a circular structure. It can be either singly or doubly linked.
27
New cards
Types of Linked List Operations
Insertion, Deletion, Searching and Traversing
28
New cards

Insertion

Adding a new node to a linked list involves adjusting the pointers of the existing nodes to maintain the proper sequence. can be performed at the beginning, end, or any position within the list.

29
New cards

Deletion

Removing a node from a linked list requires adjusting the pointers of the neighboring nodes to bridge the gap left by the deleted node. can be performed at any position within the list.

30
New cards
Searching and Traversing
Searching for a specific value in a linked list involves traversing the list from the head node until the value is found or the end of the list is reached.
31
New cards
Stack

is a linear data structure that follows a particular order in which the operations are performed. The order may be LIFO (Last In First Out) or FILO(First In Last Out).

32
New cards
LIFO (Last In First Out)
implies that the element that is inserted last, comes out first.
33
New cards
FILO(First In Last Out)
implies that the element that is inserted first, comes out last
34
New cards
fixed size stack
has a fixed size and cannot grow or shrink dynamically. If the stack is full and an attempt is made to add an element to it, an overflow error occurs.
35
New cards

Dynamic Sized Stack

this stack can grow or shrink dynamically. When the stack is full, it automatically increases its size to accommodate the new element, and when the stack is empty, it decreases its size

36
New cards

Types of Stack Operations

push(), pop(), top(), isEmpty(), size()

37
New cards
push()
To insert an element into the stack.
38
New cards
pop()
To remove an element from the stack.
39
New cards
top()
Returns the top element of the stack.
40
New cards
isEmpty()
Returns true if stack is empty else false.
41
New cards
size()
Returns the size of stack.
42
New cards

Array-based implementation

the push operation is implemented by incrementing the index of the top element and storing the new element at that index

43
New cards

Linked list based implementation

the push operation is implemented by creating a new node with the new element and setting the next pointer of the current top node to the new node

44
New cards
QUEUES
is defined as a linear data structure that is open at both ends and the operations are performed in First In First Out (FIFO) order.
45
New cards
Types of Queue
Input Restricted, Output Restricted, Circular Queue, Double Ended, Priority Queue
46
New cards
Input Restricted Queue
This is a simple queue. In this type of queue, the input can be taken from only one end but deletion can be done from any of the ends.
47
New cards
Output Restricted Queue
This is also a simple queue. In this type of queue, the input can be taken from both ends but deletion can be done from only one end.
48
New cards
Circular Queue
This is a special type of queue where the last position is connected back to the first position. Operations are performed in FIFO order.
49
New cards

Double Ended Queue (Dequeue)

In a ____________ the insertion and deletion operations, both can be performed from both ends.

50
New cards

Priority Queue

is a special queue where the elements are accessed based on the priority assigned to them.

51
New cards
Types of Queue Operations
Enqueue(), Dequeue(), Peek(), rear(), isFull(), isNull()
52
New cards

Enqueue()

Adds (or stores) an element to the end of the queue.

53
New cards

Dequeue()

Removal of elements from the queue.

54
New cards
Peek() or front()
Acquires the data element available at the front node of the queue without deleting it.
55
New cards

rear()

This operation returns the element at the rear end without removing it.

56
New cards

isFull()

Validates if the queue is full.

57
New cards

isNull()

Checks if the queue is empty.

58
New cards
Sequential allocation
A queue can be implemented using an array. It can organize a limited number of elements.
59
New cards
Linked list allocation
A queue can be implemented using a linked list. It can organize an unlimited number of elements.
60
New cards
Multi programming
When multiple programs are running in the main memory.
61
New cards
Network
a queue is used in devices such as a router or a switch. another application of a queue is a mail queue which is a directory that stores data and controls files for mail messages.
62
New cards
Job Scheduling
The computer has a task to execute a particular number of jobs that are scheduled to be executed one after another.
63
New cards
Shared resources
Queues are used as waiting lists for a single shared resource.
64
New cards

TREE

this data structure is a hierarchical structure that is used to represent and organize data in a way that is easy to navigate and search.

65
New cards

Parent Node

The node which is a predecessor of a node is called the _____ node of that node. {B} is the parent node of {D, E}.

66
New cards

Child Node

The node which is the immediate successor of a node is called the ____ node of that node. Examples

67
New cards

Root Node

The topmost node of a tree or the node which does not have any parent node is called the ______. {A} is the _________ of the tree. A non-empty tree must contain exactly one root node and exactly one path from the root to all other nodes of the tree.

68
New cards

Leaf Node or External Node

The nodes which do not have any child nodes are called ___ nodes. {K, L, M, N, O, P} are the leaf nodes of the tree.

69
New cards

Ancestor of a Node

Any predecessor nodes on the path of the root to that node are called ____ of that node. {A,B} are the ancestor nodes of the node {E}.

70
New cards

Descendant

Any successor node on the path from the leaf node to that node. {E,I} are the _____ of the node {B}.

71
New cards

Sibling

Children of the same parent node are called ___. {D,E} are called ___.

72
New cards
Level of a node
The count of edges on the path from the root node to that node. The root node has level 0.
73
New cards

Internal node

A node with at least one child is called _____ Node.

74
New cards

Neighbour of a Node

Parent or child nodes of that node are called _____ of that node.

75
New cards
Subtree
Any node of the tree along with its descendant
76
New cards

Types of Tree

BINARY, TERNARY, N-ary/Generic Generic

77
New cards

BINARY

In this tree, each node can have a maximum of two children linked to it.

78
New cards

TERNARY

is a tree data structure in which each node has at most three child nodes, usually distinguished as “left”, “mid” and “right”

79
New cards

N-ary/Generic

this tree are a collection of nodes where each node is a data structure that consists of records and a list of references to its children (duplicate references are not allowed).

80
New cards
Types of Tree Operations
Create, Insert, Search, Traversal
81
New cards

Create

Create a tree in the data structure.

82
New cards

Insert

 Inserts data in a tree.

83
New cards

Search

Searches specific data in a tree to check whether it is present or not.

84
New cards

Preorder Traversal

Traveling a tree in a pre order manner in the data structure.

85
New cards

In order Traversal

Traveling a tree in an in-order manner

86
New cards

Post order Traversal

Traveling a tree in a post-order manner.

87
New cards

GRAPH

is a non-linear data structure consisting of vertices and edges.

88
New cards
Components of Graph
VERTICES & EDGES
89
New cards

VERTICES

are the fundamental units of the graph. Sometimes, ______ are also known as vertex or nodes. Every node/vertex can be labeled or unlabeled.

90
New cards

EDGES

are drawn or used to connect two nodes of the graph. It can be ordered pair of nodes in a directed graph.

91
New cards

Null Graph

A graph is known as a ___ graph if there are no edges in the graph.

92
New cards

Trivial Graph

Graph having only a single ____, it is also the smallest graph possible.

93
New cards
Undirected Graph
A graph in which edges do not have any direction. That is the nodes are unordered pairs in the definition of every edge.
94
New cards
Directed Graph
A graph in which edge has direction. That is the nodes are ordered pairs in the definition of every edge.
95
New cards

Connected Graph

The graph in which from one node we can visit any other node in the graph is known as a ____ graph.

96
New cards

Disconnected Graph

The graph in which at least one node is not reachable from a node

97
New cards

Regular Graph

The graph in which the degree of every vertex is equal to K is called K ____ graph.

98
New cards
Complete Graph
The graph in which from each node there is an edge to each other node.
99
New cards
Cycle Graph
The graph in which the graph is a cycle in itself, the degree of each vertex is 2.
100
New cards

Cyclic Graph

A graph containing at least one cycle is known as a ____ graph.