Professional Documents
Culture Documents
Name: Munia Akter ID: 181-35-2293 Section: B
Name: Munia Akter ID: 181-35-2293 Section: B
Name: Munia Akter ID: 181-35-2293 Section: B
ID : 181-35-2293
Section: B
int merge(int *arr1, int len1, int *arr2, int len2, int *arr) {
int i = 0, j = 0, k = 0;
while((j < len1) && (k < len2)) {
arr[i++] = (arr1[j] < arr2[k])?arr1[j++]:arr2[k++];
}
return i;
}
Week 6 :
Graph:
BFS algorithm:
DFS Algorithm:
Step 1: Initialize all nodes to the ready state (STATUS = 1)
Step 2: Put the starting node A onto STACK and change its status to the
waiting state
(STATUS = 2)
Step 3: Repeat Steps 4 and 5 until STACK is empty:
Step 4:
POP the top node N of STACK. Process N and change its status to the
processed state(STATUS=3)
Step 5:
Push onto STACK all neighbors of N that are still in the ready
state(STATUS=1), and change their
Status to the waiting state(STATUS=2).
[End of Step 3 loop]
Step 6: Exit.