DSA Assignment I006
DSA Assignment I006
DSA Assignment I006
Example
1. The computation used to solve the problem is identical for every position
in the data set.
2. The result of the initial computation will depend on the result of the
subsequent computations.
A simple array sum can be accomplished without a stack because the unit
operation (adding the current value to the total) doesnt depend on the results of
the other computations. But if you are summing up nodes in a tree, any node
value is going to be the sum the of the child values. You wont have enough
information to compute this until you compute the children first, so youll need a
stack to remember to come back to this calculation.
a. Trees
Decision Making: To get the Next Move in games. Computer chess
games build a huge tree (training) which they prune at runtime using
heuristics to reach an optimal move.
b. Graphs
Social network graphs: Graphs that represent who knows whom, who
communicates with whom, who influences whom or other relationships
in social structures. An example is the twitter graph of who follows
whom. These can be used to determine how information flows, how
topics become hot, how communities develop, or even who might be a
good match for who, or is that whom.
Website analysis -The best known example is the link graph of the
web, where each web page is a vertex, and each hyperlink a directed
edge. Link graphs are used, for example, to analyze relevance of web
pages, the best sources of information, and good link sites.
c. Stacks
Backtracking (game playing, finding paths, exhaustive searching).
Memory management, run-time environment for nested language
features and expression evaluation.
d. Priority queues
Dijkstras Shortest Path Algorithm using priority queue: When the graph
is stored in the form of adjacency list or matrix, priority queue can be
used to extract minimum efficiently when implementing Dijkstras
algorithm.
Artificial Intelligence: A* Search Algorithm : The A* search algorithm
finds the shortest path between two vertices of a weighted graph, trying
out the most promising routes first. The priority queue (also known as
the fringe) is used to keep track of unexplored routes, the one for which
a lower bound on the total path length is smallest is given highest
priority.
e. Hash tables
Message digests: Say that I decide to upload all of my documents, music,
and videos up to Drop box or Google Drive. I'm thrilled that I won't need
to store 100 GB of files locally on my computer anymore! But, I might be
a little worried: how can I be sure that Drop box or Google isn't
tampering with my files? Hashing provides a clever solution. Before I
upload all of my files to Drop box/Drive, I can compute the hash of each
file. Each hash is typically just a few bytes (merely 32 bytes in the case of
the SHA-256 hash function), so storing hashes for even a million files
won't be a problem.
f. Heap
Order statistics: The Heap data structure can be used to efficiently find
the kth smallest (or largest) element in an array.
There are two types of heap "ascending heap" and "descending heap".
In ascending heap root is the smallest one and in descending heap root
is the largest element of the complete or almost complete binary tree.
So, wherever priority thing need to be implemented, ascending or
descending heap can be used. To create Priority queue, heaps are used.