Forum: Java Jul 24th, 2009 |
| Replies: 10 Views: 481 do i have to have a root node? what am i going to do with this class? |
Forum: Java Jul 24th, 2009 |
| Replies: 10 Views: 481 that's exactly why i'm confused too. In a node, there's a root for the info and a left and right link. and what i know is that a binary tree uses nodes.
In this exercise, this is what was given... |
Forum: Java Jul 24th, 2009 |
| Replies: 10 Views: 481 yes, i know. but i don't know how |
Forum: Java Jul 22nd, 2009 |
| Replies: 10 Views: 481 I don't think i've fix it.
here's what i did
public void BTreeInsert(BinaryTree myTree, int newItem) {
if ( myTree == null ) {
myTree = new BinaryTree(newItem);
} else { |
Forum: Java Jul 22nd, 2009 |
| Replies: 10 Views: 481 public void BTreeInsert(BinaryTree myTree, int newItem) {
if ( myTree == null ) {
myTree = new BinaryTree(newItem);
} else {
if ( newItem < myTree.root) {
... |
Forum: Java Jul 20th, 2009 |
| Replies: 10 Views: 481 Hello every one.
Basically i am trying to construct a binary tree. but there's a problem. When i run the program, there is an error. somewhere in the treeInsert method(). I am having difficulty... |
Forum: Java Mar 9th, 2009 |
| Replies: 9 Views: 693 pardon me, you said treeInsert(node). but mine is treeInsert(newItem). Am i wrong in doing this? because further you said treeInsert(node.left) which i can't do.. are your saying that it should be... |
Forum: Java Mar 3rd, 2009 |
| Replies: 9 Views: 693 Recursions the part where i break up.. the above method i posted should be recursive but it seems that isn't. I'm having a hard time figuring out because there are a lot of considerations in... |
Forum: Java Mar 2nd, 2009 |
| Replies: 9 Views: 693 No, the tree isn't for sorting. I want to put the numbers example 1,2,3,4,5 in the binary tree. then it should be like this:
1, is in the root.
2, is in the left of the root
3, is in the right... |
Forum: Java Feb 19th, 2009 |
| Replies: 9 Views: 693 the structure that i want to use is node or link..
do i use recursion on this? |
Forum: Java Feb 13th, 2009 |
| Replies: 9 Views: 693 I have a problem:
1.) How do you insert a sequence of integers into a binary tree? does anybody have an algorithm for it?
like input : 1, 5, 3, 4 ,2
binary tree:
1
... |
Forum: Java Jan 23rd, 2009 |
| Replies: 11 Views: 2,533 I guess it's just the matter of what you like, and on which is a lot easier. I have learn buffered reader. My prof. didn't teach us scanner. I heard about it from others that it is much easier to... |
Forum: Java Jan 23rd, 2009 |
| Replies: 6 Views: 373 Here's my idea, i have 2 queues, in which i kepp track of them by:
1st queue:
front and rear;
2nd queue:
front2 and rear.
before i had read your reply stephen84s, i decided to have two... |
Forum: Java Jan 22nd, 2009 |
| Replies: 6 Views: 373 ok i made revisions on the code i just posted:
public void compareTo(int item){
QueueNode temp = front;
while(temp != null){
if (temp.info > item)
temp.info = item;
... |
Forum: Java Jan 22nd, 2009 |
| Replies: 6 Views: 373 here is what i had so far:
public int compareTo(int x){
QueueNode temp = front;
while(temp != null){
if (temp.info > x)
temp.info = new queueNode(x);
... |
Forum: Java Jan 21st, 2009 |
| Replies: 6 Views: 373 In a queue, where elements in integers are added, how do i do this:
Inside the queue:
1 2 3 5 6 8
when I want to add a number, say 4, the output should be like:
1 2 3 4 5 6 8 |
Forum: Java Jan 21st, 2009 |
| Replies: 4 Views: 483 |
Forum: Java Jan 21st, 2009 |
| Replies: 4 Views: 483 Yes!.. :)
public String toString(){
String s = "[ ";
if (front.info != null){
s += "( " + peek().toString() + " )" + " ]";
}else{ |
Forum: Java Jan 21st, 2009 |
| Replies: 4 Views: 483 When you put an item on a queue, how do you show the items inside the queue? do you use peek method? the situation is a linked queue... |
Forum: Java Jan 16th, 2009 |
| Replies: 16 Views: 1,336 I can't do that, cause my job has to be linked list. :)
I'm pretty sure i am clear of what i want, but can't understand how to do it.. :|
thanks for your replies.
here's the edited code;
... |
Forum: Java Jan 15th, 2009 |
| Replies: 16 Views: 1,336 That's what im trying to do in the first place. :)
i did this:
public Node[] stack; // this is supposedly my array
stack = new Node[size2]; // this is what i had to... |
Forum: Java Jan 15th, 2009 |
| Replies: 16 Views: 1,336 Actually , i also didn't undertsand much about the T[] and oldT[] discussed int our lectures. As i know, T[] refers to the new tops that are computed using the garwick also in allocating memery.... |
Forum: Java Jan 14th, 2009 |
| Replies: 16 Views: 1,336 Because i was thinking that if the index is 1, then it would refer to the stack 1 and it would push the item in that stack. |
Forum: Java Jan 13th, 2009 |
| Replies: 16 Views: 1,336 Those T[], B[], and oldT[], keeps track of which stack you want, either stack1, stack2, and stack3.
If i chose stack1 to put an item, it pushes and is ok,but if i try to pop the item in which i put... |
Forum: Java Jan 12th, 2009 |
| Replies: 16 Views: 1,336 when you put an item in the shelf, is done by push method, and then try to retreive the item, done by pop, i doesn't have error, only just print's stack empty.. because i did specify in the code that... |
Forum: Java Jan 12th, 2009 |
| Replies: 16 Views: 1,336 T[] refers to he top and oldT[] is the old top.. becuase in the garwick's algo, oldT will get new T when new base pointers, represented as B[], are computed. |
Forum: Java Jan 12th, 2009 |
| Replies: 16 Views: 1,336 hello.. i really need help.. I don't know why i keep on getting an empty stack if i pop a token from stack even if user has already push a token into it..
public class MStack implements Stack{
... |
Forum: Java Jan 9th, 2009 |
| Replies: 2 Views: 414 i mean how can a link stack be in a sequential vector/ isn't a vector here an array? as in sequential representation of stacks are in array and when you say linked representation, its node. for me,... |
Forum: Java Jan 9th, 2009 |
| Replies: 2 Views: 414 can anyone clarify to me what this means? it's kind of comfusing..:)
linked stack embedded in a sequencial vector |
Forum: Java Jan 6th, 2009 |
| Replies: 12 Views: 3,045 here is what i did to compute the formula:
public void computeBase(){
int n = size;
int m = 3;
for (int i = 0; i <= 3; i++){
Base[i]= Math.floor(n/m) * i -1;
Object base =... |
Forum: Java Jan 1st, 2009 |
| Replies: 6 Views: 668 i think the code i posted isn't any good. (frown)
HAPPY NEW YEAR! every one.. hehe |
Forum: Java Jan 1st, 2009 |
| Replies: 12 Views: 3,045 I want to greet everyone here a happy new year!:) |
Forum: Java Jan 1st, 2009 |
| Replies: 12 Views: 3,045 that's supposedly be like this:
B[i] = [n/m] * i - 1,
Math.floor(n/m) => it should be th floor of the result..
i understand how to compute for the base pointers, but how do i get into which stack?... |
Forum: Geeks' Lounge Dec 29th, 2008 |
| Replies: 2 Views: 313 |
Forum: DaniWeb Community Feedback Dec 29th, 2008 |
| Replies: 38 Views: 9,704 hello.
can you change my user name to "ezkonekgal"
a lot of people know me by my current username, especially my classmate.. I don't want them to recognize me so much when i post to forums... |
Forum: Java Dec 29th, 2008 |
| Replies: 6 Views: 668 This is Garwick's algorithm:
1. Strip all the stacks of unused cells and consider all of the unused cells as comprising the available or free space.
2. Reallocate one to ten percent of the... |
Forum: Java Dec 29th, 2008 |
| Replies: 6 Views: 668 To have the bookshelf, i first created and array and this array has a stack. My problem is that i have to subdivide this array to have a multiple stack using base pointer.. I can't quite get the base... |
Forum: Java Dec 29th, 2008 |
| Replies: 12 Views: 3,045 This is what i have so far:
import java.io.*;
import java.util.*;
public class MStack {
/* Default length of the array */ |
Forum: Java Dec 28th, 2008 |
| Replies: 6 Views: 668 A book shop has bookshelves with adjustable dividers. When one divider becomes full, the divider could be adjusted to make space. Create a Java program that will reallocate bookshelf space using... |
Forum: Geeks' Lounge Dec 28th, 2008 |
| Replies: 2 Views: 313 How do you change your user i.d in this site?
pls help |