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
Zachary is a member of Future Business Leaders of America at his school and is competing in the Impromptu Speaking competition.
Scrat [10]

Answer:

c start off with a story

Explanation:

I just took the test

4 0
3 years ago
Read 2 more answers
create a 3 to 5 step plan for checking out a post on social media for the next time you encounter something questionable.
SashulF [63]
1. Report post
2. Block or unfollow user
3. Tell parent
6 0
3 years ago
Read 2 more answers
Differentiate between childhood socialization and adulthood socialization ​
AveGali [126]

Answer:

In adolescence, socialization is concerned with the development of overarching values and the self-image. In adulthood, socialization involves more overt and specific norms and behaviors, such as those related to the work role as well as more superficial personality features.

6 0
3 years ago
Malware that is spread through security warnings or advertisements for antivirus software is known as ______________.
Agata [3.3K]
This is known as "phishing"
7 0
3 years ago
Read 2 more answers
Write a program that reads a list of integers, one per line, until an * is read, then outputs those integers in reverse. For sim
TiliK225 [7]

Answer:

I'm just going to copy my pseudocode into an answer:

x = array()

i = 0

while (true)

j = input()

if j = "*" then break

x[i] = j

i++

print x.join(", ")

Explanation:

8 0
3 years ago
Other questions:
  • Jose wants to be sure maintains a high credit score as he is planning yo buy a new car soon what should he do to ensure his scor
    13·2 answers
  • 3. If the typical balance on Lucy's credit card is $750 and the interest rate (APR) on her credit card is 16%, how much in inter
    11·2 answers
  • 1. Which of the following statements is true regarding the use of refrigerants?
    15·2 answers
  • Which of the following is not a characteristic of a motorcycle?
    6·1 answer
  • 6.5 Code Practice: Question 1 please help with code!!! Thank you
    12·1 answer
  • Internet is for everyone but it wont be if its users cannot protect their privacy and the confidentiality of transactions conduc
    6·1 answer
  • HELP ASAP!!!
    7·1 answer
  • Describe how computer are used in ticket counter?​
    10·1 answer
  • Which of the following is not the disadvantage of closed
    7·2 answers
  • Do you need a contractor to install nest thermostat
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!