homework

ocaml recurssion iteration- find last occurence of element in a list

Assuming l is a List and elem is an element, how can I return the last occurence of the element elem in the list l? Also return -1 if the element does not exisit in l. I dont quite understand how to use recursion for iterating through the list... let rec getLastOccurence l elem = ;; ...

Bash Can not get IF to work like I want to

I need to understand bash if expressions. Sure, I've used Google. I know that it goes something like this: if [ expr operator expr ] then doSomeThing fi However, I understand that Bash doesn't have a boolean data type. I want to check if the file passed as an argument ($1) exists. The way I would do this straight of my mind: if [ -...

Finding PI Value using "Dart Board Method"

Hi, I'm trying to find the value of PI using the "Dart Board Method" but I've been unable to find a relevant algorithm on the net. Do you know of a link which can help me to understand this method and also provides an algorithm for this? Thanks. ...

Is it possible to create a linked list on the stack in C++?

Hi i just started learning C++ couple of weeks ago. So now I have this school assignment problem that asks me to implement a linked-list without using "new" or anything to do with dynamically allocating memory (and cannot use any ADT from STL). The prof says that everything can be done on the stack, but how? I have been working on this s...

Bash comparing stored "boolean" value with what?

Hi, I'm trying to make a program that takes in one argument. A file. And then checks what has happened to the file 60 seconds later. To do this, I need to store the result from "-e $1" in a variable and then check it 60 seconds later. I can not seem to be able to make the if expression listen to me, and I know it's wrong. For testing pur...

Nonrestoring division for unsigned binary

I have tried to look online for a way to do a non-restoring division, but the explanation has still left me quite clueless. dividend = 0100 0011 1100 0000 quotient = 0110 0010 divisor is not given How do you figure out the total # of operations (ie. the number of subtractions, the number of additions performed)? ...

Generating random number between [-1, 1] in C?

I have seen many questions on SO about this particular subject but none of them has any answer for me, so I thought of asking this question. I wanted to generate a random number between [-1, 1]. How I can do this? ...

Hex to char array in C

Given a string of hex values i.e. e.g. "0011223344" so that's 0x00, 0x11 etc. How do I add these values to a char array? Equivalent to say: char array[4] = { 0x00, 0x11 ... }; ...

How can I sort a list when the sorting criterion requires an extra variable? C++

Hi there, this is for an assignment so I will be deliberately general. My question is related to implementation decisions I already made--maybe they weren't good ones. I have a list of pointers to structs, e.g. list<MyStruct*> bob; At one point I've needed to sort these pointers by one of the data members of their targets and I was able...

Help needed to write a comparator for my job interview code sample

I need help to write a comparator :- I want this output :- Martin Joseph Male 4/2/1979 Green Ramya Patil Female 5/4/2009 Red Don kelly Male 5/6/1986 Yellow Van Shinde female 3/4/1984 Green But i am getting the following output :- Output 1: Van Shinde female 3/4/1984 Green Don kelly Male 5/6/1986 Yellow Ram...

Data structure for search engine in JAVA?

Hi, I m MCS 2nd year student.I m doing a project in Java in which I have different images. For storing description of say IMAGE-1, I have ArrayList named IMAGE-1, similarly for IMAGE-2 ArrayList IMAGE-2 n so on..... Now I need to develop a search engine, in which i need to find a all image's whose description matches with a word ente...

How to write that in assembly?

I have just started a part time course and I have limited class time. I am really stuck on this question, any help solving it is greatly appreciated! here's the question.... (a) write a subprogram which will take one argument, x, and return x*3 + 1. I.e. a Java method would be int fun(int x){ return x*3 + 1; } (b) Write a fragment o...

How do I update an Entity Reference using a SelectList in edit form? (asp.net mvc)

Hi There, Just trying to figure out how do achieve the following: I have an edit form, and a simple viewmodel for said form. The viewmodel contains an entity and then a few SelectLists for dropdowns. The problem is this: The entity in question has a related entity (which is called room). I want the user to be able to select a differe...

How are ASCII characters stored in memory?

Consider a computer that has a byte addressable memory organized in 32 bit words according to the big endian scheme. A program reads ASCII characters entered at a keyboard and stores them in successive byte locations, starting at location 1000. Show the contents of two memory words at locations 1000 and 1004 after the name "johnson" has ...

handling integer having large number of digits

how to handle integers having say 25 digits in c++ solve the problems.. ...

How to argue that if we could solve the halting problem, then we could solve busy beaver?

This is one of the tasks of my assignment. I have a Turing machine simulation which can simulate a busy beaver function. I have done some research about proving this problem, but still don't get it so I guess maybe you can help me here. A good source for me to go to or example of how to argue this would be good. ...

Java with database storage.

I have to write a program that can take bookings, store them and then access them at a later time, the application has to be written in Java. Because of this i have been looking into various ways to use a database with Java. I have been looking into using the JDBC with the mySQL driver database and also looking into the javaDB. What wou...

retrieve each values in the Div

this piece of code will loop for several time; When any user select any of the radio button I want to find which radio button is selected; With the selected index i want to get address_ object; now i want to access its siblings div values like addressLine_1, addressLine_2, addressLine_3, city, state, zip in a variable. Please help to m...

What is the difference between partition sort and quick sort?

What is the difference between partition sort and quick sort? ...

Could use some help with this soundex coding.

The US census bureau uses a special encoding called “soundex” to locate information about a person. The soundex is an encoding of surnames (last names) based on the way a surname sounds rather than the way it is spelled. Surnames that sound the same, but are spelled differently, like SMITH and SMYTH, have the same code and are filed toge...