1. Engineering
  2. Computer Science
  3. i am having difficulty quotdebuggingquot this code here is the...

Question: i am having difficulty quotdebuggingquot this code here is the...

Question details

I am having difficulty "debugging" this code

package cse360assignl public class OrderedIntList { private int[] a; // array private int c:// counter OrderedIntList () a -new int[10]; public void insert (int v) int j ); for (int i- 0; i<c;i++j++) if(v<a[i]) break; for (int i = c-1; ij; ) a[i] ali--); public void print O f for (int i- 1; i<c; i++) if (î%5-0) System.out.printIn(); System.out.print(a[i]+Ч); }

Here is the instructions

In OrderedIntList.java, a list is implemented as an array of integer. The constructor creates an array of size 10. The insert method is supposed to the following. 1. 2. 3. Insert an integer into the list so the list is maintained in ascending order. Not insert a duplicate value If the array is full, then the value should be inserted (if not a duplicate) and the last value dropped off the end of the array The approach on the insert is to locate the position where the new value is to be inserted, move the other items down in the array, place the new value at the correct location and increase the count. The print method is to print the output in the format five integers per line, each separated by a tab. The last line contains any additional values.

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution