User Profile
Collapse
-
Priority queue based on a sorted linked list
I want to implement a priority queue based on a sorted linked list. The remove operation on the priority queue should remove the item with a smallest key. Can anybody give me an idea how to do that? -
I got the idea.
Thank you very much... -
Circular Linked List
I am trying to create a circular list that includes insert() , find() and remove() methodes. also a step() method that moves current along to the next link.
I still need to display the list by breaking the circle at some arbitrary point to print it on the screen. Does anyone have an idea how to do that?
Code:import javax.swing.JOptionPane; public class CLL { public class Link { int item=0;
-
-
Honestly, I didn't develop the code myself , but i understood the find() method how it works, i mean the one i gave and not your suggestion. My problem is that I am not good in java; means i couldn't translate your ideas into code even I understood them ; so please, if it is possible, translate this part of your suggestion into code:
"you must return variable "lowerBound " in your previous binary search algorithm to know the...Leave a comment:
-
this is what i've done for insert() and delete() methods using linear search:
public void insert(long value)
{
int j;
for(j=0; j<nElems; j++)
if (a[j]>value)
break;
for(int k=nElems; k>j; k--)
a[k]= a[k-1];
a[j] = value;
nElems++;
}
public boolean delete(long value)
{
int j = find(value);
if (j==nElems)
...Leave a comment:
-
This is what i've done so far for find() method:
[CODE=java]public int find(double searchKey)
{
int lowerBound = 0;
int upperBound = nElems-1;
int curIn;
while(true)
{
curIn = (lowerBound + upperBound ) / 2;
if(a[curIn]==searchKey)
return curIn;
else if(lowerBound > upperBound)...Leave a comment:
-
ordered array
I want to write some methods like insert(), delete() and find() in an ordered array using binary search
No activity results to display
Show More
Leave a comment: