Algorithms And Data Structures
Aug 29, 2014I know nothing about algorithms and data structures.Is there any good books where I can start learning it.Should I also learn advanced mathematics?
View RepliesI know nothing about algorithms and data structures.Is there any good books where I can start learning it.Should I also learn advanced mathematics?
View Replieshow to create new nodes with this values below and insert them in the following order.
55, 2, 76, 2 , 9, 1, 90, 43, 5, 23, 86, 3, 321, 4, 32, 66, 99, 12, 21
I have one Insert method One traversal method, with a post-order( I don't know if I need to use pre-order, I'm trying to use a very poor hash function ℎ(xx)= √xx xKK mod 2 where xx is 2012559 and KK=3.14. If ℎ(xx) = 0, my traversal method is pre-order, and if ℎ(xx) = 1 my traversal will be post-order.I have 4 separated classes, Tree.java, Node.java, Test.java and traversalType.java
package BST;
public class Node {
int data;
Node leftChild;
Node rightChild;
public Node(){
[code]....
how to create new nodes with this values below and insert them in the following order.
55, 2, 76, 2 , 9, 1, 90, 43, 5, 23, 86, 3, 321, 4, 32, 66, 99, 12, 21
I have one Insert method One traversal method, with a post-order( I don't know if I need to use pre-order, I'm trying to use a very poor hash function ℎ(xx)= √xx xKK mod 2 where xx is 2012559 and KK=3.14. If ℎ(xx) = 0, my traversal method is pre-order, and if ℎ(xx) = 1 my traversal will be post-order.
I have 4 separated classes, Tree.java, Node.java, Test.java and traversalType.java
package BST;
public class Node {
int data;
Node leftChild;
Node rightChild;
public Node(){
[code]....
I'm finishing my data structures class and looking for internships and trying to prepare myself for real world application of things I've learned. I'm trying to figure out what sort of project I can start or start over winter break that would use the new data structures I've learned (BSTs, Heaps, Hash Tables, etc). We have been implementing these from scratch but would I be using a library for these on the job? If so, should I implement them that way instead? I have a registrar project from my first data structures class where I used a linked list and then an array list to take care of the different students, classes, and instructors. Maybe I should clean that up and just use that?
how these data structures can be used in non-trivial situations and why I should use one over another. I just don't know a good place to start.
I have a java query like this
query ="Select major_career.Major_Title, career.ISCOTitle,career.FS.... " //only partial,
// I swear the query is correct
resultSet = statement.executeQuery(query); //this executes it
relArr = new ArrayList<String>(); //don't worry it is intialized
In the code below I tried to store the resultset components into the arraylist
int j = 1;
while (resultSet.next()) {
while(j<=numberOfColumns){
relArr.add(resultSet.getObject(j).toString());
j++;
}
} // end while
I am not sure whether the arraylist is able to store the result set because when i try to display it like show below it only shows some rows and only the first column
Iterator it = relArr.iterator();
while (it.hasNext())
{
System.out.println(it.next());
I want to manipulate the resultset results in my program by copying the resultset values to other datastructures.
I've looked over the concepts of Java programming, tested them in code and i understand most of them. I have a problem when i need to make harder programs , this might be because i dont know design patterns and algorithms.I'm curious what a entry level programmer needs to know to get a job in the field. Right now i was thinking i need to know:
1. The way all big concepts work and most of the keywords.
2. Design patterns.
3. Algorithms.
what i actually need to know for an entry level job and can you tell me which design patterns and algorithms are a must know for that first job. Considering i might have financial problems in the near future this is not a theoretical question, i really need to know what i need to learn in the next 2-3 months to get an entry level job down.
I have three sorting algorithms in which I must count the number of swaps/copies and comparisons. I am meant to only count the swaps and comparisons that involve anything other than indexes as they are too fast to really matter (according to the professor). My counters are in the right position or not. I keep coming up with swaps/comparisons that don't necessarily match the formulas I'm finding for best/worst case. Makes me think that my counters are somehow out of place or that I don't have enough of them.
Insertion Sort:
public class InsertionSort {
public static void insertionSorter(int[] array) {
int firstValue; // first value in array
int scan; // scan array through the array
int moves = 0; // number of moves
[Code] ....
How to Write Program with out using control structures
IMG_4216.JPG
Every type of controllable object in my game is a type of Entity, and so extends Entity. This is broken down into Ship(s) and Structure(s). But I have different types of structures as well. The problem is that I use an ArrayList<Structure> to store all of a team's structures, but I need to be able to loop through that, and still be able to reference the subclasses of those structures.
For example, I have a JumpGate, which extends Structure. I need to be able to reference a particular JumpGate - as a JumpGate - and not as a Structure. However, the way that I cycle through all of the different types of structures is with an ArrayList<Structure>. I could get around this by having an ArrayList<JumpGate>, however, I would then need a seperate ArrayList for every type of Structure, which would get messy.
I would like to understand how does multipart/form-data works during file upload scenario's, Does it chunks the data from client to server while transferring the files ?
View Replies View Relatedimport javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class DisplayFinal_Panel extends JPanel {
private JLabel label1, label2, label3;
private JTextField box;
[code]....
I only want Listener 1 to work right now. Also, user input is in TextField.
I'am trying to converting string data into xml data using xml beans and StringEscapeUtils.This is work fine but in one case it if the data contains special characters.
Code snippet
--------------------
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
public class ParseXMLData {
public static XmlObject parseXML(String stringXML) {
XmlObject xmlObject = null;
[Code] ....
success case
---------------------------
i/p------<aaa><bbb>This converts string to xml</bbb></aaa>
o/p---<aaa><bbb>This converts string to xml</bbb></aaa>
Failer case
-----------------
i/p----<aaa><bbb>This fails if it contains < symbols</bbb></aaa>
expected o/p----<aaa><bbb>This fails if it contains < symbols</bbb></aaa>
Observed that it converts < to '<' but as per xml rules, if data contains '< ' it fails. I want to convert staring and end tags to xml format and if data in b/w middle of starting and ending tags do'n need to convert it. How to do it.
Is there a way to inform the Entity Manager or force the JPA provider to reload data from the database? The scenario could be data being updated by a store procedure or direct SQLPlus maintenance, without restarting the Application Server, the JPA need to load the newly updated data from the database.
I think the current JPA API is not enough. The void refresh(java.lang.Object entity) from EntityManager need to pass in the Entity object, I will like to know how to refresh the entire JPA Entity data after the physical table data being update from backend.
By using FileReader, FileWriter and their constituents, I am creating a file to contain employee information ( name, age, hours, etc. ). The user is to input all of the data on a single line and we were asked to implement StringTokenizer to assign that data to the file. I have never used the StringTokenizer before, but I have a rough idea how it is to function. I used pw.println to test what I have so far, now I would like to let the user build the initial file with the "first employees" of the company, and then view the file, and then go back and append new employee data to that same file. My question is, how can I take the user input as a StringTokenizer and add that to the file?
In the for loop below, I thought I would see if it would work, but it does not. The loop only executes once and does not allow me to enter data.
public class Records {
public static void main(String [] args) throws IOException {
Scanner input = new Scanner(System.in);
FileWriter fw = new FileWriter("dbs3.java");
BufferedWriter bw = new BufferedWriter(fw);
PrintWriter pw = new PrintWriter(bw);
System.out.println("NEW EMPLOYEE DATA SHEET");
System.out.print("Number of new employees: ");
int number = input.nextInt();
[Code] ....
I am using apache-commons-fileupload to get file from client to the server.(using JSP and Servlet).
JSP/HTML
<form method="POST" action="GetFile" enctype="multipart/form-data">
<input type="file" name="datafile">
<input type="text" name="text1">
<input type="submit" value="Next">
</form>
Servlet: GetFile
System.out.println(request.getParameter("text1"));
I am able to upload the file to the server, but I am not able to get the value of text1 in the servlet (I am getting null value of text1 in the servlet), I need this textfield in the form to submit some additional information while uploading it to the server.
--> Is enctype="multipart/form-data" option of form doesn't allow other form data to be submited? if it doesn't allow it then what are the other options I have to send this additional textfield to the server.
--> Or is there any other problem in my code?
I have written several simple data classes that I serialized manually by converting to text. At this point I need to serialize a more complex data structure. which will include lists of the simpler elements. Can serialize store and reconstitute this type of structure automatically or do I need to do this one manually as well? Consider the pseudocode below for a clarification of my question;
Java Code:
Class Hops{
String Name;
float Alpha Acid;
float Beta Acid;
};
Class Malt{
String Name;
float extract;
};
Class Recipie{
String Name;
CList HopList;
CList MaltList;
};
CList RecipieList; mh_sh_highlight_all('java');
I read the article on Serialization presented at tutorial point, but the example only showed a simple class, not lists of class members. What I want to do is serialize RecipieList, which consists of a CList of Recipies, which in turn consist of CLists of various ingredients.
I have a program which consist of several classes. The program reads a pom file and parses the data and then writes the data to a static table. The issue I'm having is with writing my LIB file data to my table. In the HtmlDataTable Class Im trying to write the files that are read in the lib directory to the table. My table currently consist of 3 columns (missing jar files,Lib Directory files, and POM file data) currently Im only able to write the missing jar files data to my table. In the HtmlDataTable class there is a for statement where I write the missing jar file data to my table. Im also trying to write the contents of the Lib directory within this statement as well. This is where I'm having my issue. My other classes consist of a SAX parser which parses the xml file, a class that creates my static table and a class that compares the jar files in my lib directory to the jar files in my pom file. . Theres a lot of code so I included the parts I felt were useful. If needed I can include the other classes as well.
public class ReadPomFile extends DefaultHandler {
public static void main(String[] args) {
try {
// obtain a SAX based parser to parse XML document
[Code].....
I am creating a program where it reads the data inside a file and then places this data into arrays. The file I created has numbers 1-30 in it, file named, testing1.txt .
Java Code:
public static void main(String[] args) {
// TODO Auto-generated method stub
// Variables Declaration Section
//******************************
BufferedReader br;
String sCurrentLine;
String str;
[Code] ....
My issue is that the 'str' value is not initialized, but if I initialize it, it ruins the code. I'm not sure what to do in the situation.
<?xml version="1.0" encoding="UTF-8"?>
<RESULTS>
<ROW>
<COLUMN NAME="ID"><![CDATA[101]]></COLUMN>
<COLUMN NAME="CUS_NAME"><![CDATA[Er]]></COLUMN>
<COLUMN NAME="PHONE_NUMBER"><![CDATA[9600605183]]></COLUMN>
<COLUMN NAME="MAIL_ID"><![CDATA[satheesh.selvam554@gmail.com]]></COLUMN>
</ROW>
</RESULTS>
My xml file is look like this how to get data from this file through tag name.
write a program that will take in a URL as input and then search through the text on that webpage to pull out relevant data.Essentially, my plan was to have the program search the webpage on certain strings and then find and record the numbers on the same line to compile into another file. Luckily, all of the data I need are in tables on the webpage so I assumed that would make it easier to get the data.
The problem that I am facing is that I do not know where to start. I have been searching the web for answers to this but, unfortunately, the only thing people tend to recommend is using an HTML parser. This would not work since HTML code is not what I am looking for and does not include the data I seek.
I am new to Java programming and how to store data in Java.....Here is a example:Unique number, description, qty in box, price...There are thousands of these in my list. What would be the best way to store them.
View Replies View Related[code=java]
public static void main(String[] args) throws FileNotFoundException, IOException {
// TODO code application logic here
FileReader fr = new FileReader("gautam.txt");
BufferedReader br = new BufferedReader(fr);
[Code] ....
Whats wrong with this code?
I've created a method to calculate the ratio of one vowel to another, but I was hoping to get some feedback on another way I could approach the problem. The first bit of code is to find the vowels and assign them to an array ( for me, it seemed the easier thing to do in order to easily access the data). In the other bit of code, I have a method with two arguments (the vowels) to calculate the ratio.
public void findVowels(StringBuilder message, String delimiter) {
subString = message.toString().toLowerCase().split(delimiter);
vowelCounter = new int[5][subString.length];
// Remove all whitespace
for (int index = 0; index < subString.length; index++) {
subString[index] = subString[index].replaceAll("s", "");
[code]....
I'm trying to show mysql data in JSF using this example [URL] .... . I figured out what <h:dataTable value="#{userBean.getUserList()}" var="u" border="1"> must be <h:dataTable value="#{userBean.userList}" var="u" border="1"> but getting error:
09:08:38,654 ERROR [stderr] (http--127.0.0.1-8080-1) at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:307)
09:08:38,654 ERROR [stderr] (http--127.0.0.1-8080-1) at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:101)
[code]...
My professor like us to make a salary, taxes and etc exercise. which we should type the name first then, input salary. then if we input the amount 8000 or higher. the system will ask another question about the marital status. and that is it.
My real problem is when we input 5000-7999 the system should ask a different question, stating do you want to pay for your premiums and a follow up of yes and no choices. if we input 0-4999 the system will just state that it is your current salary.... etc..
package exer5;
import java.util.Scanner;
public class Exer5 {
public static void main(String[] args) {
Scanner Kirk = new Scanner (System.in);
[code]....
I have a class which connects with database and fills object with data. Method looks like this:
//in database class
void getData(anObject a, int id){
//connects with database
a.field1=get...
a.field2=get...
....
//disconnects
}
Now I want to use this method in anObject class, but I can't call it because I don't have created object jet. Is there any way to call this method?