Help me to transalate this C++ into java

levelorder(root)
  q = empty queue
  q.enqueue(root)
  while not q.empty do
    node := q.dequeue()
    visit(node)
    if node.left ≠ null
      q.enqueue(node.left)
    if node.right ≠ null
      q.enqueue(node.right)and how would I put all the values here instead of in queue it's in an arraylist?

OK, an example:
We have the following tree:       e
    c     f
  b   d     g
aAnd we have your (borrowed) pseudo code:levelorder(root)
  q = empty queue
  q.enqueue(root)
  while not q.empty do
    node := q.dequeue()
    visit(node)
    if node.left ≠ null
      q.enqueue(node.left)
    if node.right ≠ null
      q.enqueue(node.right)Now, when you call levelorder(root), where root = node e, this is what happens:levelorder('e') {               // contents of queue
  new queue                             // [ ]
  queue.enqueue('e')                    // ['e']
  while(queue is not empty) {
    node = queue.dequeue() = 'e'        // [ ]
    if('e'.left is not null) {
      queue.enqueue('c')                // ['c']
    if('e'.right is not null) {
      queue.enqueue('f')                // ['c', 'f']
    // The end of the while here, but since
    // the queue is not empty, we continue
    node = queue.dequeue() = 'c'        // ['f']
    if('c'.left is not null) {
      queue.enqueue('b')                // ['f', 'b']
    if('c'.right is not null) {
      queue.enqueue('d')                // ['f', 'b', 'd']
    // The end of the while here, but since
    // the queue is not empty, we continue
    node = queue.dequeue() = 'f'        // ['b', 'd']
    if('f'.left is not null) {
    if('f'.right is not null) {
      queue.enqueue('g')                // ['b', 'd', 'g']
    // The end of the while here, but since
    // the queue is not empty, we continue
    node = queue.dequeue() = 'b'        // ['d', 'g']
    if('b'.left is not null) {
      queue.enqueue('a')                // ['d', 'g', 'a']
    if('b'.right is not null) {
    // The end of the while here, but since
    // the queue is not empty, we continue
    node = queue.dequeue() = 'd'        // ['g', 'a']
    if('d'.left is not null) {
    if('d'.right is not null) {
    // The end of the while here, but since
    // the queue is not empty, we continue
    node = queue.dequeue() = 'g'        // ['a']
    if('g'.left is not null) {
    if('g'.right is not null) {
    // The end of the while here, but since
    // the queue is not empty, we continue
    node = queue.dequeue() = 'a'        // [ ]
    if('a'.left is not null) {
    if('a'.right is not null) {
    // The queue is empty, stop looping
}Now if you look at the order of the dequeue sequence, you'll see the level-order traversal of the tree. Now when you dequeue each node from your queue, you could put those nodes inside an ArrayList (which seems what you're after).
Good luck.

Similar Messages

  • How can i rewrite this code into java?

    How can i rewrite this code into a java that has a return value?
    this code is written in vb6
    Private Function IsOdd(pintNumberIn) As Boolean
        If (pintNumberIn Mod 2) = 0 Then
            IsOdd = False
        Else
            IsOdd = True
        End If
    End Function   
    Private Sub cmdTryIt_Click()
              Dim intNumIn  As Integer
              Dim blnNumIsOdd     As Boolean
              intNumIn = Val(InputBox("Enter a number:", "IsOdd Test"))
              blnNumIsOdd = IsOdd(intNumIn)
              If blnNumIsOdd Then
           Print "The number that you entered is odd."
        Else
           Print "The number that you entered is not odd."
        End If
    End Sub

    873221 wrote:
    I'm sorry I'am New to Java.Are you new to communication? You don't have to know anything at all about Java to know that "I have an error," doesn't say anything useful.
    I'm just trying to get you to think about what your post actually says, and what others will take from it.
    what does this error mean? what code should i replace and add? thanks for all response
    C:\EvenOdd.java:31: isOdd(int) in EvenOdd cannot be applied to ()
    isOdd()=true;
    ^
    C:\EvenOdd.java:35: isOdd(int) in EvenOdd cannot be applied to ()
    isOdd()=false;
    ^
    2 errors
    Telling you "what code to change it to" will not help you at all. You need to learn Java, read the error message, and think about what it says.
    It's telling you exactly what is wrong. At line 31 of EvenOdd.java, you're calling isOdd(), with no arguments, but the isOdd() method requires an int argument. If you stop ant think about it, that should make perfect sense. How can you ask "is it odd?" without specifying what "it" is?
    So what is this all about? Is this homework? You googled for even odd, found a solution in some other language, and now you're just trying to translate it to Java rather than actually learning Java well enough to simply write this trivial code yourself?

  • Converting this VBScript into Java???

    HI
    I hava found this VBSCript. But I like to work on java.Is it possible to convert this into java code. Basically the script runs something in the remote machine. If its possible ,would u pls tell me what special package I need ??
    call execprog ("217.138.120.34","c:\acad_deploy\AdminImage\install.bat")
    sub ExecProg(ServerName, ProgramName)
    '     dim process as object, processid as long, result as long
         set process=getobject("WinMgmts:{impersonationLevel=Impersonate, authenticationLevel=pktPrivacy}\\" & servername & "\root\cimv2:Win32_Process")
         result=process.create(programname, null, null, processid)
         if result=0 then
             msgbox "Command executed successfully on remote machine"
         else
             msgbox "Some error, could not execute command"
         end if
    end sub Thanks in advance

    I hava found this VBSCript. But I like to work on
    java.Is it possible to convert this into java code.Yes, it is possible to convert the VBScript program in to Java code. You need to identify what the program (script) does and what the other programs are doing as well. (You said the VBscript calls other programs on remote machines). After this, design a way to implement same functionality with Java.
    Basically the script runs something in the remote
    machine.What "something"?
    If its possible ,would u pls tell me what
    special package I need ??It is possible, in order to convert the VBScript program to Java, you will have to create a Java package to contain the class hiearchy, i.e. com.admin.install.*
    And of course you will need packages from J2SE and possibly J2EE. The Runtime and Process classes from J2SE are examples what is available. These objects can be used to used to call the other programs. Your design will depend on details of the other programs.
    Do you plan on converting the "install.ba" program to Java as well?

  • Please help C++ into java.

    Hello,
    I am working one small swing program. And want to know about c++ code. Can any one tell me that can we convert the c++ code into java code. My c++ code is:
    void Activity::computeInternalStructure(Rules& r)
         //the internal subgroups list must be computed before entering here.
         //teachers
         //this->nTeachers=0;
         this->iTeachersList.clear();
         for(QStringList::Iterator it=this->teachersNames.begin(); it!=this->teachersNames.end(); it++){
              int tmp;
              for(tmp=0; tmp<r.nInternalTeachers; tmp++){
                   if(r.internalTeachersList[tmp]->name == (*it))
                        break;
              assert(tmp < r.nInternalTeachers);
              //assert(this->nTeachers<MAX_TEACHERS_PER_ACTIVITY);
              //this->teachers[this->nTeachers++]=tmp;
              this->iTeachersList.append(tmp);
         //subjects
         this->subjectIndex = r.searchSubject(this->subjectName);
         assert(this->subjectIndex>=0);
         //activity tags
         this->iActivityTagsSet.clear();
         foreach(QString tag, this->activityTagsNames)
              assert(tag!="");
              int index=r.searchActivityTag(tag);
              assert(index>=0);
              this->iActivityTagsSet.insert(index);
         //this->activityTagIndex = r.searchActivityTag(this->activityTagName);
         //students     
         //this->nSubgroups=0;
         this->iSubgroupsList.clear();
         for(QStringList::Iterator it=this->studentsNames.begin(); it!=this->studentsNames.end(); it++){
              StudentsSet* ss=r.searchAugmentedStudentsSet(*it);
              assert(ss);
              if(ss->type==STUDENTS_SUBGROUP){
                   int tmp;
                   /*for(tmp=0; tmp<r.nInternalSubgroups; tmp++)
                        if(r.internalSubgroupsList[tmp]->name == ss->name)
                             break;*/
                   tmp=((StudentsSubgroup*)ss)->indexInInternalSubgroupsList;
                   assert(tmp>=0);
                   assert(tmp<r.nInternalSubgroups);
                   //assert(this->nSubgroups<MAX_SUBGROUPS_PER_ACTIVITY);
                   bool duplicate=false;
                   if(this->iSubgroupsList.contains(tmp))
                   //for(int j=0; j<this->nSubgroups; j++)
                   //     if(this->subgroups[j]==tmp)
                             duplicate=true;
                   if(duplicate){
                        QString s;
                        s=QObject::tr(QString("Warning: activity with id=%1\ncontains duplicated subgroups. Automatically correcting..."))
                             .arg(this->id);               
                        cout<<qPrintable(s)<<endl;
                   else
                        this->iSubgroupsList.append(tmp);
                        //this->subgroups[this->nSubgroups++]=tmp;
              else if(ss->type==STUDENTS_GROUP){
                   StudentsGroup* stg=(StudentsGroup*)ss;
                   for(int k=0; k<stg->subgroupsList.size(); k++){
                        StudentsSubgroup* sts=stg->subgroupsList[k];
                        int tmp;
                        /*for(tmp=0; tmp<r.nInternalSubgroups; tmp++)
                             if(r.internalSubgroupsList[tmp]->name == sts->name)
                                  break;*/
                        tmp=sts->indexInInternalSubgroupsList;
                        assert(tmp>=0);
                        assert(tmp<r.nInternalSubgroups);
                        //assert(this->nSubgroups<MAX_SUBGROUPS_PER_ACTIVITY);
                        bool duplicate=false;
                        if(this->iSubgroupsList.contains(tmp))
                        //for(int j=0; j<this->nSubgroups; j++)
                        //     if(this->subgroups[j]==tmp)
                                  duplicate=true;
                        if(duplicate){
                             QString s;
                             s=QObject::tr(QString("Warning: activity with id=%1\ncontains duplicated subgroups. Automatically correcting..."))
                                  .arg(this->id);
                             cout<<qPrintable(s)<<endl;
                        else
                             //this->subgroups[this->nSubgroups++]=tmp;
                             this->iSubgroupsList.append(tmp);
              else if(ss->type==STUDENTS_YEAR){
                   StudentsYear* sty=(StudentsYear*)ss;
                   for(int k=0; k<sty->groupsList.size(); k++){
                        StudentsGroup* stg=sty->groupsList[k];
                        for(int l=0; l<stg->subgroupsList.size(); l++){
                             StudentsSubgroup* sts=stg->subgroupsList[l];
                             int tmp;
                             /*for(tmp=0; tmp<r.nInternalSubgroups; tmp++)
                                  if(r.internalSubgroupsList[tmp]->name == sts->name)
                                       break;*/
                             tmp=sts->indexInInternalSubgroupsList;
                             assert(tmp>=0);
                             assert(tmp<r.nInternalSubgroups);
                             //assert(this->nSubgroups<MAX_SUBGROUPS_PER_ACTIVITY);
                             bool duplicate=false;
                             if(this->iSubgroupsList.contains(tmp))
                             //for(int j=0; j<this->nSubgroups; j++)
                             //     if(this->subgroups[j]==tmp)
                                       duplicate=true;
                             if(duplicate){
                                  QString s;
                                  s=QObject::tr(QString("Warning: activity with id=%1\ncontains duplicated subgroups. Automatically correcting..."))
                                       .arg(this->id);
                                  QObject::tr("&Ok"));
                                  cout<<qPrintable(s)<<endl;
                             else{
                                  //this->subgroups[this->nSubgroups++]=tmp;
                                  this->iSubgroupsList.append(tmp);
              else
                   assert(0);
    }Please help me. In this code we are using some variables. with QT GUI in c++.
    Thanks in advance.
    Manveer.

    Manveer-Singh wrote:
    Hello,
    I am working one small swing program. And want to know about c++ code. Can any one tell me that can we convert the c++ code into java code. My c++ code is:
    void Activity::computeInternalStructure(Rules& r)
         //the internal subgroups list must be computed before entering here.
         //teachers
         //this->nTeachers=0;
         this->iTeachersList.clear();
         for(QStringList::Iterator it=this->teachersNames.begin(); it!=this->teachersNames.end(); it++){
              int tmp;
              for(tmp=0; tmp<r.nInternalTeachers; tmp++){
                   if(r.internalTeachersList[tmp]->name == (*it))
                        break;
              assert(tmp < r.nInternalTeachers);
              //assert(this->nTeachers<MAX_TEACHERS_PER_ACTIVITY);
              //this->teachers[this->nTeachers++]=tmp;
              this->iTeachersList.append(tmp);
         //subjects
         this->subjectIndex = r.searchSubject(this->subjectName);
         assert(this->subjectIndex>=0);
         //activity tags
         this->iActivityTagsSet.clear();
         foreach(QString tag, this->activityTagsNames)
              assert(tag!="");
              int index=r.searchActivityTag(tag);
              assert(index>=0);
              this->iActivityTagsSet.insert(index);
         //this->activityTagIndex = r.searchActivityTag(this->activityTagName);
         //students     
         //this->nSubgroups=0;
         this->iSubgroupsList.clear();
         for(QStringList::Iterator it=this->studentsNames.begin(); it!=this->studentsNames.end(); it++){
              StudentsSet* ss=r.searchAugmentedStudentsSet(*it);
              assert(ss);
              if(ss->type==STUDENTS_SUBGROUP){
                   int tmp;
                   /*for(tmp=0; tmp<r.nInternalSubgroups; tmp++)
                        if(r.internalSubgroupsList[tmp]->name == ss->name)
                             break;*/
                   tmp=((StudentsSubgroup*)ss)->indexInInternalSubgroupsList;
                   assert(tmp>=0);
                   assert(tmp<r.nInternalSubgroups);
                   //assert(this->nSubgroups<MAX_SUBGROUPS_PER_ACTIVITY);
                   bool duplicate=false;
                   if(this->iSubgroupsList.contains(tmp))
                   //for(int j=0; j<this->nSubgroups; j++)
                   //     if(this->subgroups[j]==tmp)
                             duplicate=true;
                   if(duplicate){
                        QString s;
                        s=QObject::tr(QString("Warning: activity with id=%1\ncontains duplicated subgroups. Automatically correcting..."))
                             .arg(this->id);               
                        cout<<qPrintable(s)<<endl;
                   else
                        this->iSubgroupsList.append(tmp);
                        //this->subgroups[this->nSubgroups++]=tmp;
              else if(ss->type==STUDENTS_GROUP){
                   StudentsGroup* stg=(StudentsGroup*)ss;
                   for(int k=0; k<stg->subgroupsList.size(); k++){
                        StudentsSubgroup* sts=stg->subgroupsList[k];
                        int tmp;
                        /*for(tmp=0; tmp<r.nInternalSubgroups; tmp++)
                             if(r.internalSubgroupsList[tmp]->name == sts->name)
                                  break;*/
                        tmp=sts->indexInInternalSubgroupsList;
                        assert(tmp>=0);
                        assert(tmp<r.nInternalSubgroups);
                        //assert(this->nSubgroups<MAX_SUBGROUPS_PER_ACTIVITY);
                        bool duplicate=false;
                        if(this->iSubgroupsList.contains(tmp))
                        //for(int j=0; j<this->nSubgroups; j++)
                        //     if(this->subgroups[j]==tmp)
                                  duplicate=true;
                        if(duplicate){
                             QString s;
                             s=QObject::tr(QString("Warning: activity with id=%1\ncontains duplicated subgroups. Automatically correcting..."))
                                  .arg(this->id);
                             cout<<qPrintable(s)<<endl;
                        else
                             //this->subgroups[this->nSubgroups++]=tmp;
                             this->iSubgroupsList.append(tmp);
              else if(ss->type==STUDENTS_YEAR){
                   StudentsYear* sty=(StudentsYear*)ss;
                   for(int k=0; k<sty->groupsList.size(); k++){
                        StudentsGroup* stg=sty->groupsList[k];
                        for(int l=0; l<stg->subgroupsList.size(); l++){
                             StudentsSubgroup* sts=stg->subgroupsList[l];
                             int tmp;
                             /*for(tmp=0; tmp<r.nInternalSubgroups; tmp++)
                                  if(r.internalSubgroupsList[tmp]->name == sts->name)
                                       break;*/
                             tmp=sts->indexInInternalSubgroupsList;
                             assert(tmp>=0);
                             assert(tmp<r.nInternalSubgroups);
                             //assert(this->nSubgroups<MAX_SUBGROUPS_PER_ACTIVITY);
                             bool duplicate=false;
                             if(this->iSubgroupsList.contains(tmp))
                             //for(int j=0; j<this->nSubgroups; j++)
                             //     if(this->subgroups[j]==tmp)
                                       duplicate=true;
                             if(duplicate){
                                  QString s;
                                  s=QObject::tr(QString("Warning: activity with id=%1\ncontains duplicated subgroups. Automatically correcting..."))
                                       .arg(this->id);
                                  QObject::tr("&Ok"));
                                  cout<<qPrintable(s)<<endl;
                             else{
                                  //this->subgroups[this->nSubgroups++]=tmp;
                                  this->iSubgroupsList.append(tmp);
              else
                   assert(0);
    }Please help me. In this code we are using some variables. with QT GUI in c++.
    Thanks in advance.
    Manveer.why do you say this?
    My c++ code is:and
    In this code we are using some variables. with QT GUI in c++. You didn't code that. Liviu Lalescu code that, not you.
    He has rights on that code and he published it under gpl.
    So you must say that it is from him, not from you.
    Also if you "translate" (modify) his algorithm you must still care about the gpl. Please read whole gpl and care about that.
    Regards,
    Volker Dirr
    PS:
    compare original code from Liviu at sourceforge or at his homepage:
    http://lalescu.ro/liviu/fet/
    you can see the copied copy in /src/engine/activity.cpp line 167 and following.

  • How to convert Property files into Java Objects.. help needed asap....

    Hi..
    I am currently working on Internationalization. I have created property files for the textual content and using PropertyResourceBundles. Now I want to use ListResourceBundles. So what I want to know is..
    How to convert Property files into Java Objects.. I think Orielly(in their book on Internationalization) has given an utitlity for doing this. But I did not get a chance to look into that. If anyone has come across this same issue, can you please help me and send the code sample on how to do this..
    TIA,
    CK

    Hi Mlk...
    Thanks for all your help and suggestions. I am currently working on a Utility Class that has to convert a properties file into an Object[][].
    This will be used in ListResourceBundle.
    wtfamidoing<i>[0] = currentKey ;
    wtfamidoing<i>[1] = currentValue ;I am getting a compilation error at these lines..(Syntax error)
    If you can help me.. I really appreciate that..
    TIA,
    CK

  • Help on upgrading this code to Java 5

    Hi guys,
    I was trying to upgrading the following code to comply with Java 5 using generics, but I failed. Hope somebody here can help me out of this.
    This is the original code:
    import java.util.*;
    public class TestJava5{
        public static void main(String [] args){
            TestJava5 t = new TestJava5();
            Collection strs = t.getAll(String.class);
            for(Iterator i = strs.iterator(); i.hasNext();){
                System.out.println(i.next());
        private Collection getAll(Class c){
            Collection rs = new ArrayList ();
            if(String.class.equals(c)){
                rs.add("str1");
                rs.add("str2");
            }else if(StringBuffer.class.equals(c)){
                rs.add(new StringBuffer("buffer1"));
                rs.add(new StringBuffer("buffer2"));
            return rs;
    }and this is the code I tried to use generics, but obviously, I cannot add a String or StringBuffer into a Collection<T>.
    import java.util.*;
    public class TestJava5{
        public static void main(String [] args){
            TestJava5 t = new TestJava5();
            Collection<String> strs = t.getAll(String.class);
            for(String str:strs){
                System.out.println(str);
        private <T> Collection<T> getAll(Class<T> c){
            Collection<T> rs = new ArrayList<T>();
            if(String.class.equals(c)){
                rs.add("str1");
                rs.add("str2");
            }else if(URI.class.equals(c)){
                rs.add(new StringBuffer("buffer1"));
                rs.add(new StringBuffer("buffer2"));
            return rs;
    }

    Actually, now I've looked at it, it's even worse than that!
    You create a collection with type T, but this type is not fixed at compile type (by definition, obviously). So when you come to add something to the collection (either a String or a StringBuffer), the compiler cannot guarantee that your collection is of the correct type.
    This code is really on a hiding to nothing, I would suggest. But... the following should relieve your immediate compilation problems. However, it is likely to cause further problems when trying to use the returned collection:
      private <T> Collection<?> getAll2(Class<T> c) {
        if (String.class.equals(c)) {
          Collection<String> rs = new ArrayList<String>();
          rs.add("str1");
          rs.add("str2");
          return rs;
        } else if (URI.class.equals(c)) {
          Collection<StringBuffer> rs = new ArrayList<StringBuffer>();
          rs.add(new StringBuffer("buffer1"));
          rs.add(new StringBuffer("buffer2"));
          return rs;
        } else {
          return null;  // or something else like new ArrayList<Object>()
      }

  • Importing XML into Java.  Help needed Please!!!

    Hi,
    I have downloaded j2sdk1.4.1_05 and want to configure it to import XML files into a DOM in Java. I am having trouble doing this and need help. I read that version 1.4 support JAXP 1.1 but I am having trouble finding the JAXP-api.jar file. It says to put all the other Jar files into a folder and leave the JAXP-api.jar.
    Could you please tell me how to set up Java so that I can import an XML file. I also downloaded JAXP 1.2. But there seems to be no installer.
    Thanx John

    You can learn about reading xml in java by reading the J2EE tutorial at
    http://java.sun.com/j2ee/1.4/docs/tutorial/doc/
    Here is sample program to read XML file into a DOM taken from this tutorial
    (http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JAXPXSLT4.html)
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.FactoryConfigurationError;
    import javax.xml.parsers.ParserConfigurationException;
    import org.xml.sax.SAXException;
    import org.xml.sax.SAXParseException;
    import org.w3c.dom.Document;
    import org.w3c.dom.DOMException;
    import java.io.*;
    public class TransformationApp
      static Document document;
      public static void main(String argv[])
        if (argv.length != 1) {
          System.err.println (
            "Usage: java TransformationApp filename");
          System.exit (1);
        DocumentBuilderFactory factory =
          DocumentBuilderFactory.newInstance();
        //factory.setNamespaceAware(true);
        //factory.setValidating(true);
        try {
          File f = new File(argv[0]);
          DocumentBuilder builder =
            factory.newDocumentBuilder();
          document = builder.parse(f);
        } catch (SAXParseException spe) {
          // Error generated by the parser
          System.out.println("\n** Parsing error"
            + ", line " + spe.getLineNumber()
            + ", uri " + spe.getSystemId());
          System.out.println("  " + spe.getMessage() );
          // Use the contained exception, if any
          Exception x = spe;
          if (spe.getException() != null)
            x = spe.getException();
          x.printStackTrace();
        } catch (SAXException sxe) {
          // Error generated by this application
          // (or a parser-initialization error)
          Exception x = sxe;
          if (sxe.getException() != null)
            x = sxe.getException();
          x.printStackTrace();
        } catch (ParserConfigurationException pce) {
          // Parser with specified options can't be built
          pce.printStackTrace();
        } catch (IOException ioe) {
          // I/O error
          ioe.printStackTrace();
      } // main
    } If you have java 1.4 sdk installed everything should compile and run. Separate
    JAXP package is nor required - JAXP is included in rt.jar in java-home-directory/jre/lib.

  • Converting flash into java script - please help!

    Our site uses a lot of flash text and flash images, I have
    been told by a friend of a friend that i need to change the way
    flash is embedded into java script - i only know the basics of web
    design and this is me hitting brick wall!
    Maybe someone could help point me in the right direction -
    simply! thank you in advance!!!!!!!!!!!!!!!!!!!!!!!!!!

    which version of dw do you have?
    for background info, google EOLAS activeX lawsuit
    Alan
    Adobe Community Expert, dreamweaver
    http://www.adobe.com/communities/experts/

  • Please help! converting c++ into java

    Thanks to the people who helped me with my last bit of text - greatly appreciated, i need a bit more help though, with calculating a basic similarity matrix and clustering. Here is what i have........
    void CalcBasicSimMatrix(int nEnt, int nAtt, Entity EAM[], double BSM [100][100]) //problem here*
    for (int i=0; i<nEnt; i++)
    for (int j=0; j<nEnt; j++)
    BSM[i][j]=BasicSimBetweenEnt(i, j, nAtt, EAM); //problem here*
    double BasicSimBetweenEnt(i, j, nAtt, EAM); //problem here*
    double a=0, t=0;
    for (int i=0; i<nAtt; i++)
    if(AT[n].Attribute==1 && AT[m].Attribute[i]==1)//problem here*
    a++;
    else
    t++;
    return a/(a+t); // is this same in java?
    struct Cluster
    int ent[100];
    int n;
    cluster Clusters[100]; //?
    void initialiseClusters() //?
    nClusters=0;
    for(int k=0; k<nEntities; k++)
    Clusters[k].n=1; //?
    Clusters[k].ent[0]=k; //?
    nClusters++;
    void PerformClustering() //?
    int method;
    double SimThreshold;
    max=100;
    InitialiseClusters(); //?
    cout<<"Enter clustering method(1=Ave Link, 2=Min Link, 3=Max Linkage):";
    cin>>method;
    cout<<"Enter similarity threshold(enter '0' if none required):";
    cin>>SimThreshold;
    while(nClusters>0 && max>0 && max>SimThreshold)
    MostSimilarClusters(method);
    if(nClusters>1)
    MergeClusters(x,y);
    The code for merging clusters also makes no sense...............
    Any help is greatfully received.Thanks.

    Now, I am assuming you are trying to learn Java, but have also been a C++ user. Here are some questions I need to ask:
    Is there a C++ course in Ojbect-Oriented Programming offered to where you are?
    What is this code suppose to do?
    What parameters does it accept?
    What are the return values?
    Is this is a recursion part of code for something larger?

  • Hello Sorry for the inconvenience, but I have a problem in Java I can not open files, audio chat, which type of jnlp after the last update of the Java 2012-004 Please help me in solving this problem.

    Hello Sorry for the inconvenience, but I have a problem in Java I can not open files, audio chat, which type of jnlp after the last update of the Java 2012-004
    Please help me in solving this problem. 

    Make sure Java is enable in your browser's security settings.
    Open Java Preferences (in Utilities folder)
    Make sure Web-start applications are enabled.
    Drag Java 32-bit to the top of the list.
    jnlp isn't an audio file format. It's just a java web-start program (Java Network Launching Protocol).

  • How to transform this pascal code into java code!

    I want to transform this pascal code into java code . Please tel me how to do it because I really don't know how to do it!
    Thanks!
    {CALCULATE HOHN-LONDON FACTORS}
    var kk:tab4;
    PROCEDURE INTENS(var kk:tab4);
    begin
    for n:=0 to nr+2 do
    begin
    kk^[1,n]:=sqrt(lup*lup*yg*(yg-4)+4*sqr(n+1)) +lup*(yg-2);
    kk^[2,n]:= sqrt(lup*lup*yg*(yg-4)+4*sqr(n+1))-lup*(yg-2);
    kk^[3,n]:=0.5*(kk^[1,n]*kk^[1,n]+4*(sqr(n+1)-lup*lup));
    kk^[4,n]:= 0.5*(kk^[2,n]*kk^[2,n]+4*(sqr(n+1)-lup*lup));
    kk^[5,n]:= sqrt(ldown*ldown*yd*(yd-4)+4*sqr(n+1)) +ldown*(yd-2);
    end;
    end;
    BEGIN
    new (kk);
    intens(kk);
    writeln(f2,' ','N ','V','branch ','H-L');
    for n:=1 to np do
    begin
    fp1[n,v]:=(n-ldown)*(n+ldown+1)*sqr(kk^[2,n-1]*kk^[6,n]+4*(n+ldown)*(n-ldown+1));
    fp1[n,v]:=fp1[n,v]/(4*(n+0.5)*kk^[4,n-1]*kk^[8,n]) ;
    writeln(f2,' ',n,' ',v,' fp1 ',fp1[n,v]:10:2);
    end;
    for n:=1 to nq do
    begin
    fq1[n,v]:=sqr(kk^[2,n]*kk^[6,n]*(ldown+0.5)+4*(n-ldown+1)*(n+ldown+1)*(ldown-0.5)) ;
    fq1[n,v]:=fq1[n,v]/(2*(n+0.5)*kk^[4,n]*kk^[8,n]*(n+1.5));
    fq1[n,v]:=fq1[n,v]*(n+1);
    writeln(f2,' ',n,' ',v,' fq1 ',fq1[n,v]:10:2);
    end;
    for n:=1 to nr do
    begin
    fr1[n,v]:=sqr(kk^[2,n+1]*kk^[6,n]+4*(n-ldown+2)*(n+ldown+1));
    fr1[n,v]:=fr1[n,v]/(4*kk^[4,n+1]*kk^[8,n]*(n+1.5));
    fr1[n,v]:=fr1[n,v]*(n-ldown+1)*(n+ldown+2) ;
    writeln(f2,' ',n,' ',v,' fr1 ',fr1[n,v]:10:2);
    end;

    Basically it looks like this:
    public class KK{
         private your_type[][] kk = new your_type[length][length];
         private void intens(your_type[] kk){
              for(int n= 0; n<nr+2; n++){
                   kk[1][n] = Math.sqrt(lup*lup*yg*(yg-4)+4*Math.pow((n+1), 2)) +lup*(yg-2);
                   kk[2][n] = Math.sqrt(lup*lup*yg*(yg-4)+4*Math.pow((n+1), 2))-lup*(yg-2);
                   kk[3][n] = 0.5*(kk[1][n]*kk[1][n]+4*(Math.pow((n+1), 2)-lup*lup));
                   kk[4][n] = 0.5*(kk[2][n]*kk[2][n]+4*(Math.pow((n+1), 2)-lup*lup));
                   kk[5][n] = Math.sqrt(ldown*ldown*yd*(yd-4)+4*Math.pow((n+1), 2)) +ldown*(yd-2);
         public static void main(String args[]){
              KK k = new KK();
              k.intens(kk);
              System.out.println(f2  + ' ' + 'N ' + 'V' + 'branch ' + 'H-L');
              for(int n=1; n < np; n++){
                   fp1[n][v] = (n-ldown)*(n+ldown+1)*Math.pow((kk[2][n-1]*kk[6][n]+4*(n+ldown)*(n-ldown+1)), 2);
                   fp1[n][v] = fp1[n][v]/(4*(n+0.5)*kk[4][n-1]*kk[8][n]) ;
                   System.out.println(f2 + ' ' + n + ' ' + v + ' fp1 ' + fp1[n][v]:10:2);
              for(int n=1; n< nq;n++){
                   fq1[n][v] = Math.pow((kk[2][n]*kk[6][n]*(ldown+0.5)+4*(n-ldown+1)*(n+ldown+1)*(ldown-0.5)), 2);
                   fq1[n][v] = fq1[n][v]/(2*(n+0.5)*kk[4][n]*kk[8][n]*(n+1.5));
                   fq1[n][v] = fq1[n][v]*(n+1);
                   System.out.println(f2 + ' ' + n + ' ' + v + ' fq1 ' + fq1[n][v]:10:2);
              for(int n=1; n < nr; n++){
                   fr1[n][v] = Math.pow((kk[2][n+1]*kk[6][n]+4*(n-ldown+2)*(n+ldown+1)), 2);
                   fr1[n][v] = fr1[n][v]/(4*kk[4][n+1]*kk[8][n]*(n+1.5));
                   fr1[n][v] = fr1[n][v]*(n-ldown+1)*(n+ldown+2) ;
                   System.out.println(f2 + ' ' + n + ' ' + v + ' fr1 ' + fr1[n][v]:10:2); //fr1[n][v]:10:2 --> Here you must use the BigDecimal class
    }I'm not very sure because my pascal knowledge is extremely "dated".
    What about the converter I told you about?

  • My Iphone 4 is changing screens without me touching it. I will be in a msg and it will jump out of that msg and into another one... can anyone please help me with what this could be?

    my Iphone 4 is changing screens without me touching it. I will be in a msg and it will jump out of that msg and into another one... can anyone please help me with what this could be?

    Try the basics from the manual.
    restart.
    reset.
    restore.
    iPhone User Guide (For iOS 4.2 and 4.3 Software)

  • Hi im trying to sign into my new icloud account but it keeps saying "this operation cannot be completed" help, hi im trying to sign into my new icloud account but it keeps saying "this operation cannot be completed" help

    hi im trying to sign into my new icloud account but it keeps saying "this operation cannot be completed" help, hi im trying to sign into my new icloud account but it keeps saying "this operation cannot be completed" help.

    Have you looked at the previous discussions listed on the right side of this page under the heading "More Like This"?

  • I have an Ipod 4th gen. and when you plug it into the wall it is stuck on the charge/lighting bolt screen and it wont charge, and when you plug it into a computer (PC) the lighting screen wont even apear. Please help I have had this problem for forever.

    I have a ipod touch 4th gen and it wont chrage. When you plug it into the wall the lightniing bolt screen will apear but no matter how long you leave it, it will never turn on. Also it the lightning bolt screen wont even come on when you plug it into a computer (PC)..........PLease help its been like this for forever

    Hi Gammer576775!
    Here is an article that will help you troubleshoot this issue with your iPod touch:
    iPod touch: Hardware troubleshooting
    http://support.apple.com/kb/ts2771
    Will not power on, or will not turn on unless connected to power
    Verify that the Sleep/Wake button functions. If it does not function, inspect it for signs of damage. If the button is damaged or is not functioning when pressed, seek service.
    Connect the iPod touch to an Apple USB power adapter and let it charge for at least ten minutes.
    After at least 15 minutes, if the display turns on and…
    The home screen appears, the device should be working. Continue charging it until it is completely charged and you see this battery icon in the upper-right corner of the screen: . Then disconnect the device from power. If it immediately turns off, seek service.
    The low-battery image appears even after the iPod touch has charged for at least 20 minutes: See the "iPod touch displays the low-battery image and is unresponsive" symptom in this article.
    Something other than the Home screen or low-battery image appears , continue with this article for further troubleshooting steps.
    If the iPod touch did not turn on, reset it while connected to an Apple USB power adapter. If the display turns on, go to step 4.If the display remains black, go to the next step.
    Restore the device. Connect it to a computer and open iTunes. If iTunes recognizes it and indicates that it is in recovery mode, attempt to restore the iPod touch. If the device doesn't appear in iTunes or if you have difficulties in restoring it, see this article for further assistance.
    If restoring the iPod touch resolved the issue, go to step 4. If restoring it did not solve the issue, seek service.
    Thanks for using the Apple Support Communities!
    Cheers,
    Braden

  • Can anybody help me set this code into an array?

    Thanks, can you help me understand how to make an array work?
    I need to fade toggle a different country png for each country button and fade out the rest of the country images i.e.: when i click the UK button i need to fade toggle the UK png and fade out the other countries
    when i click the USA button i need to fade toggle the USA ing and fade out the other countries and so on
    sym.getSymbol("Countries").$("UK").fadeToggle();sym.getSymbol("Countries").$("USA","AUS","Hongkong","Switzerland","Ireland","Indias","Japa n","Netherlands","Spain").fadeOut();
    sym.getSymbol("Countries").$("USA").fadeToggle();sym.getSymbol("Countries").$("UK","AUS","Hongkong","Switzerland","Ireland","Indias","Japan ","Netherlands","Spain").fadeOut();
    etc
    but it doesn't seem to work how i have it and i have been told to do an array but I'm not sure how?
    Project here if you want to have a look:
    Dropbox - Countries.zip
    can you help?

    I think this[var = sym.getSymbol (Stanbuttons).$(".UK_stan, .USA_stan"); ] should be
    var myvar = sym.getSymbol (Stanbuttons).$(".UK_stan, .USA_stan");
    And than
    myvar.each(function(){
    $(this).fadeOut();

Maybe you are looking for

  • VPRS Cost Determination in Billing document

    Dear Friends,   We are facing an issue in cost determination,  we are creating intercompany billing between the companies.  As part of price determination, we determine standard cost from the material master for price calculation.  Addtionally, we ar

  • Black dashes printing at top of print jobs

    When I print there are black dashes at the top of my documents. They are not smudges. I print from Adobe Photoshop Elements, non traditional sizes to HP Photosmart All In One. Any ideas how to get rid of them. I print stationery so the dashes must go

  • PPro CS6, error reading *.psd files

    My old NLE laptop is dying, so I built a new desktop earlier this year and loaded Production Premium CS6 on it as my second copy. Laptop is retired now, more or less, and the desktop is all I use. This installation went on without a hitch, took my se

  • Content-length in HTTP Post request

    Hi all, I have a problem with a Http request. I send data in a POST to a servlet, but the KVM doesn't set the Content-Length correctly. How can I do ? The code : conn = (HttpConnection) Connector.open(m_strServer); conn.setRequestMethod(HttpConnectio

  • Re: ASSISTANCE PLEASE HDMI problem with Humax DTRT...

     Hi starting this new thread as the one I have posted on has not been replied to yet and do not know how to flag it up for a reply!? Hi have just found this thread.  I had problems last October when my youview box which was installed in May the sound