Question

In: Computer Science

QUESTION 1 1.   We can solve memory leaks with        some form of garbage collection...

QUESTION 1
1.   We can solve memory leaks with
       some form of garbage collection such as mark-sweep or reference counters
       some form of garbage collection such as tombstones or lock-and-keys
       using a tombstone or mark-sweep approach to the dangling pointer problem
       using a tombstone or lock and keys approach to the dangling pointer problem
QUESTION 2
1.   Pointers (and/or reference) types are necessary in modern programming languages because
       they provide the means to access and manipulate dynamic storage
       they aid readability and reliabilty
       otherwise everyone would be able to program
       they are easy to use and easy to get right
QUESTION 3
1.   What collection-type data type is most useful with data values that are heterogeneous and may be processed differently?
       associative arrays
       arrays
       hashes
       record data types
QUESTION 4
1.   Booleans are NOT stored as a single bit because
       a single bit cannot be accessed efficiently on many machines
       simpler for the programmer to use a byte rather than a bit
       simpler for the compiler writer to use a byte rather than a bit
       space efficiency is better when using bytes
QUESTION 5
1.   Why is decimal a preferred type in financial calculations?
       financial firms have lots of money and wanted their own type
       decimal is a simpler encoding
       decimal encodes exact amounts whereas float and double are approximations
       it's a smaller format

Solutions

Expert Solution

In case of any queries, please revert back.

QUESTION 1 :- We can solve memory leaks with
A.) Some form of garbage collection such as mark-sweep or reference counters [mark and sweep are effective but not for memory leaks]
B.) Some form of garbage collection such as tombstones or lock-and-keys [These are the most common ways to solve memory errors such as memory leaks. In Tombstone,A copy of Memory Stack is kept safe. Hwever they take extra memory.]
C.) Using a tombstone or mark-sweep approach to the dangling pointer problem[mark and sweep are effective but not for memory leaks.]
d. ) Using a tombstone or lock and keys approach to the dangling pointer problem [ANSWER: Smart pointers are often used along with these to solve the problem of memories like memory allocation.]

QUESTION 2 :- Pointers (and/or reference) types are necessary in modern programming languages because
A.)  they provide the means to access and manipulate dynamic storage [ANSWER : This is because main function of pointers is to provide the handling of control of memory to the users.]
B.) they aid readability and reliabilty[They dont aid readability at all]
C.) otherwise everyone would be able to program [Silly Option!]
D) they are easy to use and easy to get right[Pointers add an unnecessary overhead and complication. So, this is not right.]

QUESTION 3 :- What collection-type data type is most useful with data values that are heterogeneous and may be processed differently?
A.) associative arrays [This is a type of Map and stores relation of one data type to other]
B.) arrays[They store all the elements of the same datatype and so are homogeneous]
C.) hashes [Calculated hash codes for the same data type.]
D.) record data types [ANSWER : Can possess different types of data in the same memory location]

QUESTION 4 :- Booleans are NOT stored as a single bit because
A.) a single bit cannot be accessed efficiently on many machines[ANSWER : Byte is often the smallest unit which can be represented by address in memory. Bits cannot be shown in memory and so Booleans are not stored in a single bit.]
B.) simpler for the programmer to use a byte rather than a bit[No, this is a silly option]
C.) simpler for the compiler writer to use a byte rather than a bit [A compiler can process both easily. Main problem is memory allocation ]
D.) space efficiency is better when using bytes[Of course space efficieny is better with bits with lower size]

QUESTION 5 :- Why is decimal a preferred type in financial calculations?
A.) financial firms have lots of money and wanted their own type[Silly Option]
B.) decimal is a simpler encoding [No, encoding of decimal is NOT simple]
C.) decimal encodes exact amounts whereas float and double are approximations [ANSWER : This is the correct option as financial calculations needed precision levels which were not received by fload and double.]
D.) it's a smaller format[No, it is NOT a smaller format than float and doubles relativelty]


Related Solutions

How do we end up creating garbage cells? Give example C++ code. What does garbage collection...
How do we end up creating garbage cells? Give example C++ code. What does garbage collection do? Be specific. Why is it good to use a reference counter in GC? Two advantages.[2] Name a way to avoid fragmentation in allocation of different sizes.
Plese answer the question! 1) What kind of memory technologies do we use as memory hierarchy...
Plese answer the question! 1) What kind of memory technologies do we use as memory hierarchy organization in computers?
Question: How can data collection for diseases be improved? What tools do we need? What are...
Question: How can data collection for diseases be improved? What tools do we need? What are medical intelligence and syndromic surveillance, and how are they used or how could they be used?
We decide to speed up the virtual memory system of question 1 by using a translation...
We decide to speed up the virtual memory system of question 1 by using a translation lookaside buffer (TLB). Suppose your memory system has the characteristics shown in the following table. The TLB and cache miss rates indicate how often the requested entry is not found. The main memory miss rate indicates how often page faults occur.                                                                            Memory Characteristics Memory Unit Access Time (Cycles) Miss Rate TLB 1 0.05% Cache 1 2% Main memory 100 0.0003% Hard drive...
1. Consider cash collection items. How can a firm minimize this time and what are some...
1. Consider cash collection items. How can a firm minimize this time and what are some of the costs? Do we worry about this as individuals as well? If so, how? 2. How can capital structure decisions affect the control of a firm? In other words, would the control issues impact your decisions on how to raise money for your company? 3. How can sales be used to develop pro forma financial statements?
1. Describe the purpose of some components in Internal Memory of a computer. 2.  how Cache Memory...
1. Describe the purpose of some components in Internal Memory of a computer. 2.  how Cache Memory functions
With the advancements made in technology we all use some form of it daily. Whether we...
With the advancements made in technology we all use some form of it daily. Whether we are using a computer, smartphone, the internet and social media, etc., these things have been incorporated into our daily living. Most people are required to use some form of technology at work, we are entertained with them and it is the most used form of communication. With that technology and the internet have been very important for companies for the purpose of working, communicating,...
1. Based on what we covered in lecture, how can art be a form of activism?
1. Based on what we covered in lecture, how can art be a form of activism?
In the real time world, in which type of servers can we increase the Cache Memory....
In the real time world, in which type of servers can we increase the Cache Memory. How it would be beneficial for the performance of the server?.
Question 1 (a) Identify the type of information that can beat the market under each form...
Question 1 (a) Identify the type of information that can beat the market under each form of market efficiency. (b) Janet, a junior analyst of an investment bank, kept an eye on the share price of Temcent Company, a fintech company with abundant analysts’ coverage. She noticed that the share price was increased by 10% immediately after the release of annual result announcement. She said to her senior colleague, Ricky, “The share price of Temcent is over-reacted to the result...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT