we are evaluating Write an algorithm to add a new node in ascending lexicographi
ID: 670720 • Letter: W
Question
we are evaluating Write an algorithm to add a new node in ascending lexicographic order by name to a singly linked list. If two or more nodes contain the same name, order the nodes list appears below. Your algorithm must cover every possible case. Assume the list is empty if Pt leftarrow Ohm. We are evaluating the garbage collection algorithms for three programming languages. Language L1 satisfies memory request by sequentially allocating memory from the heap till memory exhausted. When memory is exhausted, it halts the program in execution to resume (essentially like Java/Python). Languages L2 and L3 allow programmers to request memory dynamically also. It is the programmers responsibility however to reclaim memory. Assume two different types of objects with different space requirements. All Objects of the same type required the same amount of memory. Language L2 places all freed blocks on the same (signal) available storage list. Language L3 places blocks of the same type on separate available storage list. Returned memory is used prior to allocating new memory from the heap in both languages L2 and L3. New memory is obtained from the heap using the algorithm developed in class for new memory request (see question 4). Compare and contrast the advantages and disadvantages of the memory schemes for all three languages. In class we developed a dynamic storage using the date structure below. A priority goal was memory reuse. Write the algorithms as developed in class to allocate and reclaim storage assuming all requests for memory are of size "C." Avail leftarrow Ohm, if there are no currently available dynamically allocated nodes for reuse of the paper size. Otherwise Avail points to the first available node on the reuse list.Explanation / Answer
First Language uses Mark-Sweep method.Mark-sweep is a
“stop-theworld” collector, which means that at some point
when the program requests memor y and none is available,
the program is stopped and a full garbage collection is performed
to free up space.The mark-sweep algorithm operates in time linear in
the size of the heap (ie. O(N)). This doesn’t directly tell us how much
overhead it imposes on a program.
Second Language uses semi-space method which is a copying algorithm,
which means that reachable objects are relocated from one address to another during a collection.
Available memory is divided into two equal-size regions called “from-space” and “to-space”.
However, for a given heap size, semi-space requires many more collections than mark-sweep
(since it only has half the space to work with)
Third Language uses an algorithm like mark-sweep, but also re-arrange the
objects to coalesce free-space to avoid fragmentation. This also often has the
benefit of keeping the objects in memory ordered by their allocation time, which typically improves
the locality of reference. Compaction has most of the benefits of the semi-space algorithm
(efficient and reliable allocation), without the cost of the additional memory.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.