I am having some problems printing an inOrder traversal of my binary tree. Even after inserting many items into the tree it's only printing 3 items.
public class BinaryTree {
private TreeNode root;
private int size;
public BinaryTree(){
this.size = 0;
}
public boolean insert(TreeNode node){
if( ro...
#include <iostream>
#include <fstream>
using namespace std;
int calculate_total(int exam1[], int exam2[], int exam3[]); // function that calcualates grades to see how many 90,80,70,60
int exam1[100];// array that can hold 100 numbers for 1st column
int exam2[100];// array that can hold 100 numbers for 2nd column
...
There are different collections are used in Java like hashtable, hashset, vector, treeset, treemap and hashmap. How are they implemented internally? What are the actual datastructure used for these collection? And, What is order?
It would be good if we discuss just a little bit about implementation of collection.
Thanks,
-Abhishek
...
I'm having problems getting my processor to simulate correctly and I think I've narrowed it down to the program I'm giving it.
1. li $R1, 0
2. li $R2, 0x100
3. li $R6, 1
4. li $R8, 0
5. li $R9, 20
6. lw $R3, 0($R1)
7. lw $R4, 4($R1)
8. add $R5, $R3, $R4
9. srlv $R5, $R5, $R6
10. sw $R5, 0($R2)
11. ad...
Hello all
I got this question which asks me to figure out why is it foolish to write a regular expression for the language that consists of strings of 0's and 1's that are palindromes( they read the same backwards and forwards).
part 2 of the question says using any formal mechanism of your choice, show how it is possible to express t...
I'm new to Java and for a HW assignment, we had to create a Person class that has a constructor, getter/setter for the attributes of firstName, lastName, phone. That is in a separate file from an old HW assignment (Person.java). Now we have to use that Person class in our new HW assignment (LoanApplication.java). So if one of the attr...
I have to write a method that returns a linked list with all the nodes that are common to two linked lists using recursion, without loops.
For example,
first list is 2 -> 5 -> 7 -> 10
second list is 2 -> 4 -> 8 -> 10
the list that would be returned is 2 -> 10
I am getting nowhere with this.. What I have been think of was to check ...
The question :
Input file: customer’s account number, account balance at
beginning of month, transaction type (withdrawal, deposit,
interest), transaction amount
Output: account number, beginning balance, ending balance,
total interest paid, total amount deposited, number of
deposits, total amount withdrawn, number of withdrawals
pac...
i need help enumerating all possible combinations of length n given a list of strings.
example, if my list was ["r","b","g"] and int 2
answer:
r r,
r b,
r g,
b r,
b b,
b g,
g r,
g b,
g g,
...
Hi there,
I need to use the fork() and wait() functions to complete an assignment. We are modelling non-deterministic behaviour and need the program to fork() if there is more than one possible transition.
In order to try and work out how fork and wait work, I have just made a simple program. I think I understand now how the calls work...
I want the number of address book items to be variable - not known in advance; I am thinking that using a linked list is the right choice?
"The user can enter new person data, or print the data for a given name, the asking data need not be a name but also an address on a telephone number, the program prints the whole information abou...
Hi Guys,
Im creating a little database that has employee, emp_shift, shift, tables
now im suppose to be able to calculate at the end of the month which employee
has done the most number of shifts.
Ive created the SQL creation, insert statements for the tables, and a little diagram to explain what im trying to acomplish, im a beginner a...
This particular assignment has to do with removing substrings from strings; I am trying some of the Stanford SEE courses online to learn some new languages.
What I've got so far is below, but if text = "hello hello" and remove ="el", it gets stuck in a loop, but if i change text to text = "hello hllo", it works, making me think I'm doi...
#include "stdio.h"
#include "conio.h"
#include <iostream>
using namespace std;
int main (void)
{
char my_char[] = "happy birthday";
int i;
bool j=false;
char my_char_temp[1];
do
{
for (i=0;i<sizeof(my_char)-2;i++)
{
j=false;
if (my_char[i+1] < my_char[i])
{...
I'm having some trouble with a hw assignment. In one assignment, we had to create a Person class. Mine was:
public class Person
{
String firstName;
String lastName;
String telephone;
String email;
public Person()
{
firstName = "";
lastName = "";
telephone = "";
email = "";
}
...
void printScientificNotation(double value, int powerOfTen)
{
if (value >= 1.0 && value < 10.0)
{
System.out.println(value + " x 10^" + powerOfTen);
}
else if (value < 1.0)
{
printScientificNotation(value * 10, powerOfTen - 1);
}
else // value >= 10.0
{
printScientificNotation(value / 10, powerOfTen + 1);
}
}
assuming...
Hey guys, I know this is a very simple question but I am new to Java so please bear with me. I have create a program that can calculate the time a book is due to come back after being issued! So please help me out.
Here is the piece of code that I have:
public void loan(int numOfDays) {
if( onLoan == true) {
System.out.print...
Hi. I have task to write program allowing users to draw stars, which can differ in size and amount of arms. When I was dealing with basic stars I was doing it with GeneralPath and tables of points :
int xPoints[] = { 55, 67, 109, 73, 83, 55, 27, 37, 1, 43 };
int yPoints[] = { 0, 36, 36, 54, 96, 72, 96, 54, 36, 36 };
Graph...
I have one class called Person that basically looks like:
public class Person
{
String firstName;
String lastName;
String telephone;
String email;
public Person()
{
firstName = "";
lastName = "";
telephone = "";
email = "";
}
public Person(String firstName, String lastName, S...
I need to convert a date to a string. The date is entered as 07/04/2010 and should then read July 4th 2010. It should also be able to be entered using singe digits instead of double (7 instead of 07, and it needs to add the 20 to the year if the user enters only /10).
This is what I have so far -
#!/usr/bin/perl
use CGI qw(:standard)...