DSA FINAL LONG QUIZ

0.0(0)
studied byStudied by 7 people
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/63

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

64 Terms

1
New cards

tree data structure

It is a collection of nodes that are

connected by edges and has a hierarchical relationship

between the nodes

2
New cards

root

topmost node of the tree is called the __

3
New cards

child nodes.

the nodes below it are called the __

4
New cards

True

The data in a tree are not stored in a sequential manner i.e.,

they are not stored linearly. T/F

5
New cards

predecessor

The node which is a

__ of a node is called the

parent node of that node.

6
New cards

immediate successor

The node which is the

__ of a node is

called the child node of that node

7
New cards

Leaf Node or External Node:

The

nodes which do not have any child

nodes are called __

8
New cards

siblings.

Children of the same parent

node are called ___

9
New cards

Level of node

The count of edges

on the path from the root node to

that node. The root node has level 0.

10
New cards

Internal node:

A node with at least

one child is called__

11
New cards

Subtree:

Any node of the tree along

with its descendant.

12
New cards

Number of edges:

An edge can be defined as the connection between two

nodes.

13
New cards

Depth of a node:

is defined as the length of the path from

the root to that node.

14
New cards

Height of a node:

can be defined as the length of the

longest path from the node to a leaf node of the tree

15
New cards

Height of the Tree

is the length of the longest path from

the root of the tree to a leaf node of the tree

16
New cards

A general tree

is a tree where each node may

have zero or more children (a binary tree is a

specialized case of a general tree).

17
New cards

General trees

are used to model applications

such as file systems.

18
New cards

Forest tree

can be defined as the set of disjoint trees

which can be obtained by deleting the root node and

the edges which connects root node to the first level

node

19
New cards

Tournament tree

_ are used to record the winner of

the match in each round being played between

two players.

20
New cards

selection

tree or winner tree

Tournament tree can also be called as

21
New cards

Expression trees

_ are used to evaluate the simple

arithmetic expressions

22
New cards

General trees

__ are unordered tree data

structures where the root node has

minimum 0 or maximum ‘n’ subtrees.

23
New cards

Binary Trees

__ are general trees in which

the root node can only hold up to

maximum 2 subtrees

24
New cards

A full binary tree

is a binary tree

type where every node has either

0 or 2 child nodes

25
New cards

A complete binary tree

is a binary tree

type where all the leaf nodes must be on

the same level. However, root and

internal nodes in a complete binary tree

can either have 0, 1 or 2 child nodes

26
New cards

A perfect binary tree

is a binary tree

type where all the leaf nodes are on

the same level and every node

except leaf nodes have 2 children

27
New cards

Tree traversal

is the process of visiting each node in the tree exactly once.

28
New cards

IN-ORDER TRAVERSAL

Algorithm:

Step 1 − Recursively traverse left subtree.

Step 2 − Visit root node.

Step 3 − Recursively traverse right subtree.

29
New cards

PRE-ORDER TRAVERSAL

Algorithm:

Step 1 − Visit root node.

Step 2 − Recursively traverse left subtree.

Step 3 − Recursively traverse right subtree.

30
New cards

POST-ORDER TRAVERSAL

Algorithm:

Step 1 − Recursively traverse left subtree.

Step 2 − Recursively traverse right subtree.

Step 3 − Visit root node.

D → E → B → F → G → C → A

31
New cards

less

The data in the Binary Search Trees (BST) is always stored in such a way

that the values in the left subtree are always __ than the values in the

root node and the values in the right subtree are always greater than the

values in the root node, i.e. left subtree < root node ≤ right subtree.

32
New cards

greater

The data in the Binary Search Trees (BST) is always stored in such a way

that the values in the left subtree are always less than the values in the

root node and the values in the right subtree are always _ than the

values in the root node, i.e. left subtree < root node ≤ right subtree.

33
New cards

self-balancing,

AVL trees are ___ which means that the tree height is kept to a minimum so that a

very fast runtime is guaranteed for searching, inserting and deleting nodes, with time

complexity O(logn)O(logn)

34
New cards

AVL Trees

__ do rotation operations in addition, to keep the tree balance.

35
New cards

difference

A node's balance factor is the __ in subtree heights.

36
New cards

True

If the balance factor is less than -1, or more than 1, for one or more nodes

in the tree, the tree is considered not in balance, and a rotation operation is

needed to restore balance T/F

37
New cards

Graphs

_ are data structures that consist of nodes or

vertices linked by edges.

38
New cards

vertices(V) and a set of edges(E)

More formally a Graph is composed of a set of

__

39
New cards

G(V, E).

The graph is denoted by _

40
New cards

Nodes/Vertices:

Vertices are the fundamental units

of the graph. Sometimes, vertices are also known as

vertex or nodes. Every node/vertex can be labeled or

unlabelled

41
New cards

Edges/Arcs

Edges are drawn or used to connect two

nodes of the graph. It can be ordered pair of nodes in

a directed graph. Edges can connect any two nodes

in any possible way. There are no rules. Sometimes,

edges are also known as arcs. Every edge can be

labelled/unlabelled.

42
New cards

no direct

If two nodes are not connected by an edge, that means that there is __ connection between

them

43
New cards

= Total number of vertices (nodes) in the graph

|V|

44
New cards

|E|

= Total number of connections (edges) in the graph

45
New cards

directed graphs

In __, edges have a

direction. They go from one node to

another, and there is no way to return to

the initial node through that edge.

Directed Graph.

46
New cards

undirected

In this type of graph, edges are

__ (they do not have a specific

direction). Think of undirected edges as

two-way streets. You can go from one

node to another and return through that

same “path”

47
New cards

weighted graphs

In __, each edge has a value

associated with it (called weight). This

value is used to represent a certain

quantifiable relationship between the nodes

they connect

48
New cards

unweighted graphs

__ do not

have weights associated with their

edges. An example of this type of graph

can be found in social networks, where

edges represent the connection between

two users. The connection cannot be

quantified. Therefore, the edge has no

weight.

49
New cards

null

A graph is known as a null__ graph if there

are no edges in the graph.

50
New cards

Trivial Graph

Graph having only a single vertex, it is

also the smallest graph possible.

51
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.

52
New cards

Directed Graph

A graph in which edge has direction. That is

the nodes are ordered pairs in the definition

of every edge

53
New cards

connected

The graph in which from one node we can

visit any other node in the graph is known as

a __ graph

54
New cards

disconnected graph

The graph in which at least one node is not

reachable from a node is known as a

_

55
New cards

regular graph.

The graph in which the degree of every vertex

is equal to K is called K _

56
New cards

Complete Graph

The graph in which from each node there is

an edge to each other node.

57
New cards

Cycle Graph

The graph in which the graph is a cycle in

itself, the degree of each vertex is 2

58
New cards

Cyclic Graph

A graph containing at least one cycle is

known as a Cyclic graph.

59
New cards

Directed Acyclic Graph

A Directed Graph that does not contain any

cycle

60
New cards

Bipartite Graph

A graph in which vertex can be divided into

two sets such that vertex in each set does not

contain any edge between them

61
New cards

Trees

_ are the restricted types of graphs, just

with some more rules. Every tree will always

be a graph but not all graphs will be

trees

62
New cards

Adjacency Matrix

In this method, the graph is stored in

the form of the 2D matrix where rows

and columns denote vertices.

63
New cards

Adjacency List

This graph is represented as a

collection of linked lists. There is an

array of pointer which points to the

edges connected to that vertex.

64
New cards