User contributions
Jump to navigation
Jump to search
- 18:27, 20 September 2020 diff hist +992 N 4.21 Created page with "the general form of this problem is to find the kth largest value. finding the median is when k = n/2. to find the kth largest value, * select a partition element and split..." current
- 18:26, 20 September 2020 diff hist +900 N 4.19 Created page with "1) Finding the maximum element is O(1) in both a max-heap (the root of the heap) and a sorted array (the last element in the array), so for this operation, both data structure..." current
- 18:25, 20 September 2020 diff hist +539 N 4.17 Created page with "Scan through the array to build an out-of-order heap, that is, the first element is indeed the smallest, but necessarily any of the other elements. This takes us O(n). Then ex..." current
- 18:25, 20 September 2020 diff hist +23 N 4.15 Created page with " Back to Chapter 4" current
- 18:25, 20 September 2020 diff hist +23 N 4.13 Created page with " Back to Chapter 4" current
- 18:24, 20 September 2020 diff hist +3,256 N 4.11 Created page with "Note that there can be at most one element which appears more than n/2 (i.e. at least ceil(n/2) ) times in the list. If we now consider the *sorted* version of the list, we'l..." current
- 18:23, 20 September 2020 diff hist -19 4.9 current
- 18:23, 20 September 2020 diff hist +3,167 N 4.9 Created page with "Here the main thing to notice is that we need a O(<math>n^{k-1}logn</math>) solution. <br /> For various values of k, <br /> k Solution Time Complexity <br /> 1 O..."
- 18:22, 20 September 2020 diff hist +23 N 4.7 Created page with " Back to Chapter 4" current
- 18:21, 20 September 2020 diff hist +250 N 4.5 Created page with "O(nlogn) solution: : sort the array first, : scan the array, keep updating a max_so_far counter. O(n) solution: : put each value into hash map with the value as key and fre..." current
- 18:20, 20 September 2020 diff hist +354 N 4.3 Created page with "<pre> Algo - If we create pair of (min1, max2n) (min1, max2n-1)... will provide optimal result 1) Sort the set of 2n element (n log n) 2) Now assign two pointers Start: A[..." current
- 18:20, 20 September 2020 diff hist +3 4.1 current
- 18:20, 20 September 2020 diff hist +200 N 4.1 Created page with "Sort it with your favorite nlogn sorting algo. The bottom half is one team, the top half the other. Or much better , partition it with median as pivot . Time complexity O(n)..."
- 18:18, 20 September 2020 diff hist +3,540 N 3.45 Created page with " == Using a Hashtable == Scan the web page word by word and for each one, except the first, take the pair formed by the previous word + the current one. Use that pair as the..." current
- 18:16, 20 September 2020 diff hist +786 N 3.43 Created page with "<pre> 1) Take two pointers Fast and Slow (Slow jumps one step at a time while Fast two step) 2) While (Fast != NULL) if(Fast == Slow) return true;..." current
- 18:14, 20 September 2020 diff hist +151 N 3.41 Created page with "Create a count sort in magazine until you find all the characters of given string. --Max 06:49, 25 June 2010 (EDT) Back to Chapter 3" current
- 18:14, 20 September 2020 diff hist +2,155 N 3.39 Created page with "== Iterative version with three variables == <pre> Node* ReverseList( Node * List ) { Node *temp1 = *List; Node * temp2 = NULL; Node * temp3 = NULL; while ( temp..." current
- 18:12, 20 September 2020 diff hist +453 N 3.37 Created page with "<pre> bool compare(struct node* a, struct node* b) { // 1. both empty -> true if (a==NULL && b==NULL) return(true); // 2. both non-empty -> compare them else if (a!..." current
- 18:11, 20 September 2020 diff hist -4 Chapter 3 →Interview Problems
- 18:10, 20 September 2020 diff hist +81 N 3.35 Created page with "Sort the shirts by color and do a binary search on color. Back to Chapter 3" current
- 18:09, 20 September 2020 diff hist +23 N 3.33 Created page with " Back to Chapter 3" current
- 18:08, 20 September 2020 diff hist +285 N 3.31 Created page with "Init: k=0 Insert X: k = k+1; A[X] = k; B[k] = X; Search X: return (A[X] < k) and (B[A[X]] == X) Delete X: A[B[k]] = A[X]; B[A[X]] = B[k]; k = k-1; Ple..." current
- 18:08, 20 September 2020 diff hist +1,323 N 3.29 Created page with "In each node of a binary tree store the sub tree sum for the left sub tree. #''Add'': while descending the tree to the left update the sub tree sum by adding the value #''Ins..." current
- 18:06, 20 September 2020 diff hist +417 N 3.27 Created page with "Let's put into the black box whole set <math>S=\{x_i\}_{i=1}^n</math>. If <math>bb(S)</math> is True, then such a subset exists and we can go on: # R:=S # for i:=1 to n do ##..." current
- 18:06, 20 September 2020 diff hist +23 N 3.25 Created page with " Back to Chapter 3" current
- 18:05, 20 September 2020 diff hist +23 N 3.23 Created page with " Back to Chapter 3" current
- 18:05, 20 September 2020 diff hist +657 N 3.21 Created page with "Since all the elements in S2 have keys larger than the keys of the elements in S1, those two trees can be subtrees of one tree whose root node will have a key larger than the..." current
- 18:04, 20 September 2020 diff hist +444 N 3.19 Created page with "Store two values, the maximum and minimum. These need to be checked and potentially updated on every delete. If the minimum is being deleted, call the successor, update the..." current
- 18:03, 20 September 2020 diff hist +23 N 3.17 Created page with " Back to Chapter 3" current
- 18:03, 20 September 2020 diff hist +23 N 3.15 Created page with " Back to Chapter 3" current
- 18:02, 20 September 2020 diff hist +23 N 3.13 Created page with " Back to Chapter 3" current
- 18:02, 20 September 2020 diff hist +205 N 3.11 Created page with "Since 1,2,...,n is finite, use a bit array to represent them.<br> See the telephone number sorting example in Column 1 of <Programming Pearls> (Jon Bentley) for detailed expla..." current
- 18:00, 20 September 2020 diff hist +23 N 3.9 Created page with " Back to Chapter 3" current
- 17:59, 20 September 2020 diff hist +23 N 3.7 Created page with " Back to Chapter 3" current
- 17:59, 20 September 2020 diff hist 0 3.5 current
- 17:59, 20 September 2020 diff hist +173 N 3.5 Created page with "1. size 4 array with 3 elements. remove 1, insert 1, and so forth. <br> 2. when the array is one-fourth full, shrink its size to half of what it was. Back to Chaprer 3"
- 17:57, 20 September 2020 diff hist +4,259 N 3.3 Created page with "'''C''' <pre> typedef struct Node { char *value; struct Node *next; } Node; int reverse(Node **head) { Node *curr, *prev, *next; if (!head || !(*head)) {..." current
- 17:56, 20 September 2020 diff hist +3,596 N 3.1 Created page with "You just need to maintain a count, like so: <pre> public static boolean isBalanced(String str) { int count = 0; for (int i = 0, n = str.length(); i < n;..." current
- 20:48, 19 September 2020 diff hist +1,166 Chapter 4 →Interview Problems
- 20:44, 19 September 2020 diff hist +1,679 Chapter 4 →Implementaion Challenges
- 20:42, 19 September 2020 diff hist +1,302 Chapter 4 →Searching
- 20:37, 19 September 2020 diff hist +650 Chapter 4 →Lower Bounds
- 20:34, 19 September 2020 diff hist +2,671 Chapter 4 →Other Sorting Alogrithims
- 19:58, 19 September 2020 diff hist +1,260 Chapter 4 →Mergesort
- 19:52, 19 September 2020 diff hist +2,911 Chapter 4 →Quicksort
- 19:39, 19 September 2020 diff hist +1,157 Chapter 4 →Heaps
- 19:36, 19 September 2020 diff hist +13 Chapter 4 →Applications of Sorting: Intervals and Sets
- 19:35, 19 September 2020 diff hist +2,099 Chapter 4 →Applicatoins of Sorting: Intervals and Sets
- 18:52, 19 September 2020 diff hist +7 Chapter 4 →Applications of Sorting: Numbers
- 18:52, 19 September 2020 diff hist +2,831 Chapter 4 →Applications of Sorting: Numbers