There are two direction for us to solve this problem. (1) Recursion Recursive step: T[0] conbines with findsubsets(T[1:]) Final step: if len(T)==0: return [[]] Code: #Recursive method def findsubsets(T): if len(T)==0: return [[]] answer=[] for sets i…
I collect and make up this pseudocode from the book: <<Introduction to the Design and Analysis of Algorithms_Second Edition>> _ Anany Levitin Note that throughout the paper, we assume that inputs to algorithms fall within their specified range…
About Cache Eviction Algorithms A cache eviction algorithm is a way of deciding which element to evict when the cache is full. In Ehcache , the memory store and the off-heap store might be limited in size. When these stores get full, elements are evi…
(referrence: GeeksforGeeks, Kth Largest Element in Array) This is a common algorithm problem appearing in interviews. There are four basic solutions. Solution 1 -- Sort First A Simple Solution is to sort the given array using a O(n log n) sorting alg…
本博客的代码的思想和图片参考:好大学慕课浙江大学陈越老师.何钦铭老师的<数据结构> 代码的测试工具PTA File Transfer 1 Question 2 Explain First, we will put N elements in a array,the elements is from 1 to N.The element in the array stand for the number of computer. C1 stand for a computer and C2 s…
Sort a linked list using insertion sort. A graphical example of insertion sort. The partial sorted list (black) initially contains only the first element in the list.With each iteration one element (red) is removed from the input data and inserted in…
Sort a linked list using insertion sort. A graphical example of insertion sort. The partial sorted list (black) initially contains only the first element in the list.With each iteration one element (red) is removed from the input data and inserted in…
Majority Number 原题链接:http://lintcode.com/en/problem/majority-number/# Given an array of integers, the majority number is the number that occurs more than half of the size of the array. Find it. Example For [1, 1, 1, 1, 2, 2, 2], return 1 Challenge O(…