Introduction to Algorithms
3rd Edition
ISBN: 9780262033848
Author: Thomas H. Cormen, Ronald L. Rivest, Charles E. Leiserson, Clifford Stein
Publisher: MIT Press
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 11.3, Problem 2E
Program Plan Intro
To apply the division method to compute the hash value of the character string without using more than a constant number of words of storage outside the string itself.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Let B be the set of all binary strings of length 8. {“00000000”, “00000001”, … “11111110”, “11111111”}
How many elements of B have no adjacent digits with the same value?
How many elements of B are palindromes?
How many elements of B contain two or more 0s?
In Lamport's Hash we mentioned the notion of
using only 64 bits of the hash. At each stage, 128 bits
are computed, 64 bits are thrown away, and the hash of
the retained 64 bits is used in the next stage. The
purpose of only using 64 bits is so that a human does not
need to type as long a string. Assuming the person will
still only type 64 bits, does it work if hashn does a hash
of all 128 bits of hashn-1, but what the person actually
transmits is 64 bits of the result?
A common implementation of sequential files on disk has each block point to its successor, which may be any block on the disk. This method requires a constant amount of time to write a block (as the file is originally written), to read the first block in the file, and to read the ith block, once you have read the 1 - 1” block. Reading the lth block therefore requires time proportional to 1. Show how by adding just one additional pointer per node, you can keep all the other properties, but allow the lth block to be read in time proportional to log I. [Hint: heaps have implicit pointers from node I to what other nodes?] Explain what the algorithm for reading the th block has in common with an algorithm for raising a number to the ith power in time proportional to log 1.
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- You are the sysadmin for a big tech company, and you have to estimate the amount of servers you need to handle some long-running jobs. One server can handle only one job at once. One job can only be executed by one server at once. Once a server has finished executing its current job, it can be reassigned to a new job. Given an array of time intervals intervals where intervals[i] = [starti, endi], representing the start and end time for a particular job that needs to be executed, return the minimum number of servers required to run all jobs. Constraints: 1 <= intervals.length <= 104 0 <= starti < endi <= 106 Function definition for Java: public int minMeetingRooms(int[][] intervals) { // Your code here } Function definition for Python: def minMeetingRooms(self, intervals: List[List[int]]) -> int: #Your code here Announced Test Cases: Input: intervals = [[0,30],[5,10],[15,20]] Output: 2Explanation: We need one server for the job that starts at 0. For the job…arrow_forwardThe Reflection algorithm can be used to encrypt a C-string (character array terminated with the null character) before it is transmitted over the Internet. The Reflection algorithm works as follows: Each letter in the message is converted to the letter in that is 13 positions to the right of that letter in the English alphabet. If the end of the alphabet is reached, counting continues from the first letter in the alphabet. The case of the letters must be maintained. For example,'M' →'Z', 'x' → 'k', 'A' → 'N'The numeric characters ('0' to '9') are shifted 5 positions to the right of that number in the character set '0' to '9'. If ‘9’ is reached, counting continues from ‘0’. For example,'0' → '5', '2' →'7', '8' → '3' All other characters are left as they are. a) What would the following string be encrypted to by the Reflection algorithm?“Call me at 662-2002 Ext 85393” b) Write a function, getPosition, which finds the position of a letter in the alphabet regardless of the case of the…arrow_forwardWe can generalize two-pass multiway merge-sort to use more than two passes. On the first pass, we divide the file into as many groups as we can merge in one pass. Then, recursively sort each group, using as many passes as necessary, and finally merge the sorted groups.A file of 1000 blocks is to be externally sorted, using 40 main-memory buffers. How many passes are needed? How many runs remain at the last pass? Find the correct number in the list below. a) The number of passes required is 2.b) The number of passes required is 3.c) The number of runs at the last pass is 10.d) The number of passes required is 1.arrow_forward
- Given two arrays X and Y of positive integers, find the number of pairs such that xy > yx (raised to power of) where x is an element from X and y is an element from Y. Example 1: Input: M = 3, X[] = [2 1 6] N = 2, Y[] = [1 5]Output: 3Explanation: The pairs which follow xy > yx are as such: 21 > 12, 25 > 52 and 61 > 16 .Example 2: Input: M = 4, X[] = [2 3 4 5]N = 3, Y[] = [1 2 3]Output: 5Explanation: The pairs for the given input are 21 > 12 , 31 > 13 , 32 > 23 , 41 > 14 , 51 > 15 . Your Task:This is a function problem. You only need to complete the function countPairs() that takes X, Y, M, N as parameters and returns the total number of pairs. Expected Time Complexity: O((N + M)log(N)).Expected Auxiliary Space: O(1). Constraints:1 ≤ M, N ≤ 1051 ≤ X[i], Y[i] ≤ 103arrow_forwardConsider the following problem on a dictionary of n words, W1...Wn, each with exactly k characters. You can transform a word Wi into word Wj if they differ in at most d≤k characters. (both dd and kk are specified as part of the input, along with n and the words) For example, if the dictionary is: W1 = 'hit', W2 = 'cog', W3 = 'hot', W4 = 'dot', W5 = 'dog', W6 = 'lot', W7 = 'log', and d=1d=1, one way to change 'hit' to 'cog' is: 'hit' →→ 'hot' →→ 'dot' →→ 'dog' →→ 'cog'. We want to find the fewest number of steps to transform W1 to W2. Q1.1 I claim that this problem be formulated as a shortest path problem. Please provide a strategy to formulate this as the shortest path problem and give a graph visualization of the problem Q1.2 Show that your graph (in Q 1.1) can be constructed in O(n^2) time, and its size is up to O(n^2).arrow_forwardWhat is the runtime of Radix Sort when sorting a list of N names? Each name has the same number of letters, k. Each letter is encoded using 8 bit, so there are c=256 different symbols. O(k) O O(N) O(k * N) O(c * N) O(N^2) O(N+k) O O(N log N)arrow_forward
- Given a collection of numbers that might contain duplicates,return all possible unique permutations.For example,[1,1,2] have the following unique permutations:[ [1,1,2], [1,2,1], [2,1,1]]""" def permute_unique(nums): perms = [[]] for n in nums: new_perms = [] for l in perms: for i in range(len(l)+1): new_perms.append(l[:i]+[n]+l[i:]).arrow_forwardA frequently used hash family is the matrix multiplication hash family that we have introduced in class. Suppose we have n buckets {1, 2, ..., n}, we will use a binary string of length b = log₂ n to index each bucket. (For example, if we have 4 buckets, they will be indexed as 00, 01, 10, 11.) Now, we would like to hash a u-bit binary string x into the hash table (For example, x could be an 8-bit string 10100110). To hash this u-bit string x into a bucket, we use the hash function hд(x) = (Ax)mod 2, where A is a b x u dimensional binary matrix, and x is a u × 1 dimensional column vector. As a result, h(x) will be a b × 1 dimensional vector which shows the bucket index that x will be hashed to. (For example, x is an 8-bit string [10100110]™, and A is a [1 0 1 1 0 0 0 then h₁(x) ) = (Ax)mod 2 = 2 × 8 dimensional matrix [ 0 1 1 0 1 0 1 [1, 0], which means that x will be hashed to bucket 2.) Prove that the above hash function h₁(x) = (Ax)mod 2 is a universal hash family. [Hint: Consider…arrow_forwardRecall, by 15-bit strings, we mean strings of binary digits, of length 15. a. How many 15-bit strings are there total? b. How many 15-bit strings have weight 6? c. How many subsets of the set {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15} contain exactly 6 elements? A ▶ FIarrow_forward
- Encryption methods, such as the Caesar Cipher encryption, allow us to encrypt and decrypt text using a special key. Another method of encrypting text / passwords is called hashing. Hashing uses special algorithms to 'scramble' the text, which is tougher to be hacked. The hash function can take numbers, letters, and symbols as input, then the function applies one of the special algorithms to output the scrambled text. The longer the output string is, the harder to hack the hashed data. The difference between hashing and the Caesar Cipher encryption is that one cannot 'decrypt' a hashed data to its original text. Since a hashed data cannot be decrypted, a user must enter the original text, which will be hashed by the program. Then the program compares the hashed value with the hashed data stored previously for the original text. A salt is used, at times, to create a random sequence that is added to the original text before using the hashing algorithm. This can help prevent the Brute…arrow_forwardg. If you have 1024 Bytes of memory, what is the maximum length of the linked list of integers that you can create. You can assume that full memory can be used for creating the linked list. Answer:arrow_forwardConsider a 64-bit hash function H(x). Describe an efficient algorithm allowing you to find a pair of messages M, M0 such that H(M) = H(M0 ). Describe what resources (i.e. time and memory complexity) it would require to find such a pairarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education