목록Coding Algorithm (4)
Jun Hyuk Kim's Blog
Dijkstra is used when we have a graph with weighted connections. First we get a input map of the graph Then we use the input map to make a connection 2d list(INF = non connected value). [0, 4, 8, 24] [INF, 0, 6, INF] [INF, INF, 0, 8] [INF, INF, INF, 0] Next we start with a single node, in this example node 1. for the output we use a single list which represents the min time it takes to get to th..
Double Ended Queues is a linked list that can take both input and output from both ends of the queue. It can be used as a stack or a queue with just a little bit of extra functions. In this page 'double ended queue' will be shortened to 'deque'. The basic Double Ended Queue contains a 'headNode' pointing to the head of the deque, a 'rearNode' pointing to the rear of the deque and a 'queueLen' co..
A min-max heap takes input at time O(logn) and output of max num and min num of O(1). This is a min-max heap with a min root. At the right side we can see the level of the heap. In the max level all the child nodes are smaller than the current one and in the min level all the child nodes are larger than the current one. To insert a value to the heap we add the number to the end of the heap array..
A max heap contains the highest number at the top. Each parent has 2, 1 or 0 childs and the parent always has a higher value than the child. The index 0 is not used to make the child,parent nodes *2(+1), //2. The size will represent the amount of numbers in the heap. In this case 'size = 15' because there are 10 elements in the heap. The length of the heap before the insertion is 10 and the inde..