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.1, Problem 3E
Program Plan Intro
To implement a direct-address table in which key of stored elements are not distinct and the elements can have satellite data.
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
3. In the StackGuard approach to solving the buffer overflow problem, the compiler inserts a canary value
on the memory location before the retum address in the stack. The canary value is randomly generated.
When there is a return from the function call, the compiler checks if the canary value has been
overwritten or not. Do you think this approach would work? Why or why not?
4. Suppose we want to create a stack of names that vary in length. Why is it advantageous to
store the names in separate areas of memory and then build the stack out of pointers to these
names rather than allowing the stack to contain the names themselves?
Someone tries to fix the stack based buffer overflow problem as follows, is it secure now? why?why not? Are there any other issues within the function's implementation below? Please explain your reasoning.
int bof(char *str, int size)
{
char *buffer = (char *) malloc(size);
strcpy(buffer, str);
return 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
- Someone tries to fix the stack based buffer overflow problem as follows, is it secure now? why? Are there any other issues within the function's implementation below? Explain your reasoning. int bof(char *str, int size) { char *buffer = (char *) malloc(size); strcpy(buffer, str); return 1; }arrow_forwardDevelop a merging implementation based on the following idea to reduce the required extra space to max(M, N/M): For the purpose of simplicity, split the array into N/M blocks of size M and assume that N is a multiple of M. Following that, (i) use selection sort to order the blocks, treating them as items and using their first key as the sort key; and (ii) iterate over the array, merging the first block with the second, the second block with the third, and so on. Develop a merging implementation based on the following idea to reduce the required extra space to max(M, N/M): For the purpose of simplicity, split the array into N/M blocks of size M and assume that N is a multiple of M. Following that, (i) use selection sort to order the blocks, treating them as items and using their first key as the sort key; and (ii) iterate over the array, merging the first block with the second, the second block with the third, and so on. Develop a merging implementation based on the following idea to…arrow_forwardHow does a link-based implementation of the List differ from an array-based implementation? Select one: a. All of these b. A link-based implementation does not need to shift entries over to make room when adding a new entry to the List c. A link-based implementation is sized dynamically so it takes up only the memory to hold the current entries d. A link-based implementation does not need to shift entries up to remove a gap when removing an entry from the Listarrow_forward
- Develop a merging implementation based on the following idea to reduce the required extra space to max(M, N/M): For the purpose of simplicity, split the array into N/M blocks of size M and assume that N is a multiple of M. The blocks are then (i) sorted using selection sort, treated as items, with their first key serving as the sort key, and (ii) iterated over the array, merging the first block with the second, the second block with the third, and so on.arrow_forwardUnderstand the actual allocation of the element of Linked List in main memory. O a. It doesn't need to continuously allocation but it needs to follow up the sequence of the logical view in the list. O b. It is continuously allocation for each element of this linked list. O c. It doesn't need to allocate continuously for each element and they don't follw the original sequence in logical view. O d. It is like array structure but use extra byte for saving an arrowarrow_forwardConsider the following C code snippet. Implement the C code snippet in MIPS assembly language. Use $50 to hold the variable i. Be sure to handle the stack pointer appropriately. The array is stored on the stack of the setArray function // C code void setArraylint num) { int i; int array[10]; for (i = 0; i= 0) return 1; else return 0; } int sub(int a, int b) { return a - b; }arrow_forward
- in c++ In a 2D integer array TD, assume that the row indices range from -3 to 7 and column indices range from 6 to 14. An element TD [-3, 6] stored at address 3220. Find out the dimension of TD and address of an element TD [2, 10], if TD stores the elements in column major order.arrow_forwardPart (a) Write an algorithm for sorting with consideration that n data is stored in linked list. Don't make any assumption just stick to the following instructions: Each node contains an INFO field and a NEXT pointer. Start contains the address of the header node. Don't change any values in the INFO. Part (b) – Consider the given algorithm for insertion of a data at after the given location in linked list. INSLOC(INFO, LINK, START, AVAIL, LOC, ITEM) 1. [OVERFLOW?] If AVAIL = NULL, then Write: OVERFLOW, and Exit // [Remove first node from AVAIL list] 2. Set NEW := AVAIL and 3. AVAIL := LINK[AVAIL] 4. Set INFO[NEW] := ITEM. [Copies new data into node] 5. If LOC = NULL, then: [Insert as first node] Set LINK[NEW]:= START and START : = NEW 6. 7. 8. else: [Insert after node with location LOC] 9. Set LINK[NEW]:= LINK[LOC] and 10. LINK[LOC] := NEW [End of If structure] 11. Exit Answer the following questions: (i) Draw the diagram for the simulation of the above algorithm such that your diagram…arrow_forwardSomeone tries to fix the stack based buffer overflow problem as follows, is it secure now? why? Are there any other issues within the function's implementation below? int bof(char *str, int size) { char *buffer = (char *) malloc(size); strcpy(buffer, str); return 1; }arrow_forward
- Use C++ to implement. The English-Russian dictionary is built as a binary tree. Each component contains an English word, a corresponding Russian word, and a counter for the number of calls to this component. Initially, the tree is formed according to the English alphabet. During the operation of the dictionary, each time the component is accessed, one is added to the access counter. Write a program that: o Provides an initial dictionary entry with specific hit counter values; forms a new representation of the dictionary in the form of a binary tree according to the following algorithm: a) in the old dictionary, the component with the largest value of the access counter is searched; 6) the found component is entered into the new dictionary and removed from the old one; c) go to step a) until the initial dictionary: 0 produces an output of the original and new dictionaries. The program should provide menu-driven dialogue and error control. when enteringarrow_forwardWe've seen that the dynamically-allocated array underlying a std::vector is resized periodically. Propose an algorithm for resizing the array used in the circular array implementation of a queue when it comes time to en queue an element and the array is full. How much larger is your new array? How do the contents of your queue look different than before?arrow_forwardLet us consider a stack implemented with a dynamic array (a.k.a. resizing array) that is initially of size 2, doubles its size when full and halves it size when only 25% full. The stack has 20 million items inserted into it. How many times was its resize() function called?arrow_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