Algorithm Exam
Algorithm Exam
Definition
A binary tree is called almost complete, if it is complete except the last
level, and on the last level if a node is in the tree, then all possible
nodes on its left side is in the tree, as well.
Definition
An almost complete tree is called a minimum (maximum) heap, if the
key (= the data in the node) of each node is less (greater) than or equal
to the keys of its children.
11. Prove that every general sorting algorithms have time complexity Ω( 𝑛 ⋅
log 𝑛).
OTHER WAY:
Proof:
Recall that the sorting algorithm must output a permutation of the input [a1,a2,... ,an].
The input is directed graph (G, E), along with special vertex s and t called the source and
vertex.
The maximum flow problem asks for the largest amount of material that can be transported
from s to t.
13. Determine the longest common subsequence of the following two words:
abbaacaabbabcabacb
baabcccbabcbbbabab
Solution:
2. Give the pseudo code of an algorithm to find the minimum and maximum of an array with
(3/2)*n comparisons.