当前位置:天才代写 > 作业代写,留学生作业代写-北美、澳洲、英国等靠谱代写 > ECSE 202代写 软件开发导论代写 test代写

ECSE 202代写 软件开发导论代写 test代写

2021-07-28 17:06 星期三 所属: 作业代写,留学生作业代写-北美、澳洲、英国等靠谱代写 浏览:524

ECSE 202代写

Introduction to Software Development

ECSE 202

ECSE 202代写 1.A map class is written in Java, but the implementation is hidden from the user. She proceeds to conduct an experiment where ···

Part I – Multiple Choice (60 Points)

1.

A map class is written in Java, but the implementation is hidden from the user. She proceeds to conduct an experiment where retrieval times are measured as a function of the number of key-value pairs stored in the map. She concludes that the complexity of the algorithm is O(Log N). Which of the statements below is FALSE?

a. The map could have been implemented using a B-Tree to index the key values.

b. The map could have been implemented using a single sorted array of objects that hold key-value pairs.

c. The map could have been implemented using parallel sorted arrays.

d. The map could have been implemented using a bucket hashing scheme with bucket array size equal to the number of items stored.

e. All statements are TRUE.

Answer: _____

 

2.  ECSE 202代写

Which of the following describes the principal difference between a linked list implemented in Java and one implemented in “C”.

a. Memory deallocation: automatically in Java (garbage collection), manually in “C (free).

b. List size: unlimited in the Java implementation, restricted to available RAM in “C”.

c. Data integrity: lower likelihood of accidentaly deleting list nodes in Java than in “C”.

d. Implementation speed: adding and removing elements is always faster in Java than in “C”.

e. List element: an object in Java, a struct in “C”.

Answer: _____

 

3.

Which of the following operators is not supported (i.e. does not work) in both “C” and Java?

a. ++

b. <<

c. %

d. ?

e. >>>

Answer: _____

 

4.  ECSE 202代写

Consider the following Java class and “C” structure definition:

public class bNode {
int a;
bNode left;
bNode right;
}

struct bNode {
int a;
struct bNode *left;
struct bNode *right;
};

Which of the statements below is the “C” equivalent to bNode node = new bNode();

a. bNode node = (bNode)malloc(sizeof(bNode *));

b. bNode *node = (bNode *)malloc(sizeof(bNode *));

c. bNode node = (bNode)malloc(sizeof(bNode));

d. bNode *node = (bNode *)malloc(sizeof(bNode));

e. bNode node = (bNode)malloc(sizeof(bNode **));

Answer: _____

 

5.

In the class lecture on computational complexity, it was observed that Java programs can exhibit different run times for the same data input. Which of the statements below is the most plausible explanation for this?

a. The Java garbage collector skews the timing.

b. No reasonable explanation is listed.

c. Run time is dependent on where the program is loaded into memory.

d. The Java Virtual Machine is responding to keyboard input.

e. The processor slows down as the workload increases.

Answer: _____

 

6.  ECSE 202代写

When is it preferable to use an ArrayList in place of an array?

a. When speed of operation is important, an ArrayList always provides faster access times than an array.

b. When the size of the array is unknown and access times are not critical.

c. When the array is of a fixed size.

d. When multi-dimensional array indices are required.

e. None of the statements is correct.

Answer: _____

 

7.

Which of the following statements is TRUE regarding a Java instance variable that is declared static, e.g. static int foo; ?

a. It behaves like a regular instance variable except that it is not stored on the heap.

b. A single copy of the variable is created and shared among all instances of the corresponding class.

c. None of these statements is true.

d. All variables in method public static void main() are implicitly static.

e. Memory accesses to static variables are always faster than accesses to variables stored on the stack.

Answer: _____

 

8.  ECSE 202代写

Assume in Assignment 6 that instead of using a B-Tree to index the student records, a 1D array was used instead. How much memory would be needed for this array? Assume an address size of 64-bits, a total of 50 student records, and a maximum record size of 200 bytes.

a. 400

b. 800

c. 200

d. 600

e. 10,000

Answer: _____

 

9.

What is printed by the following snippet of “C” code? You may assume that the address size is 64-bits.

int main() {
struct R {
long a;
long *b;
char c[10];
};
struct R *r;
printf(“%d\n”,sizeof(r));
}

a. 22

b. 4

c. 26

d. 8

e. 18

Answer: _____

 

10.  ECSE 202代写

What is printed by the following snippet of “C” code?

char a[] = “1234”;
printf(“%d\n”,a[0]+a[1]+a[2]+a[3]+4*’0′);

a. 1234

b. Code does not compile.

c. 6 ECSE 202, Version 1

d. 10

e. 9

Answer: _____

 

11.

Which of the following statements is true regarding writing programs in Java and “C”?

a. In writing Java programs in Eclipse, the default is to have a seperate file for each class.

b. All “C” programs must explicitly use include files to store function prototypes.

c. In a “C” program, structure and union definitions must be defined separately in an include file ending in .h.

d. In Java, if a package is not explicitly defined by the programmer, classes will be assigned to the (user package).

e. In a “C” program, each function must be defined in a separate file.

Answer: _____

 

12.  ECSE 202代写

A binary tree is designed to store data of type int, and is implemented in “C” on a computer with a 64-bit address. If a list with 5 elements is stored in this tree, what is the total memory allocated in the process?

a. 80 bytes

b. 60 bytes

c. 120 bytes

d. 100 bytes

e. 108 bytes

Answer: _____

 

13.

Which of the following statements in “C” is equivalent to the following in Java? Assume that type int is 4 bytes.

int myArray[] = new int[10];

a. int myArray = (int)malloc(sizeof(int)*10);

b. int *myArray = (int *)malloc(sizeof(*int)*10);

c. int *myArray = (int *)malloc(sizeof(int)*40);

d. int *myArray = (int *)malloc(40);

e. int myArray = (int *)malloc(sizeof(*int)*10);

Answer: _____

 

14.  ECSE 202代写

In both “C” and Java, a 2D array implementation was described where the first index selects from a 1D array that references a particular row array, and the second a column within the selected row. What is the key advantage of this approach?

a. Can be implemented using threads.

b. Smaller code size.

c. Faster access times.

d. Smaller memory requirements.

e. The array does not have to be fully contiguous in memory.

Answer: _____

 

15.

What mechanism does Java provide users for handling exceptions generated in programs?

a. The interrupt handler class.

b. The try-catch-throw block.

c. The ExceptionListener method.

d. The exception handler class.

e. None of the answers is correct.

Answer: _____

 

16.  ECSE 202代写

Why is type double not always a good choice for writing financial programs?

a. Type double does not have sufficient range to represent quantities used in financial calculations.

b. Type double is not always an exact representation for real-valued decimal numbers.

c. Type double does not have sufficient precision to represent quantities used in financial calculations.

d. Type double does not have a native representation in the cpu like type int.

e. Type double is inefficient relative to type int for calculations.

Answer: _____

 

17.

A binary tree is generated from the following sequence of numbers, {-3, 7, -5, 16, 4, -1}. What is the value stored at the node that is the left successor of the node that contains 4?

a. -5

b. -1

c. null

d. 16

e. 7

Answer: _____

 

18.  ECSE 202代写

Which of the following statements is false?

a. In most implementations, a Java Virtual Machine is necessary to run Java Programs.

b. Java programs are unable to directly access the physical resources of a computer.

c. The syntax of the Java language is similar to that of “C”.

d. “C” programs are always faster than their Java counterparts.

e. “C” programs can sometimes be smaller than their Java counterparts.

Answer: _____

 

19.

Which of the following does not describe a difference in the way “C” and Java deal with objects?

a. Reclaiming memory no longer referenced.

b. How objects are created.

c. Where dynamically allocated data are stored.

d. Error handling when space for an object cannot be allocated.

e. Being able to access the memory address of an object.

Answer: _____

 

ECSE 202代写
ECSE 202代写

 

20.  

Which of the following is not related to an exception in Java?

a. Using the write method with the BufferedWriter class.

b. Using the readLine method with BufferedReader.

c. Opening a file for writing using the FileWriter class.

d. Trying to open a non-existent file using the FileReader class.

e. Reaching the end of a file using the BufferedReader class.

Answer: _____

 

21.

Which of the following statements is FALSE regarding interfaces in Java?

a. A class that implements an interface is required to implement all the methods declared in the interface.

b. Any subclass of a class that implements an interface does not have to implement the interface.

c. All of these statements are true.

d. As with the extends keyword, a Java class can only implement a single interface.

e. It is like a class, but can only contain method signatures and fields.

Answer: _____

 

22.  ECSE 202代写

What is the reason that we are studying the “C” programming language in this course?

a. “C” is widely used, has a small footprint, and runs on most computer architectures.

b. “C” is the only language that runs on all computer platforms.

c. “C” is a functional language widely used in artificial intelligence.

d. “C” is a modern language with memory allocation and garbage collection.

e. “C” is the language that runs on most web browsers.

Answer: _____

 

23.

What is the value of the expression below?

x = 3 + 2 << 2 + 1;

a. 5

b. 21

c. 12

d. 19

e. 40

Answer: _____

 

24.  ECSE 202代写

In writing command line programs in “C”, why is it essential to check argc before attempting to read from argv[ ]?

a. To avoid an access violation.

b. To ensure that the pointer selected corresponds to a valid string.

c. To prevent reading past the end of the array.

d. All answers are correct.

e. argv [ ] is allocated on the basis of the number of arguments.

Answer: _____

 

25.

Consider the following snippet of “C” code:

char a = -128;
unsigned char b=a;
printf(“%d %d\n”, a>>1, b>>1);

What if printed by the printf statement?

a. -64 64

b. -64 -64

c.  64 -64

d. 0 64

e. 64 64

Answer: _____

 

26.  ECSE 202代写

What is produced by the following snippet of “C” code?

char str[] = “This is my string”;
printf(“%s”,&str[8]);

a. Segmentation fault

b. my string

c. m

d. This code does not compile.

e. This is m

Answer: _____

 

27.

A look-up table is used to store the product of two unsigned integers in the range [0,31]. Assuming that this table is implemented using a 2D array of type short, what is the size of this array in bytes?

a. 64

b. 2048

c. 1024

d. 4096

e. 961

Answer: _____

 

28.  ECSE 202代写

What is printed by the following “C” program:

#include <stdio.h>
int main(void){
char a, *b;
b=&a;
a=’C’;
*b=a-‘A’+’a’;
printf(“a = %c\n”,a);
}

a. a = c

b. a =

c. a = C

d. a = A

e. The program will fail to compile as written.

Answer: _____

 

29.

What is meant by the term layered abstraction in reference to Java?

a. The property of a class that allows it to export selected methods while keeping others hidden.

b. Refers to methods inherited from the immediate superclass.

c. The property of a class that allows it to override specific methods within its immediate superclass.

d. The property of a class that hides implementation details from the user.

e. Refers to the fact that methods associated with a particular class may be inherited from different levels within the class hierarchy.

Answer: _____

 

30.  ECSE 202代写

Two changes are made to the code in Assignment 2:

1.The class declaration for aBall is changed from public class aBall extends Thread to public class aBall.

2.In bSim, iBall.start() is changed to iBall.run(). How does the behavior of the program change?

a. The ground plane is drawn, and the set of balls is generated all at the same location; nothing further happens.

b. The ground plane is drawn; nothing further happens.

c. The program produces a blank window; nothing further happens.

d. Each ball follows the same trajectory as before, but a complete simulation is run for one ball before the next is started (balls run sequentially).

e. There is no change in behavior since graphics objects in acm are threads by default.

Answer: _____

 

31.

Which of the statements below is FALSE regarding the following snippet of Java code?

public void actionPerformed (ActionEvent e) {
String cmd = e.getActionCommand();

a. All virtual interactors can generate ActionEvents.

b. addActionListeners() must be called to enable ActionEvents.

c. ActionEvents can be generated by IntFields and DoubleFields.

d. “e” corresponds to an event generated by a virtual interactor.

e. The actionPerformed method is called by the Java system.

Answer: _____

 

32.  ECSE 202代写

A particular computer represents signed integers using a 6-bit datatype. What range of numbers can this scheme represent?

a. [-31,31]

b. [-63,63]

c. [0,63]

d. [-64,63]

e. [-32,31]

Answer: _____

 

33.

It is observed that a program written in “C” will often run faster than an equivalent program written in Java. Which of the following is NOT a possible reason for this observation?

a. Java code runs on the Java Virtual Machine.

b. “C” does not perform garbage collection.

c. “C” code executes directly on the CPU.

d. “C” is a weakly typed language.

e. “C” does not perform bounds checking on memory accesses.

Answer: _____

 

34.  ECSE 202代写

In Assignments 3 & 4, the stackBalls method in the bTree class used instance variables to represent the position of the ball instead of variables defined locally within the method. Which of the following is NOT a reason for doing this?

a. The stackBalls method visits every node within the B-Tree.

b. Instance variables are accessible from every method in the class.

c. A single instance of the position variables is required.

d. There is a separate copy of method variables for each instance of a recursive method.

e. The stackBalls method is recursive.

Answer: _____

 

35.

Which of the following is not characteristic of an event-driven program?

a. An interactive video game.

b. A program that reads a list of numbers from a command line interface and prints out the sum.

c. A program that allows a user to enter command options asynchronously from a keyboard.

d. A data acquisiton program that responds to asynchronous events generated by sensors.

e. A program that uses a mouse to select from a menu of options.

Answer: _____

 

36.  ECSE 202代写

What is a thread (in the context of this course)?

a. A segment of code that operates sequentially to a main program.

b. A segment of code that operates concurrently with a main program.

c. A segment of code initiated by a main program.

d. A segment of code that is completely independent of a main program.

e. A segment of code that is part of the operating system of the computer.

Answer: _____

 

37.

What is the value of the binary number 101010.11?

a. 42.11

b. 42.75

c. 42.24

d. 42

e. 42.30

Answer: _____

 

38.  ECSE 202代写

Consider the function call in the code below:

char a[] = “hello”;
double b = 1.41;
int *c;
double *d;

*c = 31;
*d = 2*b;
myfunction(a,*c,*d, &b);

Which of the following correctly describes the argument passing mechanism used in the function call?

a. value, value, value, reference

b. value, reference, reference, reference

c. reference, value, value, reference

d. reference, reference, reference, reference

e. value, value, value, value

Answer: _____

 

39.

A hashMap class is implemented using the bucket hashing scheme. It is anticipated that 10,000 entries will be stored in the map, but the bucket array is limited to size 2000. What is the expected speed up afforded by this hashing scheme relative to a linear search?

a. 5

b. 10

c. 2000

d. 10,000

e. 1,000

Answer: _____

 

40.  

Assuming that 50 student records are read by the program in Assignment 6, how much memory is required to store a single B-Tree? Assume that the address size is 64 bits, and that the maximum size of a student record is 200 bytes.

a. 10,000

b. 600

c. 800

d. 2,400

e. 1,200

Answer: _____

 

PART 2 – (40 Points) Answer all problems in the space provided

Problem 1 (10 Points)  ECSE 202代写

Write a “C” program to interactively read an unsigned integer value and print its corresponding  binary value. The program should operate in a loop according to the example shown below (note the use of a sentinel value to signal end). This is the question from the midterm, but in “C”.

Decimal to Integer Conversion (negative value to exit):
* Number? 33
* The binary value of 33 = 100001
* Number? 42
* The binary value of 42 = 101010
* Number? 17
* The binary value of 17 = 10001
* Number? -8
* Program terminated

Your program must be able to replicate this example for any user input corresponding to a valid integer value. The program must include a method for converting an integer to a binary string with the following prototype:

void dec2bin (int n, char str[]);

Hints:

1.The algorithm for converting from an integer to a binary number is as follows:

input: an integer n
output: a list of binary digits

empty list
while n > 0
current bit = n % 2
n = n / 2
add current bit to front of list.
end while

2.To simplify the program create a string, e.g. char string[80], in the main program and pass it to dec2bin.

3.Your program should include <stdio.h>, <stdlib.h>, and <string.h>

4.Assume that you have access to the following library functions:

int strlen(char str[])             returns the length of string str.

void strrev(char str[])             reverses the string str.

 

Problem 2 (10 Points)  ECSE 202代写

Write a program that reads a string from the input and prints it out in reverse order. It will do this continually until the user types in a blank line as per the following example (Your program should be able to replicate this example for any user input).

String Reversal Program
Enter a string to reverse at the prompt, blank line to exit.
> 01234567890
>> 09876543210
> hello world
>> dlrow olleh
> the end
>> dne eht
>
Program end

You may use any approach you wish to do the user I/O, as long as it is able to replicate the above example. The program MUST incorporate a method, revstr(), that implements string reversal with the following signature:

String revstr (String in)

This method MUST be written subject to the following restrictions:

1.No use of the concatenation operator. This makes the problem less trivial.

2.You may only use the charAt() and length() methods from the String class.

Hints:

1.The point of this method is to avoid creating intermediate objects using concatenation. Recall the examples we did in class of array reversal.

2.The String class constructor can take a character array as input.

 

Problem 3 (20 points)  ECSE 202代写

Write an interactive Java program that allows a user to store and retrieve attribute-value pairs consisting of 2 strings. Unfortunately you will not be allowed to use the Java Map classes – that is the purpose of this question. When you run the program, it should present the user with a set of simple instructions as shown in the example below. It then prints a command prompt, > , and waits for user input. Here is an example of how the program should run:

Simple Map Program

At the prompt >, enter one of 3 commands:
p (p)ut a new entry in the map.
g (g)et an entry from the map.
q (q)uit.
> g foo
Command not understood
> g
Enter key: foo
No key-value pair with key foo found.
> p
Enter key: red
Enter value: green
> p
Enter key: left
Enter value: right
> p
Enter key: up
Enter value: down
> g
Enter key: left
left –> right
> g
Enter key: up
up –> down
> g
Enter key: red
red –> green
> q

Program Terminated

Your program MUST implement the following classes:

1.private class mapObject(String key, String value)

Holds the key-value pair. It should also implement getter methods getKey() and getValue() respectively.

2.public class simpleMap()

Creates a new map when instanced and implements the following 2 methods:

private void put (mapObject kvPair)
Adds a new key-value pair to the map

mapObject get (String key)
Retrieves a key-value pair matching the key if one exists, or null otherwise.

3.public class doMap()

Implements a simple interactive program that operates as shown in the examples above.

Note: You can implement this program in the simplest way possible. Efficiency is not required

(e.g. not necessary to implement binary search).

Hints:

1.ArrayList is useful for storing arbitrary type objects and can grow incrementally.

2.The simpleMap() class can be written in a few lines of code

3.doMap() is the entry point for this program. It initializes the map, creates a new mapObject for each key-value pair entered by the user and adds it to the map, or retrieves a mapObject on the basis of the key supplied by the user.

 

ECSE 202代写
ECSE 202代写

 

其他代写:code代写 algorithm代写 作业加急 北美代写 CS代写 Data Analysis代写 data代写 澳大利亚代写 essay代写 assignment代写 analysis代写 homework代写 加拿大代写 英国代写 作业代写 report代写 paper代写

合作平台:essay代写 论文代写 写手招聘 英国留学生代写

 

 

天才代写-代写联系方式