homework

Initialize hashtable c++

I am trying to initialize a hashtable. when i do the stock's operator= overload is called. I am not sure what i need to do in this function? ...

how to create our own exceptions in java

hi can any one pls give me simple example for creating and using UserDefined Exceptions in java thanks in advance SS ...

Connected direct graph, find alg...

You are given a connected directed graph G = (V,E). Design a O(n+m)-time algorithm that computes a directed path that starts from a vertex v 2 G, visit each edge exactly once (according to its direction) and ends in v. If such path cannot be found, your algorithm should determine that. ...

Can Lucene return several search results from a single indexed file?

I am using Lucene to index and search a small number of large documents. Using the demo from the Lucene site I have indexed the documents and am able to search them. However, the search result is not particularly useful as it points to the file of the document. With very large documents this isn't particularly useful. I am wondering if ...

Require some help with Java..

Use of if to simulate modulus operator Rewrite this increment() method from the NumberDisplay() class without using the % modulus operator. /** Increment the display value by one * rolling over to zero if the limit is reached */ public void increment() { if(value > limit); else value = (value + 1); value = 0; } well,...

How do I add an inline style (specifically border width) to a div element?

Here is my task first and foremost: At the top of the page body, insert a div element with the id "header" containing the inline image "mlogo.jpg". The aternate text for the image should be "Mayer Photography". Insert an inline style that sets the border width of the image to 0 pixels. So that's my task and here is what I have come up...

What's wrong with my Dutch National Flag algorithm?

I'm trying to turn an array like this: 0, 1, 2, 2, 1, 0, 1, 0, 0, 1, 2 into this: 0 0 0 0 1 1 1 1 2 2 2 Here is my code: public static int[] sortDNF(int[] tape) { int smaller = 0; // everything with index < smaller is 0 int bigger = tape.length - 1; // everything with index > bigger is 2 int current = 0; // where we are looking...

Graph Adjacency List How to implement O(1) lookup for nodes/vertexes. Array?

I read in the specifications for graphs implemented with Adjacency List that adding edges is done in constant time. BUT that would require a node lookup with O(1). I would like best possible performance. The question here is which datatype would would give me that. Hashmap has been considered, worst case with hashmap is still O(n). Cou...

Representing game states in Tic Tac Toe

The goal of the assignment that I'm currently working on for my Data Structures class is to create a of Quantum Tic Tac Toe with an AI that plays to win. Currently, I'm having a bit of trouble finding the most efficient way to represent states. Overview of current Structure: AbstractGame Has and manages AbstractPlayers (game.nextP...

Buffer size in C

When provided with a buffer size in C, how do I know how much is left and when do I need to stop using the memory? For example, if the function I am writing is this: void ascii_morse (lookuptable *table, char* morse, char* ascii, int morse_size) { } In this application I will be passed a string (ascii) and I will convert it to morse...

Java Queue Merge, Beginner

I'm trying to write a method that will take in two Queues (pre-sorted Linked Lists) and return the merged, in ascending order, resulting Queue object. I pasted the Queue class, the merge method starts 1/2 way down. I'm having trouble calling merge, this is how I am trying to call it from my main method, can anyone help with this call ...

Printing 5 numbers in a row

I have to write a program to print the numbers 1 to 50, but with 5 numbers in a row, like: 1,2,3,4,5 6,7,8,9,10 like that till 50 without using lists for i in range(2,51): if i%5==0: print i this is giving me 5,10,15,20 Please help me ...

C++, Can't use an array or vectors, how do I use a pointer to get through this mess?

I need help with pointers and memory management. I need to store different objects, all derived from the same base class, and have been using an array to do this but it is causing a segmentation fault when the array is populated with different objects. My program works fine when the array is full of objects of the same derived type. ...

send SIGINT to child process

I am trying to create a child process and then send SIGINT to the child without terminating the parent. I tried this: pid=fork(); if (!pid) { setpgrp(); cout<<"waiting...\n"; while(1); } else { cout<<"parent"; wait(NULL); } but when I hit C-c both process were terminated ...

please explain this line of code

please explain whats happening in this line of code . specialy what is args[0].tocharArray char[] password = args[0].toCharArray(); ...

Regular expression required

Please give me one regular expression which mathes these kind of name formats like: 1) M/S.KHALIL WARDE S.A.L. 2) Oliver Twist The expression should allow alphabets, dot, space and / only. thanks ...

C# Plugin model with user supplied RegEx

Hi I have a program in C# WPF which analyzes certain log files. Each log contains lines of data in a format which contains an address and a data offset. For eg some log file can have the format, mmio address : data or some can have the format write address : data There can be many such formats, but rest assured that each line whe...

Surjective functions

As an extension question my lecturer for my maths in computer science module asked us to find examples of when a surjective function is vital to the operation of a system, he said he can't think of any! I've been doing some googling and have only found a single outdated paper about non surjective rounding functions creating some flaws i...

please, how can i extend this code?

hi, can you please tell how i can extend the following code so that five professions can be added in the xml document? <?xml version=”1.0” encoding=”ISO-8859”?> <!DOCTYPE person [ <!ELEMENT first_name (#PCDATA)> <!ELEMENT last_name (#PCDATA)> <!ELEMENT profession (#PCDATA)> <!ELEMENT name (first_name, last_name)> <!ELEMENT person (name,...

Function composition in Java

I'm trying to implement a lazy sequence (meaning that the next item is only calculated when you invoke the step function), and one of the methods it should have is "map" which receives a function that affects all the members. The most elegant way to do this is to use function composition, and assign the new function to the function varia...