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]
3 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]3 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
If the tax percent is 15% and tax is $36 and percent discount is 10, what is the cost price?​
fomenos
$36.26 because tax is $4.40 and the discount would be $4.14 | so 40-14 is 26
4 0
3 years ago
A printer would be considered _____. Select 2 options. 1 an input device 2 an output device 3 hardware 4 software 5 storage
brilliants [131]

Answer:

an output device and hardware

Explanation:

Hardware is something that can be physicaly touched and an output device is something that gives information out, such as a monitor, speaker, or printer

3 0
3 years ago
Which of the following choices best completes the above flowchart?
bagirrra123 [75]

Answer:A

Explanation: they have too cover cost of manufacturing

8 0
3 years ago
Why is an ISA unlikely to change between successive generations of microarchitectures
QveST [7]
Someone answer this because I need to know as well
\
4 0
3 years ago
Which option in PowerPoint allows users to configure the number of columns and rows manually, using numerical values?
babunello [35]

Users can use numerical values to set the number of columns and rows in the Insert Table dialog box in PowerPoint. Option A is correct.

<h3>What is the PowerPoint?</h3>

Microsoft or MS PowerPoint is defined as a presentation program that was developed by Forethought, Inc.'s Robert Gaskins and Dennis Austin. In PowerPoint, users can use numerical values to specify the number of columns and rows in the Insert Table dialog box.

Therefore, option A is correct.

Learn more about the PowerPoint, refer to:

brainly.com/question/14498361

#SPJ1

7 0
2 years ago
Other questions:
  • One of the earlier applications of crypto-graphic hash functions was the storage of passwords to authenticate usersin computer s
    13·1 answer
  • Which combination of factors would result in the lowest monthly mortgage payment?
    9·2 answers
  • The final step of the DHCP Discovery process is known as...
    8·1 answer
  • Big data refers to huge collections of data that are difficult to process, analyze, and manage using conventional data tools. It
    13·1 answer
  • RAM that can be changed. True or False
    9·2 answers
  • Write a program that dynamically allocates an array large enough to hold a user-defined number of test scores. Once all the scor
    5·1 answer
  • The<br>tool can lighten the part of an<br>image.*<br>Your answer​
    13·1 answer
  • Using only AND, OR and inverter gates to implement the above Boolean equation, how many gates are needed
    8·1 answer
  • Select the correct answer from each drop-down menu. The following diagram shows four resistors. What is the effective resistance
    9·1 answer
  • A computer hacker trying different combinations of characters to crack a password is a ________.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!