Kamis, 21 November 2019

Profile

💓💓 Foto kenangan pada jamannya 💓💓

Minggu, 07 Desember 2014

Assignment #6 (Konsep Bahasa Pemrograman)



Review Questions



15. What is an aggregate constant?


Answer: A parenthesized list of values used in initializing arrays is called an aggregate value.


16. What array operations are provided specifically for single-dimensioned arrays in Ada?


Answer: Ada allows array assignments, including those where the right side is an aggregate value rather than an array name.  Ada also provides catenation, specified by the ampersand (&).  Catenation is defined between two single-dimensioned arrays and between a single-dimensioned array and a scalar.  Nearly all types in Ada have the built-in relational operators for equality and inequality.


17. Define row major order and column major order.


Answer:  There are two common ways in which multidimensional arrays can be mapped to one dimension: row major order and column major order.  In row major order, the elements of the array that have as their 1st subscript the lower bound value of that subscript are stored first, followed by the elements of the second value of the first subscript, and so forth.  In column major order, the elements of an array that have as their last subscript the lower bound value of that subscript are stored first, followed by the elements of the second value of the last subscript, and so forth.


18. What is an access function for an array?


Answer: An access function for a multidimensional array is the mapping of its base address and a set of index values to the address in memory of the element specified by the index values.


19. What are the required entries in a Java array descriptor, and when must they be stored (at compile time or run time)?


Answer: In Java all arrays are fixed heap-dynamic arrays.  Once created, these arrays keep the same subscript ranges and storage.  Secondarily, Java supports jagged arrays and not rectangular arrays.  Being a fixed heap-dynamic array the entries will be established and fixed at run time.


20. What is the structure of an associative array?


Answer: An associative array is an unordered collection of data elements that are indexed by an equal number of values called keys. User-defined keys must be stored.









Problem Set



15. What are the arguments for and against Java’s implicit heap storage recovery, when compared with the explicit heap storage recovery required in C++? Consider real-time systems.


Answer: Implicit eliminates the creation of dangling pointers. Disadv: cpu-time to do recovery, sometimes when there’s plenty of heap storage so recovery isn’t necessary.


16. What are the arguments for the inclusion of enumeration types in C#, although they were not in the first few versions of Java?


17. What would you expect to be the level of use of pointers in C#? How often will they be used when it is not absolutely necessary?


18. Make two lists of applications of matrices, one for those that require jagged matrices and one for those that require rectangular matrices. Now, argue whether just jagged, just rectangular, or both should be included in a programming language.


19. Compare the string manipulation capabilities of the class libraries of C++, Java, and C#.


20. Look up the definition of strongly typed as given in Gehani (1983) and compare it with the definition given in this chapter. How do they differ?