1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Travka [436]
2 years ago
15

Write a method named numUnique that accepts a sorted array of integers as a parameter and that returns the number of unique valu

es in the array. The array is guaranteed to be in sorted order, which means that duplicates will be grouped together. For example, if a variable called list stores the following values: int[] list
Computers and Technology
1 answer:
SVEN [57.7K]2 years ago
3 0

Answer:

The method in Java is as follows:

public static int numUnique(int list[]) {  

int unique = 1;  

for (int i = 1; i < list.length; i++) {  

 int j = 0;  

 for (j = 0; j < i; j++) {

  if (list[i] == list[j])  

   break;  

 }

 if (i == j)  

  unique++;  

}  

return unique;  

}  

Explanation:

This line defines the numUnique method

public static int numUnique(int list[]) {

This initializes the number of unique elements to 1

int unique = 1;  

This iterates through the list

for (int i = 1; i < list.length; i++) {

The following iteration checks for unique items

 int j = 0;  

<em>  for (j = 0; j < i; j++) { </em>

<em>   if (list[i] == list[j]) </em><em>If current element is unique, break the iteration</em><em> </em>

<em>    break;  </em>

<em>  } </em>

 if (i == j)  

  unique++;  

}

This returns the number of unique items in the list

return unique;  

}  

You might be interested in
Which of these is a way that a doctor can examine a patient?
SIZIF [17.4K]

Answer:

D. all the above

Explanation:

because doctor uses stethoscope to listen patients heart, he also used hammer to check patients reflexes and also doctor has to listen to the patient.

5 0
3 years ago
Glenda operates an Airbnb business in which she rents an apartment for $150US per night . There is a mandatory deposit of 50 dol
Kipish [7]

Answer:

Steps of the technological design process include: identify a problem, research the problem, generate possible solutions, select the best solution, create a model, test the model, refine and retest the model as needed, and communicate the final solution.

Explanation:

3 0
3 years ago
What is the full form of w3c
Xelga [282]
The World Wide Web Consortium, which <span>is an international community where organizations, employees</span><span> and the general public work together to develop Web standards.</span>
7 0
3 years ago
In the MARS Marketing Management Simulation, the results of your marketing mix decisions:
azamat
C- are only occasionally affected by the decisions made by other teams
explanation
idk
3 0
3 years ago
The name atari comes from what
algol [13]

Answer:

JAPANESE

Explanation:

Have a nice day:)

3 0
3 years ago
Other questions:
  • Please answer fast screenshot included - thanks in advance
    11·1 answer
  • What type of maintenance can prevent the computer from breaking?
    11·2 answers
  • Write a method reverse( ) for OurLinkedList class. The method should return a new OurLinkedList object that is the reverse of th
    8·1 answer
  • A program called a ( n ) ____ translates instructions written in high-level languages into machine code.
    13·1 answer
  • A carver begins work on the following block of granite that weighs 2700 g. What is the density of the granite?
    13·1 answer
  • PLEASE ANSWER FAST.one of the barriers for early "talkies" was the need to manually crank the projector and manually synchronize
    13·1 answer
  • List out the storage measurements units of a computer .<br><br>​
    10·2 answers
  • Does anyone know how many Brainliests you need to be able to send a private message to someone??
    10·2 answers
  • You have implemented an access control method that only allows users who are managers to access specific data. Which type of acc
    11·2 answers
  • identify the difficulties with the k-nearest neighbor algorithm. a. both a and b b. calculate the distance of the test case from
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!