Explore BrainMass
Share

# 1 label code, 2 determine time complexity of code segments ,

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

1. Find one example of each label in the following source code and write the line number of the example next to the label.

a. Instance variable

b. Class variable :

c. Instance method

d. Class method

e. Constant variable

f. Constructor

g. Import statement :

1: package edu.gmu.cs.geom;
2:
3: import edu.gmu.cs.geom.Translatable;
4:
5: public class Point2d implements Translatable {
6:
7: public static int ORIGIN_X = 0;
8: public static int ORIGIN_Y = 0;
9:
10: private int x;
11: private int y;
12:
13: public Point2d() {
14: this.x = Point2d.ORIGIN_X;
15: this.y = Point2d.ORIGIN_Y;
16: }
17:
18: public Point2d(int x, int y) {
19: this.x = x;
20: this.y = y;
21: }
22:
23: public int getX() {
24: return this.x;
25: }
26:
27: public int getY() {
28: return this.y;
29: }
30:
31: public void translate(int xDelta, int yDelta) {
32: this.x += xDelta;
33: this.y += yDelta;
34: }
35:
36: public static Point2d add(Point2d left, Point2d right) {
37: int x = left.getX() + right.getX();
38: int y = left.getY() + right.getY();
39:
40: return new Point2d(x, y);
41: }
42:
43: }

2. Order the following code segments by time complexity in ascending order. For bonus points, show the runtime of each code segment in Big O notation.

a.

for (int y = 0; y < n; y++) {
for (int x = 0; x < n; x++) {
m[y, x] = 0;
}
}

b.

public boolean isOdd(int x) {
return (x % 2) == 0;
}

c.

int x = 0;
int y = 0;

while (x < MAX) {
if (isOdd(x)) {
x++;
y++;
} else {
x++;
}
}

d.

int sum = 0;
for (int i = 0; i < items.size(); i = (i * 2) + 1) {
sum += items.get(i);
}

https://brainmass.com/computer-science/programming-languages/label-code-determine-time-complexity-code-segments-425349

#### Solution Preview

Question #1
a. Instance variable
10: private int x;
b. Class variable :
7: public static int ORIGIN_X = 0;
c. Instance method
23: ...

#### Solution Summary

The expert determines the time complexity of code segments for a label code are examined.

\$2.19

## Methodology Research

INFORMATION

Statement of Purpose

The purpose of this study is to examine the attitudes of both married couples and single persons toward the best ways to build a committed relationship. This study will also provides an enrichment opportunity and resources that strengthen both married couples and single person relationships, enhance personal growth, and help build mutual fulfillment.

This assignment needs to be 4 pages in length. This assignment must contain the following elements. Look at the information above to complete this assignment.

Research Question

Use the Statement of Purpose from the Introduction. You will be phrasing your problem as a Research Question. Good research questions should be stated in a clear, unambiguous manner to imply the possibility of its solution through research. While the research question asks how variables are related to one another, a hypothesis provides a tentative answer to such a question and a more specific guide for research.

Methods: Procedures for Collection of Data

The research plan can involve either individuals or groups as the unit of analysis, but the aspects of design should be chosen so as to maximize the strength of your study. State clearly and fully the methods to be used in gathering data to test your hypotheses and/or to answer the questions posed above.

Methods: Procedures for Collection of Data. In this section of the paper you will outline a plan for conducting research of the topic. Although you will not be actually conducting the study, the best advice is to plan in such detail that another equally competent researcher could pick up the proposal and replicate the study. The research plan needs to individuals and groups as the unit of analysis, but the aspects of design should be chosen so as to maximize the strength of the study. State clearly and fully the methods to be used in gathering data to test the questions posed above.

a. Sample. The reader will want to know demographic information about the population from which the sample would be selected. Details of how the sample would be selected should also be explained here. This subsection should answer these questions: 1) what is the source of the sample (the population from which the sample would be selected); 2) how would the sample be selected; 3) why was this sample selected; 4) what are the characteristics of the sample. The sample information should include the number of respondents, the nature of the respondents, specifically any demographic information such as age, gender, etc.
b. Procedures for Data Collection. It is necessary in this section to describe the chosen design and data collection procedures. If an experimental design is chosen, explain both the experimental process and the controls which would be applied. Study Design. This section consists of a chronological list of the steps that would be used in conducting the study. It should be as detailed as possible to include time estimates where applicable.
c. Data Analysis. What will be done after the data is collected? The statistical methods you would use to analyze your data are outlined in this section. If the techniques or measurement procedures are unusual, describe them in detail. For non-statistical methods of analysis, describe the qualitative factors you will be using.

I need some help with each component e.g ideas and suggestions to point me in the right direction. Thank you.

View Full Posting Details