The Fibonacci sequence begins with 0 and then 1 follows. All subsequent values are the sum of the previous two, for example: 0, 1, 1, 2, 3, 5, 8, 13. Complete the fibonacci() method, which takes in an index, n, and returns the nth value in the sequence. Any negative index values should return -1.
Ex: If the input is: 7
the out put is :fibonacci(7) is 13
Note: Use recursion and DO NOT use any loops. // is this mean i don't have to use loops? for (int i = 1; i<= n; ++i)
import java.util.Scanner;
public class LabProgram {
public static int fibonacci(int n) {
/* Type your code here. */
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
int startNum;
System.out.println("Enter your number: ");
startNum = scnr.nextInt();
System.out.println("fibonnaci(" + startNum + ") is " + fibonacci(startNum));
}
}

Answers

Answer 1

Answer:

if this helps you,do consider marking my ans as brainliest.

Explanation:

import java.util.Scanner;

public class LabProgram{

public static int fibonacci(int n) {

/* Type your code here. */

if(n<0)

return -1;

if(n==0||n==1)

return n;

else

return fibonacci(n-1)+fibonacci(n-2);

}

public static void main(String[] args) {

Scanner scnr = new Scanner(System.in);

int startNum;

System.out.println("Enter your number: ");

startNum = scnr.nextInt();

System.out.println("fibonnaci(" + startNum + ") is " + fibonacci(startNum));

}

}

Answer 2

Recursions involve calling a function from the function itself, until a condition is met.

The required function, where comments are used to explain each line is as follows:

//This defines the function

public static int fibonacci(int n) {

//The function returns -1, if n is negative

if(n<0){

return -1;}

//The function returns the value of n, if n is 0 or 1

if(n==0||n==1){

return n;}

//If otherwise

else{

//The function returns the nth term of the Fibonacci series

return fibonacci(n-1)+fibonacci(n-2);

}

}

At the end of the program, the nth term of the Fibonacci series is printed.

Read more about similar programs at:

https://brainly.com/question/24212022


Related Questions

list area where ICT tools can be integrated​

Answers

Answer:

In surgical labs

In Aviation control centres

In secretarial sects of organizations

why do we need to make a plan before actions?

Answers

Answer:

Creating an action plan gives you a clear guide to success.

Explanation:

It helps prioritize goals, maximize resources, and make better decisions

Two character strings may have many common substrings. Substrings are required to be contiguous in the original string. For example, photograph and tomography have several common substrings of length one (i.e., single letters), and common substrings ph, to, and ograph as well as all the substrings of ograph. The maximum common substring length is 6. Let X = X122 . Im and Y = yıy2 - - • Yn be two character strings. Using dynamic programming, design an algorithm to find the maximum common substring length for X and Y using dynamic programming. Please follow the general steps for designing a dynamic programming solution as in Q1 (other than the actual programming part).

Answers

Answer:

Explanation:

The following function is written in Java. It takes two strings as parameters and calculates the longest substring between both of them and returns that substring length.

import java.util.*;

class Test

{

   public static void main(String[] args)

   {

       String X = "photograph";

       String Y = "tomography";

       System.out.println(X + '\n' + Y);

       System.out.println("Longest common substring length: " + longestSub(X, Y));

   }

   static int longestSub(String X, String Y)

   {

       char[] word1 = X.toCharArray();

       char[] word2 = Y.toCharArray();

       

       int length1 = X.length();

       int length2 = Y.length();

       int substringArray[][] = new int[length1 + 1][length2 + 1];

       int longestSubstringLength = 0;

       

       for (int i = 0; i <= length1; i++)

       {

           for (int j = 0; j <= length2; j++)

           {

               if (i == 0 || j == 0)

                   substringArray[i][j] = 0;

               else if (word1[i - 1] == word2[j - 1])

               {

                   substringArray[i][j]

                           = substringArray[i - 1][j - 1] + 1;

                   longestSubstringLength = Integer.max(longestSubstringLength,

                           substringArray[i][j]);

               }

               else

                   substringArray[i][j] = 0;

           }

       }

       return longestSubstringLength;

   }

}

Karen is designing a website for her uncle's landscaping business. She wants to ensure that it's engaging and provides a lot of information about the services that he provides. She already has a lot of images that make the website visually attractive, but she hasn't found a way to provide information about the services and still engage the visitors. What is something that Karen can add to the website to meet these needs.

Answers

Explanation:

Talk About The Benefits. of your  service over other compines

According to the above scenario, Karen can add an upbeat video that describes about the services offered by them to the website to meet these needs.

What is Website?

A website is a collection of internet pages and related material recognized by a common domain name and hosted on at least one web server.

Websites are usually focused on a single topic or goal, such as news, education, business, entertainment, or social networking. The navigation of the site, which typically begins with a home page, is guided by hyperlinking between online pages.

Websites may be accessed using a variety of devices, including desktops, laptops, tablets, and smartphones. The app that is utilized on these smartphones is known as Web Browser.  

According to the aforesaid situation, Karen can post an uplifting video to the website that outlines the services they offer to suit these demands.

Learn more about Website here:

https://brainly.com/question/19459381

#SPJ2

a friend emails a presentation to isabella to view. what kind of change can she make?​

Answers

Answer:

She can enable editing. She can change the view.

Explanation:

12. Realizar un algoritmo que genere un número aleatorio, el usuario debe adivinar cual es el número generado para esto tendrá 3 turnos

Answers

Answer:

Explanation:

El siguiente algoritmo esta escrito en Java y genera un numero aleatorio. Despues le pide al usario que intente adivinar el numero. Si el usario adivina correctamente entoces le dice que fue correcto y termina el programa. Si no adivina bien entonces dice Incorrecto y le pide otra adivinanza al usario hasta llegar a la tercera adivinanza y se termina el programa.

import java.util.Random;

import java.util.Scanner;

class Brainly{

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       Random ran = new Random();

       int numero = ran.nextInt(20);

       for (int x = 0; x <= 2; x++) {

           System.out.println("Adivina el numero entre 0 y 20: ");

           int respuesta = in.nextInt();

           if (respuesta == numero) {

               System.out.println("Correcto");

               break;

           } else {

               System.out.println("Incorrecto");

           }

       }

   }

}

A company is choosing a database. Several options are available, but the business owner needs help deciding which one is best. The company is a big city law firm with many clients. Which tool would you recommend?

a server database

a desktop database

a spreadsheet

Answers

Answer:

a. Server database

Explanation:

Answer:

The next one is C. Spreadsheet.

Explanation:

Edge

Let's implement a classic algorithm: binary search on an array. Implement a class named BinarySearcher that provides one static method named search. search takes a SearchList as its first parameter and a Comparable as its second. If either parameter is null, or if the SearchList is empty, you should throw an IllegalArgumentException. SearchList is a provided class. It provides a get(int) method that returns the Comparable at that index, and a size method that returns the size of the SearchList. Those are the only two methods you should need! search returns a boolean indicating whether the passed value is located in the sorted SearchList. To search the sorted SearchList efficiently, implement the following algorithm: Examine the value in the middle of the current array (index (start + end) / 2) If the midpoint value is the value that we are looking for, return true If the value that we are looking for is greater than the midpoint value, adjust the current array to start at the midpoint if the value that we are looking for is less than the midpoint value, adjust the current array to end at the midpoint Continue until you find the value, or until the start reaches the end, at which point you can give up and return false This is a fun problem! Good luck! Keep in mind that every time you call SearchList.get that counts as one access, so you'll need to reduce unnecessary accesses to pass the test suite.

Answers

Answer:

Hope this helped you, and if it did , do consider giving brainliest.

Explanation:

import java.util.ArrayList;

import java.util.List;

//classs named BinarySearcher

public class BinarySearcher {

 

//   main method

  public static void main(String[] args) {

     

//   create a list of Comparable type

     

      List<Comparable> list = new ArrayList<>();

     

//       add elements

     

      list.add(1);

      list.add(2);

      list.add(3);

      list.add(4);

      list.add(5);

      list.add(6);

      list.add(7);

     

//       print list

     

      System.out.println("\nList : "+list);

     

//       test search method

     

      Comparable a = 7;

      System.out.println("\nSearch for 7 : "+search(list,a));

     

      Comparable b = 3;

      System.out.println("\nSearch for 3 : "+search(list,b));

     

      Comparable c = 9;

      System.out.println("\nSearch for 9 : "+search(list,c));

     

      Comparable d = 1;

      System.out.println("\nSearch for 1 : "+search(list,d));

     

      Comparable e = 12;

      System.out.println("\nSearch for 12 : "+search(list,e));

     

      Comparable f = 0;

      System.out.println("\nSearch for 0 : "+search(list,f));

     

  }

 

 

 

//   static method named search takes arguments Comparable list and Comparable parameter

  public static boolean search(List<Comparable> list, Comparable par) {

     

//       if list is empty or parameter is null the throw IllegalArgumentException

     

      if(list.isEmpty() || par == null ) {

         

          throw new IllegalArgumentException();

         

      }

     

//       binary search

     

//       declare variables

     

      int start=0;

     

      int end =list.size()-1;

     

//       using while loop

     

      while(start<=end) {

         

//           mid element

         

          int mid =(start+end)/2;

         

//           if par equal to mid element then return

         

          if(list.get(mid).equals(par) )

          {

              return true ;

             

          }  

         

//           if mid is less than parameter

         

          else if (list.get(mid).compareTo(par) < 0 ) {

                 

              start=mid+1;

          }

         

//           if mid is greater than parameter

         

          else {

              end=mid-1;

          }

      }

     

//       if not found then retuen false

     

      return false;

     

  }

 

 

}import java.util.ArrayList;

import java.util.List;

//classs named BinarySearcher

public class BinarySearcher {

 

//   main method

  public static void main(String[] args) {

     

//   create a list of Comparable type

     

      List<Comparable> list = new ArrayList<>();

     

//       add elements

     

      list.add(1);

      list.add(2);

      list.add(3);

      list.add(4);

      list.add(5);

      list.add(6);

      list.add(7);

     

//       print list

     

      System.out.println("\nList : "+list);

     

//       test search method

     

      Comparable a = 7;

      System.out.println("\nSearch for 7 : "+search(list,a));

     

      Comparable b = 3;

      System.out.println("\nSearch for 3 : "+search(list,b));

     

      Comparable c = 9;

      System.out.println("\nSearch for 9 : "+search(list,c));

     

      Comparable d = 1;

      System.out.println("\nSearch for 1 : "+search(list,d));

     

      Comparable e = 12;

      System.out.println("\nSearch for 12 : "+search(list,e));

     

      Comparable f = 0;

      System.out.println("\nSearch for 0 : "+search(list,f));

     

  }

 

 

 

//   static method named search takes arguments Comparable list and Comparable parameter

  public static boolean search(List<Comparable> list, Comparable par) {

     

//       if list is empty or parameter is null the throw IllegalArgumentException

     

      if(list.isEmpty() || par == null ) {

         

          throw new IllegalArgumentException();

         

      }

     

//       binary search

     

//       declare variables

     

      int start=0;

     

      int end =list.size()-1;

     

//       using while loop

     

      while(start<=end) {

         

//           mid element

         

          int mid =(start+end)/2;

         

//           if par equal to mid element then return

         

          if(list.get(mid).equals(par) )

          {

              return true ;

             

          }  

         

//           if mid is less than parameter

         

          else if (list.get(mid).compareTo(par) < 0 ) {

                 

              start=mid+1;

          }

         

//           if mid is greater than parameter

         

          else {

              end=mid-1;

          }

      }

     

//       if not found then retuen false

     

      return false;

     

  }

 

 

}

the levels of classification of organisms in order are: domain, kingdom, phylum, class, order, family, genus, and species. The broadest, least specific level is____________________

Answers

Answer:

Domain.

Explanation:

In Science, this biological classification of living organisms based on similarities or characteristics such as eyes, number of legs, etc., is generally referred to as taxonomy.

Taxonomy can be defined as the process of naming, classification and description of living organisms such as plants and animals.

Basically, the eight (8) biological classification (taxonomy) used for grouping and organizing organisms are; kingdom, domain, phylum, family, order, class, species and genus.

Hence, taxonomy helps scientist to have a good understanding and knowledge when studying various organisms.

Furthermore, the broadest, least specific level of the biological classification of living organisms is domain. The three (3) domain in which living organisms can be classified are: Bacteria, Eukaryote, and Archaea.

Answer:

doman

Explanation:

11. Its collection of toys which could be used in the game via an implanted RFID chip made Activision’s game _______ one of the most important in gaming history.
a) 102 Dalmations
b) Skylanders
c) Lego Star Wars
d) Super Monkey Ball

Answers

Answer:

I think it's B correct me if I'm wrong

Explanation:

Answer:

B

Explanation:

I say it is the right one although in this 2021 there is no other game but it is its 10th anniversary

What is the full form of LAPTOP?​

Answers

Answer:

The full form of Laptop is Lightweight Analytical Platform Total Optimized Power.

(main.c File)
Counting the character occurrences in a file
For this task you are asked to write a program that will open a file called “story.txt”
and count the number of occurrences of each letter from the alphabet in this file.
At the end your program will output the following report:
Number of occurrences for the alphabets:
a was used – times.
b was used – times.
c was used – times…. …and so, on
Assume the file contains only lower-case letters and for simplicity just a single
paragraph. Your program should keep a counter associated with each letter of the
alphabet (26 counters) [Hint: Use array]
Your program should also print a histogram of characters count by adding
a new function print Histogram (int counters []). This function receives the
counters from the previous task and instead of printing the number of times each
character was used, prints a histogram of the counters. An example histogram for
three letters is shown below) [Hint: Use the extended asci character 254]

Answers

Answer:

C code

Explanation:

#include <stdio.h>

void histrogram(int counters[])

{

   int i,j;

   int count;

   for(i=0;i<26;i++)

   {

       count=counters[i];

       printf("%c ",i+97);

       for(j=0;j<count;j++)

       {

           printf("="); //= is used

       }

       printf("\n");

      

   }

      

}

int main()

{

   FILE* fp;

   int i;

   int arr[26];

   char c;

   int val;

   // Open the file

fp = fopen("story.txt", "r");

  

if (fp == NULL) {

printf("Could not open file ");

return 0;

}

else

{

   for(i=0;i<26;i++)

   arr[i]=0;

  

   for (c = getc(fp); c != EOF; c = getc(fp))

   {

       if(c>='a' && c<='z')

       {

           val = c-97;

           //printf("%d ",val);

           arr[val]++;

          

           }

       }

       histrogram(arr);

      

  

      

  

   }

}

Assume that class BankAccount exists, and that it has a constructor that sets the private field balance, and that setBalance and getBalance are defined by class BankAccount and set and get double values. Then what is the output of the following code:________.
a. 600.0
b. 0.0
c. 300.0
d. null
e. an error will result

Answers

Question:

Assume that class BankAccount exists, and that it has a constructor that sets the private field balance, and that setBalance and getBalance are defined by class BankAccount and set and get double values.

Then what is the output of the following code?

BankAccount b1 = new BankAccount(600.0);

BankAccount b2 = b1;

b1.setBalance(300.0);

System.out.println(b2.getBalance() );

Answer:

300.0

Explanation:

The given snippet of code is as follows:

=======================================

BankAccount b1 = new BankAccount(600.0);

BankAccount b2 = b1;

b1.setBalance(300.0);

System.out.println(b2.getBalance() );

=======================================

Line 1: An object b1 of the BankAccount class is created which sets the value of its balance to 600.0

Line 2: A second object, b2, is created referencing or pointing to the first object, b1 in memory. It could also be interpreted to mean that a second object b2 is created from the exact copy of the first object, b1. This is called object cloning. This by implication means that all the fields (including the contents of the fields) of the first object b1, are copied to b2 which also means that when there's a change in b1, an update is made to b2 also. If a change is made to b2, b1 also gets updated.

Line 3: Object b1 is updated by setting the value of its balance field to 300.0 using the setBalance() method. This will also update the same field for the second object b2.

Line 4: The value of the balance field of object b2 is being printed to the console. Since the value has been updated in line 3 when that of b1 was updated, 300.0 will be printed to the console.

Prepare a document to list down at least 10 features/operations (on process and thread) you can do using Process Explorer.

Answers

Answer:

The operations that can be carried out using process explorer include but are not limited to:

Explanation:

Killing a Process TreeEnding or terminating a processSuspending a processExamining which process has locked a fileManually detecting a virusUnhiding a process. This can help to callup the window for a process that is not visible under normal explorer activitiesMonitor CPU usage setting the priority of a processchanging a service process's access securityMonitoring Graphics Processing Unit

Cheers

Use the drop-down menus to complete the steps to convert a macro to VBA.
1. Open the macro in view.
2. The Design conditional tab will appear.
3. Find the Tools group, and select .
4. The Convert dialog box will open.
5. Click .
6. The macro is now in VBA formatting.

Answers

Answer:

1. Design

2. Convert Macros to Visual Basic

3. Convert

Explanation:

Answer:

B D A

Explanation:

Create a class named TestCircle whose main() method declares Several Circle objects. Using the setRadius() method, assign one Circle a small radius value, and assign another a larger value. Do not assign a value to the radius of the third circle; instead, retain the value assigned at construction. Display all the values for all the Circle objects. Save the application as TestCircle.java

Answers

Answer:ublic class Circle {

public int radius = 1;

public double diameter;

public double area;

//Constructor for circle class

public double Circle(int First){

return radius;

}

//Start set and get for radius

private double setRadius(int r){

   return radius = 5;

}

private double getRadius(){

 return radius;

}

//Start set and get for diameter

public double setDiamter(double d){

   return diameter = 7;

}

public double getDiamter(){

 return radius * diameter;

}

is it possible to unlock a password without a password if you forgot​

Answers

Answer:

no

Explanation:

because u will need an code

Answer:

it should have a reset with email option

Explanation:

Internet __________, or IP, describes how data pachets move through a network.

Answers

Answer:

Packets

Explanation:

Answer:

protocol

Explanation:

IP stands for internet protocol

how many nibbles make one kilobyte​

Answers

2000 nibbles I think correct me if I’m wrong

Answer:

2000 nibbles

Explanation:

2000 nibbles is needed for 1 kilobyte

Selection Sort List the resulting array after each iteration of the outer loop of the selection sort algorithm. Indicate the number of character-to-character comparisons made for each iteration (line 07 of the Selection Sort algorithm at the end of the assignment). Sort the following array of characters (sort into alphabetical order): CQS A XBT Selection Sort 01 public static void selectionSort (int[] a) { 02 03 int n = a.length; for (int i = 0 ; i 0; j--) { if ( a[j-1] > a[j] ) { exchange(a, j-1, j); } else break; 10 } 12 private static void exchange (int[] a, int i, int j) { 13 // exchange the value at index i with the value at index j int temp = a[i]; a[i] = a[j]; a[j] = temp; 17 }

Answers

Solution :

Initial array = [tex]$\text{C,Q,S,A,X,B,T}$[/tex]

[tex]$n= 7$[/tex](length of the array)

[tex]$\text{1st}$[/tex] Iteration:

i = 1

  j = 1

  [tex]$\text{a[j-1]}$[/tex] = C

  a[j] = Q

  since [tex]$\text{a[j-1]}$[/tex] < a[j] , break from inner loop

 

Number of comparisons in 1st Iteration = 1

After 1st Iteration:

Array : C,Q,S,A,X,B,T

2nd Iteration:

i = 2

  j = 2

  a[j-1] = Q

  a[j] = S

  since a[j-1] < a[j], break from inner loop

 

Number of comparisons in 2nd Iteration = 1

After 2nd Iteration:

Array : C,Q,S,A,X,B,T

3rd Iteration:

i = 3

  j = 3

  a[j-1] = S

  a[j] = A

  since a[j-1] > a[j], exchange a[2] with a[3]

  Array : C,Q,A,S,X,B,T

 

  j = 2

  a[j-1] = Q

  a[j] = A

  since a[j-1] > a[j], exchange a[1] with a[2]

  Array : C,A,Q,S,X,B,T

 

  j = 1

  a[j-1] = C

  a[j] = A

  since a[j-1] > a[j], exchange a[0] with a[1]

  Array : A,C,Q,S,X,B,T

 

  j = 0, break from inner loop

Number of comparisons in 3rd Iteration = 3

After 3rd Iteration:

Array : A,C,Q,S,X,B,T

4th Iteration:

i = 4

  j = 4

  a[j-1] = S

  a[j] = X

  since a[j-1] < a[j], break from inner loop

 

Number of comparisons in 4th Iteration = 1

After 4th Iteration:

Array : A,C,Q,S,X,B,T

5th Iteration:

i = 5

  j = 5

  a[j-1] = X

  a[j] = B

  since a[j-1] > a[j], exchange a[4] with a[5]

  Array : A,C,Q,S,B,X,T

 

  j = 4

  a[j-1] = S

  a[j] = B

  since a[j-1] > a[j], exchange a[3] with a[4]

  Array : A,C,Q,B,S,X,T

 

  j = 3

  a[j-1] = Q

  a[j] = B

  since a[j-1] > a[j], exchange a[2] with a[3]

  Array : A,C,B,Q,S,X,T

 

  j = 2

  a[j-1] = C

  a[j] = B

  since a[j-1] > a[j], exchange a[1] with a[2]

  Array : A,B,C,Q,S,X,T

 

  j = 1

  a[j-1] = A

  a[j] = B

  since a[j-1] < a[j], break from inner loop

 

Number of comparisons in 5th Iteration = 5

After 5th Iteration:

Array : A,B,C,Q,S,X,T

6th Iteration:

i = 6

  j = 6

  a[j-1] = X

  a[j] = T

  since a[j-1] > a[j], exchange a[5] with a[6]

  Array : A,B,C,Q,S,T,X

 

  j = 5

  a[j-1] = S

  a[j] = T

  since a[j-1] < a[j], break from inner loop

 

Number of comparisons in 6th Iteration = 2

After 6th Iteration:

Array : A,B,C,Q,S,T,X

Sorted Array : A B C Q S T X  

What type of system enables computer data to be stored in multiple locations and shared with multiple users simultaneously?

A. content delivery network
B. consumer delivery network
C. cloud storage
D. World Wide Web​

Answers

Answer:

A

Explanation:

Taran is concerned with the security of his macros in a database. Which security option could he use to provide protection?

digital signatures
hide database objects
start-up options
secure VBA code

Answers

Answer:security VBA code

Explanation:

what is operating software​

Answers

Answer:

An operating system (OS) is system software that manages computer hardware, software resources, and provides common services for computer programs. ... Operating systems are found on many devices that contain a computer – from cellular phones and video game consoles to web servers and supercomputers. Mobile devices, such as tablets and smartphones also include operating systems that provide a GUI and can run applications. Common mobile OSes include Android, iOS, and Windows Phone.

plz mark it as brainliest

state two reason why there is a carry out a feasibility srudy in SDLC​

Answers

Answer:Feasibility studies are important to business development.

1.) They can allow a business to address where and how it will operate.

2.) They can also identify potential obstacles that may impede its operations and recognize the amount of funding it will need to get the business up and running.

Select all that apply.

What two values do comparison operators return?

TRUE
EQUAL
LESS THAN
FALSE

Answers

Answer:

Equal

Less than

Explanation:

Sergio needs to tell his team about some negative feedback from a client. The team has been
working hard on this project, so the feedback may upset them. Which of the following explains
the best way for Sergio to communicate this information?

A) Hold an in person meeting so that he can gauge the team's body language to assess their
reaction

B) Send a memorandum so everyone will have the feedback in writing

C) Hold a video conference so everyone can see and hear about the client's concern without the group witnessing each other's reactions

D) Send an email so everyone will have time to think about the feedback before the next team meeting

Answers

Answer:

A

Explanation:

I feel that if everyone is with eachother, there may be a better hope to improve the next time

I need help
I am thinking about coming out to my mom because we are going to the store today and I will be in the car, I dont know if I should or not

Answers

Answer:

do it! you will have to one day so why not now? hopefully she will understand and say nice things as well and be like mom ive

been thinking a lot and i really want to tell you something. Explanation:

Answer:most likely she is your parent that you live with so she might already know but has not said anything it also depends her personality but if your ready and know or think she would not hate you forever go for it

Explanation:

The variable strFirst's scope is _____.

Answers

pretty sure it’s d, hope this helps

Answer:

- the usernameMaker function

Explanation:

When you look at the code, you can see it's located alongside the usernameMaker. It it only utilized then, therefore being it's scope. For reassurance, it's also correct on Edge.

I hope this helped!

Good luck <3

A major advantage of direct mapped cache is its simplicity and ease of implementation. The main disadvantage of direct mapped cache is: a. it is more expensive than fully associative and set associative mapping. b. it has a greater access time than any other method. c. its performance is degraded if two or more blocks that map to the same location are used alternately. d. it does not allow the cache to store the tag that corresponds to the block currently residing in that cache location.

Answers

brainlest   pl     jk  mmmmmmmmmmmmm

Write an algorithm (pseudo-code) that takes an unsorted list of n integers and outputs a sorted list of all duplicate integers. There must be no duplicates in the output list, also the output list should be a sorted list. The algorithm must run in O(n) time. Show your analysis of the running time. Note: Assume that inputs are integer values from 0 to 255. (Hint: use the concept that being used in the separate chaining)

Answers

Answer:

brainliest if it did help you

Explanation:

Given array : A[0...n-1]Now, create a count array Cnt[0...n-1]then, initialize Cnt to zero

for(i=0...n-1)

Cnt[i]=0 ---------O(n) time

Linearly traverse the list and increment the count of respected number in count array.

for(i=0...n-1)

Cnt[A[i]]++; ---------O(n) time

Check in the count array if duplicates exist.

for(i=0...n-1){

if(C[i]>1)

output (i); -----------O(n) time

}

analysis of the above algorithm:

Algorithm takes = O(1 + n + n + n)

                           = O(n)          

//java code

public class SortIntegers {

  public static void sort(int[] arr) {

    int min = arr[0];

    int max = arr[0];

    for (int i = 0; i < arr.length; ++i) {

      if (arr[i] > max) {

        max = arr[i];

      }

      if (arr[i] < min) {

        min = arr[i];

      }

    }

    int counts[] = new int[max - min + 1];

    for (int i = 0; i < arr.length; ++i) {

      counts[arr[i] - min]++;

    }

    for (int i = 0; i < counts.length; ++i) {

      if (counts[i] > 1) {

        System.out.print((i + min) + " ");

      }

    }

    

    System.out.println();

  }

  public static void main(String[] args) {

    sort(new int[] { 5, 4, 10, 2, 4, 10, 5, 3, 1 });

  }

}

Other Questions
What is the value of x Can someone just help me? I'm doing a study guideWhy should questions for a lab not be a yes or no question? What does it mean to be a testable question? hello please help ill give brainliest I just dont see how to do this problem. I have been trying to solve it for hours but I skipped it and did the rest but I cant seem to figure it out. I dont really get it. Is this sentence in active or passive voice?As soon as the books were delivered, they were taken to the President.Passive VoiceActive Voice PLEASE HELP ASAP Find the value of x. Que es una redaccin Answer only if you know if you put links I will report Trish wants to put up a fence arounda rectangular garden. The gardenmeasures 2 feet by 21 feet. How muchfencing material is needed?Asap Which is an example of a way that a citizen can seek participation in an international organization? Miko and her parents rent boats for the afternoon. Her parents rent a canoe and Miko rents a kayak. It costs $20.49 to rent a canoe plus an additional $7.49 for each hour. It costs $17.99 to rent a kayak plus an additional $5.99 for each hour. Miko and her parents rent one canoe and one kayak for the same amount of time, and their total cost for the rentals is $78.92. Write and solve an equation to determine the amount of time, in hours, that they rented the kayak and canoe. A picnic basket was marked up 95% from an original cost of $9.57. Last Friday, Rosanne bought the picnic basket and paid an additional 8% in sales tax. What was her total cost? What kind of development works can be called sustainable development? What rhetorical strategy is in the following quotation? "A very agony ofself-abasement will be no armor against the poisoned shafts whichassumed superiority will hurl against me."allegorymetaphorsyllogism juxtaposition Jeremy needs more soap. He buys 12 bags of soap for 5 dollars. Each bag of soap has x number of bars inside. How many bars of soap does Jeremy have? Helpppp pleaseeee please pretty please NO LINKS OR I WILL REPORT YOU please give an explanation I will mark brainliest 5 and 6 you get 50 points HELP ME WITH THIS PLSSSSS A radio station disc jockey decides to set up three songs to play while hetakes a break. The first song lasts 2 minutes, the second song lasts3 minutes and the third song lasts 2 minutes. What is the longest amountof time the disc jockey can be gone on his break? Paradise Corporation budgets on an annual basis for its fiscal year. The following beginning and ending inventory levels (in units) are planned for next year. Beginning Inventory Ending Inventory Raw material* 56,000 66,000 Finished goods 96,000 66,000 * Three pounds of raw material are needed to produce each unit of finished product. If Paradise Corporation plans to sell 560,000 units during next year, the number of units it would have to manufacture during the year would be: