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
A _____ character is a space, a tab, or a new line.
babunello [35]
Whitespace

--------------------------------------------
5 0
3 years ago
Write a function ComputeVal that takes two integer parameters and returns the product of the two parameters plus 9. Ex: ComputeV
Romashka-Z-Leto [24]

Answer:

#include <iostream>

using namespace std;

/* Your code goes here */

int main() {

  int input1, input2;

  int result;

 

  cin >> input1;

  cin >> input2;

 

  result = ComputeNum(input1, input2);

 

  cout << result << endl;

  return 0;

Explanation:

6 0
3 years ago
How would you define the rule of thirds?
mixer [17]

A pronciple of composition used fir centuries by artists and photographers or it is a method when used to frame a composition properly

8 0
3 years ago
For which firewall feature should you create forward trust and forward untrust certificates?
guajiro [1.7K]

Answer:Jun 19, 2019 - Additionally, set up a forward untrust certificate for the firewall to ... After setting up the forward trust and forward untrust certificates required for SSL Forward Proxy ... If you do not install the forward trust certificate on client systems, ... Create a Decryption Policy Rule to define traffic for the firewall to decrypt.

WELCOME

8 0
3 years ago
Which prosscess is a form of mechanicel weathering
Alecsey [184]

Answer:

The most common form of mechanical weathering is the freeze-thaw cycle. Water seeps into holes and cracks in rocks. The water freezes and expands, making the holes larger. Then more water seeps in and freezes

4 0
2 years ago
Read 2 more answers
Other questions:
  • A database on a mobile device containing bands, sub-bands and service provider IDs allowing the device to establish connection w
    9·1 answer
  • The variable sentence stores a string. Write code to determine how many words in sentence start and end with the same letter, in
    13·1 answer
  • Liza works as a receptionist. Around the lunch hour, she has a difficult time hearing the callers due to employees talking near
    12·1 answer
  • What allows people to create their own radio shows over the internet?
    14·1 answer
  • _____ is an example of a locally installed email client.
    5·2 answers
  • Select the steps for adding artwork into a placeholder on a presentation slide
    11·1 answer
  • Traceability of requirements is helpful in the followingexcept
    5·1 answer
  • Different video files and ______ can cause compatibility issues to arise between computer systems.
    8·1 answer
  • What is the Microsoft excel window where you work on. And it composed of three worksheet?​
    7·1 answer
  • A programmer wants to determine whether a score is within 10 points of a given target. For example, if the target is 50, then th
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!