0% found this document useful (0 votes)
12 views

greedy Algorithm

The document provides a comprehensive overview of various computer science concepts, including greedy algorithms, dynamic programming, data structures like stacks and heaps, and sorting algorithms. It explains key terms such as hash collision, load factor, and time/space complexity, while also discussing traversal methods like BFS and DFS. Additionally, it covers specialized data structures like AVL trees and B-trees, as well as algorithmic strategies like divide and conquer and backtracking.

Uploaded by

Prabesh Thapa
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

greedy Algorithm

The document provides a comprehensive overview of various computer science concepts, including greedy algorithms, dynamic programming, data structures like stacks and heaps, and sorting algorithms. It explains key terms such as hash collision, load factor, and time/space complexity, while also discussing traversal methods like BFS and DFS. Additionally, it covers specialized data structures like AVL trees and B-trees, as well as algorithmic strategies like divide and conquer and backtracking.

Uploaded by

Prabesh Thapa
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

What is greedy Algorithm?

A greedy algorithm is an approach for solving a problem by selecting


best option available at the moment.
What is Dynamic Programming?
Dynamic Programming is a bottom-up approach we solve all possible
small problems and then combine them to obtain solutions for bigger
problems.
Four applications of Stack
Expression evaluation
Undo/Redo operations
Function calls and recursion
Backtracking Algorithms
What is Hash Collision?
Hash collision occurs when two different inputs produce the same hash
value or hash code.
What is leaftist heap?
A leftist tree, also known as a leftist heap, is a type of binary heap data
structure used for implementing priority queues.
Adaptive Sorting Algorithm
The sorting algorithms in which the order of elements affects the time
complexity of the sorting algorithm is known as an adaptive sorting
algorithm.
Non Adaptive Sorting Algorithm
The sorting algorithms in which the order of elements of the
data doesn’t affect the time complexity of the sorting algorithms are
known as non-adaptive sorting algorithms.
A complete graph contain n(n-1)/2 edges where n is the number of nodes
in the graph.
Non-linear Data Structures: Non-linear data structures are those in which
the data elements are not arranged in a sequential manner. Example
Graphs, Trees

Linear Data Structures: Linear data structures are those in which the data
elements are arranged in a sequential manner. Example Arrays,
LinkedList, Stack, Queue
Why external sorting is slower than internal sorting?
In internal sorting all the data to sort is stored in memory at all times
while sorting is in progress. In external sorting data is stored outside
memory (like on disk) and only loaded into memory in small chunks.
Big O Notation
Big O notation is a mathematical notation used in computer science and
data structures to describe the performance or complexity of an
algorithm. It provides a way to analyze how the runtime or space
requirements of an algorithm scale with respect to the input size.
BFS(Breadth First Search)
BFS is a traversal approach in which we first walk through all nodes on
the same level before moving on to the next level.
DFS(Depth First Search)
DFS is also a traversal approach in which the traverse begins at the root
node and proceeds through the nodes as far as possible until we reach
the node with no unvisited nearby nodes.
Load Factor in Hashing
Load factor refers to the measure of how full a hash table is, expressed
as the ratio of the number of elements stored in the table to the total
number of slots or buckets available in the table.
LF = Number of elements stored / Total number of slots
Best Case Worst Case Average case
The best case of an algorithm refers to the scenario in which the
algorithm performs optimally and achieves the lowest possible time or
space complexity.
The worst case of an algorithm refers to the scenario in which the
algorithm performs the least efficiently, resulting in the highest possible
time or space complexity.
The average case of an algorithm refers to the scenario in which the
algorithm's performance is averaged over all possible inputs of a given
size
A cyclic graph is defined as a graph that contains at least one cycle
which is a path that begins and ends at the same node, without passing
through any other node twice.
Dynamic programming is a technique used in computer programming
and algorithm design to solve optimization problems by breaking them
down into smaller overlapping subproblems.
What is a binomial queue?
A binomial queue is a priority queue that is implemented not as a single
tree but as a collection of heap-ordered trees
A priority queue is an abstract data type that stores a collection of
elements, each associated with a priority.
An algorithm that uses random numbers to decide what to do next
anywhere in its logic is called Randomized Algorithm.
Binary Tree is defined as a tree data structure where each node has at
most 2 children.
The divide and conquer algorithm in data structures involves breaking
down a problem into smaller subproblems, solving them independently,
and then combining the results to obtain the final solution.
A max heap is a binary heap where the value of each node is greater than
or equal to the values of its children
A min heap, on the other hand, is a binary heap where the value of each
node is less than or equal to the values of its children
QuickSort is a sorting algorithm based on the Divide and Conquer
algorithm that picks an element as a pivot and partitions the given array.
An abstract data type (ADT) is a conceptual model for representing data
and the operations that can be performed on that data.
Rehashing is the process of recalculating the hashcode of already stored
entries to move them to another bigger sige hashmap when the threshold
is crossed.
A minimum spanning tree is a spanning tree that has minimum weight
than all other spanning trees of the same graph.
Space Complexity
Space complexity of an algorithm represents the amount of memory
space required by the algorithm in its life cycle.
Time Complexity
Time complexity of an algorithm represents the amount of time required
by the algorithm to run the completion.
Big Oh Notation
The notation is the formal way to express the upper bound of an
algorithm’s running time. It measures the worst case time complexity
An AVL tree defined as a self-balancing Binary Search Tree (BST)
where the difference between heights of left and right subtrees for any
node cannot be more than one.
A backtracking algorithm is a problem-solving algorithm that uses
a brute force approach for finding the desired output.
The Brute force approach tries out all the possible solutions and chooses
the desired/best solutions.
A graph data structure is a collection of nodes that have data and are
connected to other nodes.
B-tree is a special type of self-balancing search tree in which each node
can contain more than one key and can have more than two children
A spanning tree is a sub-graph of an undirected connected graph, which
includes all the vertices of the graph with a minimum possible number
of edges.
A minimum spanning tree is a spanning tree in which the sum of the
weight of the edges is as minimum as possible.
Heapify is the process of creating a heap data structure from a binary
tree

You might also like